@carbon/type 10.0.0-rc.0 → 10.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +525 -0
  2. package/LICENSE +2 -2
  3. package/README.md +25 -21
  4. package/es/index.js +26 -38
  5. package/lib/index.js +31 -37
  6. package/package.json +7 -7
  7. package/scss/_classes.scss +3 -0
  8. package/scss/_font-family.scss +17 -4
  9. package/scss/_inlined/_classes.scss +41 -0
  10. package/scss/_inlined/_font-family.scss +70 -0
  11. package/scss/_inlined/_prefix.scss +11 -0
  12. package/scss/_inlined/_reset.scss +43 -0
  13. package/scss/_inlined/_scale.scss +59 -0
  14. package/scss/_inlined/_styles.scss +673 -0
  15. package/scss/_inlined/font-face/_mono.scss +430 -0
  16. package/scss/_inlined/font-face/_sans.scss +497 -0
  17. package/scss/_inlined/font-face/_serif.scss +430 -0
  18. package/scss/_inlined/font-face/_settings.scss +12 -0
  19. package/scss/_prefix.scss +3 -0
  20. package/scss/_reset.scss +20 -7
  21. package/scss/_scale.scss +16 -5
  22. package/scss/_styles.scss +145 -49
  23. package/scss/font-face/_mono.scss +41 -0
  24. package/scss/font-face/_sans.scss +144 -36
  25. package/scss/font-face/_serif.scss +77 -36
  26. package/scss/font-face/_settings.scss +12 -0
  27. package/scss/index.scss +11 -0
  28. package/scss/type.scss +4 -4
  29. package/scss/vendor/@carbon/import-once/import-once.scss +27 -0
  30. package/scss/vendor/@carbon/import-once/index.scss +8 -0
  31. package/scss/vendor/@carbon/layout/_breakpoint.scss +237 -0
  32. package/scss/vendor/@carbon/layout/_convert.scss +30 -0
  33. package/scss/vendor/@carbon/layout/_key-height.scss +97 -0
  34. package/scss/vendor/@carbon/layout/_mini-unit.scss +23 -0
  35. package/scss/vendor/@carbon/layout/_spacing.scss +328 -0
  36. package/scss/vendor/@carbon/layout/_utilities.scss +41 -0
  37. package/scss/vendor/@carbon/layout/index.scss +8 -0
  38. package/scss/vendor/@carbon/layout/layout.scss +12 -0
  39. package/src/__tests__/__snapshots__/styles-test.js.snap +121 -87
  40. package/src/__tests__/exports-test.js +43 -37
  41. package/src/__tests__/fluid-test.js +0 -1
  42. package/src/reset.js +3 -0
  43. package/src/styles.js +22 -38
  44. package/umd/index.js +31 -37
@@ -7,7 +7,9 @@
7
7
 
8
8
  /// Font family fallbacks for: IBM Plex Mono, IBM Plex Sans, IBM Plex Sans
9
9
  /// Condensed, IBM Plex Sans Hebrew, and IBM Plex Serif
10
- /// @type {Map}
10
+ /// @type Map
11
+ /// @access public
12
+ /// @group @carbon/type
11
13
  $carbon--font-families: (
12
14
  'mono':
13
15
  unquote(
@@ -23,20 +25,27 @@ $carbon--font-families: (
23
25
  'serif': unquote("'IBM Plex Serif', 'Georgia', Times, serif"),
24
26
  );
25
27
 
26
- /// Get the font-family for an IBM Plex font.
28
+ /// Get the font-family for an IBM Plex font
27
29
  /// @param {String} $name
28
30
  /// @return {String}
31
+ /// @access public
32
+ /// @group @carbon/type
29
33
  @function carbon--font-family($name) {
30
34
  @return map-get($carbon--font-families, $name);
31
35
  }
32
36
 
33
- /// Include the `font-family` definition for the given name in your selector.
37
+ /// Include the `font-family` definition for the given name in your selector
34
38
  /// @param {String} $name
39
+ /// @access public
40
+ /// @group @carbon/type
35
41
  @mixin carbon--font-family($name) {
36
42
  font-family: carbon--font-family($name);
37
43
  }
38
44
 
39
- /// Suggested font weights to be used in product.
45
+ /// Suggested font weights to be used in product
46
+ /// @type Map
47
+ /// @access public
48
+ /// @group @carbon/type
40
49
  $carbon--font-weights: (
41
50
  'light': 300,
42
51
  'regular': 400,
@@ -46,12 +55,16 @@ $carbon--font-weights: (
46
55
  /// Retrieve the font-weight value for a given name
47
56
  /// @param {String} $weight
48
57
  /// @return {Number}
58
+ /// @access public
59
+ /// @group @carbon/type
49
60
  @function carbon--font-weight($weight) {
50
61
  @return map-get($carbon--font-weights, $weight);
51
62
  }
52
63
 
53
64
  /// Set the `font-weight` property with the value for a given name
54
65
  /// @param {String} $weight
66
+ /// @access public
67
+ /// @group @carbon/type
55
68
  @mixin carbon--font-weight($weight) {
56
69
  font-weight: carbon--font-weight($weight);
57
70
  }
@@ -0,0 +1,41 @@
1
+ //
2
+ // Copyright IBM Corp. 2018, 2018
3
+ //
4
+ // This source code is licensed under the Apache-2.0 license found in the
5
+ // LICENSE file in the root directory of this source tree.
6
+ //
7
+
8
+ @import 'prefix';
9
+ @import 'styles';
10
+ @import 'font-family';
11
+
12
+ /// Create type classes for font families, weights, styles
13
+ /// @access public
14
+ /// @group @carbon/type
15
+ @mixin carbon--type-classes {
16
+ // Font families
17
+ @each $name, $value in $carbon--font-families {
18
+ .#{$prefix}--type-#{$name} {
19
+ font-family: $value;
20
+ }
21
+ }
22
+
23
+ // Font weights
24
+ @each $name, $value in $carbon--font-weights {
25
+ .#{$prefix}--type-#{$name} {
26
+ font-weight: $value;
27
+ }
28
+ }
29
+
30
+ // Font styles
31
+ .#{$prefix}--type-italic {
32
+ font-style: italic;
33
+ }
34
+
35
+ // Type styles
36
+ @each $name, $value in $tokens {
37
+ .#{$prefix}--type-#{$name} {
38
+ @include carbon--type-style($name, map-has-key($value, breakpoints));
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,70 @@
1
+ //
2
+ // Copyright IBM Corp. 2018, 2018
3
+ //
4
+ // This source code is licensed under the Apache-2.0 license found in the
5
+ // LICENSE file in the root directory of this source tree.
6
+ //
7
+
8
+ /// Font family fallbacks for: IBM Plex Mono, IBM Plex Sans, IBM Plex Sans
9
+ /// Condensed, IBM Plex Sans Hebrew, and IBM Plex Serif
10
+ /// @type Map
11
+ /// @access public
12
+ /// @group @carbon/type
13
+ $carbon--font-families: (
14
+ 'mono':
15
+ unquote(
16
+ "'IBM Plex Mono', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Courier, monospace"
17
+ ),
18
+ 'sans': unquote("'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif"),
19
+ 'sans-condensed':
20
+ unquote("'IBM Plex Sans Condensed', 'Helvetica Neue', Arial, sans-serif"),
21
+ 'sans-hebrew':
22
+ unquote(
23
+ "'IBM Plex Sans Hebrew', 'Helvetica Hebrew', 'Arial Hebrew', sans-serif"
24
+ ),
25
+ 'serif': unquote("'IBM Plex Serif', 'Georgia', Times, serif"),
26
+ );
27
+
28
+ /// Get the font-family for an IBM Plex font
29
+ /// @param {String} $name
30
+ /// @return {String}
31
+ /// @access public
32
+ /// @group @carbon/type
33
+ @function carbon--font-family($name) {
34
+ @return map-get($carbon--font-families, $name);
35
+ }
36
+
37
+ /// Include the `font-family` definition for the given name in your selector
38
+ /// @param {String} $name
39
+ /// @access public
40
+ /// @group @carbon/type
41
+ @mixin carbon--font-family($name) {
42
+ font-family: carbon--font-family($name);
43
+ }
44
+
45
+ /// Suggested font weights to be used in product
46
+ /// @type Map
47
+ /// @access public
48
+ /// @group @carbon/type
49
+ $carbon--font-weights: (
50
+ 'light': 300,
51
+ 'regular': 400,
52
+ 'semibold': 600,
53
+ );
54
+
55
+ /// Retrieve the font-weight value for a given name
56
+ /// @param {String} $weight
57
+ /// @return {Number}
58
+ /// @access public
59
+ /// @group @carbon/type
60
+ @function carbon--font-weight($weight) {
61
+ @return map-get($carbon--font-weights, $weight);
62
+ }
63
+
64
+ /// Set the `font-weight` property with the value for a given name
65
+ /// @param {String} $weight
66
+ /// @access public
67
+ /// @group @carbon/type
68
+ @mixin carbon--font-weight($weight) {
69
+ font-weight: carbon--font-weight($weight);
70
+ }
@@ -0,0 +1,11 @@
1
+ //
2
+ // Copyright IBM Corp. 2018, 2018
3
+ //
4
+ // This source code is licensed under the Apache-2.0 license found in the
5
+ // LICENSE file in the root directory of this source tree.
6
+ //
7
+
8
+ /// @type String
9
+ /// @access public
10
+ /// @group @carbon/type
11
+ $prefix: 'bx' !default;
@@ -0,0 +1,43 @@
1
+ //
2
+ // Copyright IBM Corp. 2018, 2018
3
+ //
4
+ // This source code is licensed under the Apache-2.0 license found in the
5
+ // LICENSE file in the root directory of this source tree.
6
+ //
7
+
8
+ @import '../vendor/@carbon/layout/convert';
9
+ @import 'font-family';
10
+
11
+ /// Include a type reset for a given body and mono font family
12
+ /// @param {Number} $base-font-size [$carbon--base-font-size] - The base font size for your document
13
+ /// @param {String} $body-font-family [carbon--font-family('sans')] - The font family used on the `<body>` element
14
+ /// @param {String} $mono-font-family [carbon--font-family('mono')] - The font family used on elements that require mono fonts, like the `<code>` element
15
+ /// @access public
16
+ /// @group @carbon/type
17
+ @mixin carbon--type-reset(
18
+ $base-font-size: $carbon--base-font-size,
19
+ $body-font-family: carbon--font-family('sans'),
20
+ $mono-font-family: carbon--font-family('mono')
21
+ ) {
22
+ html {
23
+ font-size: $base-font-size;
24
+ }
25
+
26
+ body {
27
+ font-family: $body-font-family;
28
+ font-weight: 400;
29
+ text-rendering: optimizeLegibility;
30
+ -webkit-font-smoothing: antialiased;
31
+ -moz-osx-font-smoothing: grayscale;
32
+ }
33
+
34
+ // IBM Plex uses semibold instead of bold, as a result we need to map
35
+ // tags that use `font-weight: bold` to the semibold value
36
+ strong {
37
+ font-weight: 600;
38
+ }
39
+
40
+ code {
41
+ font-family: $mono-font-family;
42
+ }
43
+ }
@@ -0,0 +1,59 @@
1
+ //
2
+ // Copyright IBM Corp. 2018, 2018
3
+ //
4
+ // This source code is licensed under the Apache-2.0 license found in the
5
+ // LICENSE file in the root directory of this source tree.
6
+ //
7
+
8
+ @import '../vendor/@carbon/layout/convert';
9
+
10
+ /// Compute the type size for the given type scale step
11
+ /// @param {Number} $step
12
+ /// @return {Number} In px
13
+ /// @access public
14
+ /// @group @carbon/type
15
+ @function carbon--get-type-size($step) {
16
+ @if $step == 1 {
17
+ @return 12px;
18
+ }
19
+ // Yn = Yn-1 + {INT[(n-2)/4] + 1} * 2
20
+ @return carbon--get-type-size($step - 1) + (floor(($step - 2) / 4) + 1) * 2;
21
+ }
22
+
23
+ /// Type scole follows a custom formula for determining each step size and supports sizes from 12px to 92px
24
+ /// @type Map
25
+ /// @access public
26
+ /// @group @carbon/type
27
+ $carbon--type-scale: ();
28
+ @for $i from 1 through 23 {
29
+ $carbon--type-scale: append(
30
+ $carbon--type-scale,
31
+ carbon--rem(carbon--get-type-size($i))
32
+ );
33
+ }
34
+
35
+ /// Get the value of a specific step in the typescale
36
+ /// @param {Number} $step
37
+ /// @return {Number} In rem
38
+ /// @access public
39
+ /// @group @carbon/type
40
+ @function carbon--type-scale($step) {
41
+ @return nth($carbon--type-scale, $step);
42
+ }
43
+
44
+ /// Set the font-size value of a selector with the value at the given `$step`
45
+ /// @param {Number} $step
46
+ /// @access public
47
+ /// @group @carbon/type
48
+ @mixin carbon--type-scale($step) {
49
+ font-size: carbon--type-scale($step);
50
+ }
51
+
52
+ /// Alias of `type-scale` mixin.
53
+ /// @param {Number} $step
54
+ /// @alias carbon--type-scale
55
+ /// @access public
56
+ /// @group @carbon/type
57
+ @mixin carbon--font-size($step) {
58
+ font-size: carbon--type-scale($step);
59
+ }