@carbon/elements 10.40.0 → 10.42.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 (42) hide show
  1. package/README.md +1 -1
  2. package/package.json +10 -10
  3. package/scss/grid/_inlined/_mixins.import.scss +416 -0
  4. package/scss/grid/_inlined/_mixins.scss +14 -0
  5. package/scss/grid/_mixins.import.scss +416 -0
  6. package/scss/grid/_mixins.scss +14 -0
  7. package/scss/grid/modules/_breakpoint.scss +4 -4
  8. package/scss/grid/modules/_css-grid.scss +2 -2
  9. package/scss/grid/vendor/@carbon/layout/_breakpoint.scss +4 -4
  10. package/scss/grid/vendor/@carbon/layout/_convert.import.scss +56 -0
  11. package/scss/grid/vendor/@carbon/layout/_convert.scss +14 -0
  12. package/scss/grid/vendor/@carbon/layout/_key-height.import.scss +112 -0
  13. package/scss/grid/vendor/@carbon/layout/_key-height.scss +14 -0
  14. package/scss/grid/vendor/@carbon/layout/modules/_breakpoint.scss +4 -4
  15. package/scss/grid/vendor/@carbon/layout/modules/_convert.scss +4 -2
  16. package/scss/layout/_breakpoint.scss +4 -4
  17. package/scss/layout/_convert.import.scss +56 -0
  18. package/scss/layout/_convert.scss +14 -0
  19. package/scss/layout/_key-height.import.scss +112 -0
  20. package/scss/layout/_key-height.scss +14 -0
  21. package/scss/layout/modules/_breakpoint.scss +4 -4
  22. package/scss/layout/modules/_convert.scss +4 -2
  23. package/scss/themes/generated/_mixins.scss +287 -0
  24. package/scss/themes/generated/_themes.scss +506 -20
  25. package/scss/themes/generated/_tokens.scss +578 -20
  26. package/scss/themes/modules/_theme.scss +60 -0
  27. package/scss/type/_inlined/_scale.scss +1 -1
  28. package/scss/type/_inlined/_styles.import.scss +761 -0
  29. package/scss/type/_inlined/_styles.scss +214 -36
  30. package/scss/type/_scale.scss +1 -1
  31. package/scss/type/_styles.import.scss +761 -0
  32. package/scss/type/_styles.scss +214 -36
  33. package/scss/type/modules/_scale.scss +1 -1
  34. package/scss/type/modules/_styles.scss +187 -26
  35. package/scss/type/vendor/@carbon/layout/_breakpoint.scss +4 -4
  36. package/scss/type/vendor/@carbon/layout/_convert.import.scss +56 -0
  37. package/scss/type/vendor/@carbon/layout/_convert.scss +14 -0
  38. package/scss/type/vendor/@carbon/layout/_key-height.import.scss +112 -0
  39. package/scss/type/vendor/@carbon/layout/_key-height.scss +14 -0
  40. package/scss/type/vendor/@carbon/layout/modules/_breakpoint.scss +4 -4
  41. package/scss/type/vendor/@carbon/layout/modules/_convert.scss +4 -2
  42. package/src/__tests__/__snapshots__/PublicAPI-test.js.snap +24 -0
@@ -20,6 +20,9 @@ $fallback: themes.$white !default;
20
20
  $theme: () !default;
21
21
  $theme: map.merge($fallback, $theme);
22
22
 
23
+ /// Local component tokens that can be updated with `@mixin add-component-tokens`.
24
+ $-component-tokens: ();
25
+
23
26
  /// Include the CSS Custom Properties for the active theme or a given theme on
24
27
  /// a selector
25
28
  @mixin theme($active-theme: $theme, $component-tokens...) {
@@ -32,6 +35,13 @@ $theme: map.merge($fallback, $theme);
32
35
  @include -custom-property($token, $value);
33
36
  }
34
37
  }
38
+
39
+ @each $token, $value in $-component-tokens {
40
+ @include -custom-property(
41
+ $token,
42
+ -resolve-token-value($active-theme, $value)
43
+ );
44
+ }
35
45
  }
36
46
 
37
47
  /// Retrieve the value for the given $token from the current $theme
@@ -43,6 +53,56 @@ $theme: map.merge($fallback, $theme);
43
53
  @error "Unable to find token: #{$token} in current $theme";
44
54
  }
45
55
 
56
+ /// Compare two themes to see if the second theme is a superset of the first
57
+ /// theme. In other words, this function will return true if every token in the
58
+ /// first theme is available in the second theme and has the same value. The
59
+ /// second theme is allowed to have additional values and it will still match.
60
+ /// @param {Map} $a
61
+ /// @param {Map} $b
62
+ /// @returns {Boolean}
63
+ @function matches($a, $b) {
64
+ @each $key, $value in $a {
65
+ @if map.has-key($b, $key) == false {
66
+ @return false;
67
+ }
68
+
69
+ @if map.get($b, $key) != $value {
70
+ @return false;
71
+ }
72
+ }
73
+
74
+ @return true;
75
+ }
76
+
77
+ /// Add component tokens which will be included any time the theme mixin is
78
+ /// called
79
+ @mixin add-component-tokens($token-map) {
80
+ $-component-tokens: map.merge($-component-tokens, $token-map) !global;
81
+ }
82
+
83
+ /// Determine the value from a component token that matches the given theme.
84
+ /// This is helpful when a component token may change depending on what theme the
85
+ /// component is being rendered in.
86
+ @function -resolve-token-value($active-theme: $theme, $token-value) {
87
+ @if meta.type-of($token-value) == map and map.has-key($token-value, values) {
88
+ $fallback: map.get($token-value, fallback);
89
+ $theme-values: map.get($token-value, values);
90
+
91
+ @each $theme-value in $theme-values {
92
+ $theme-to-match: map.get($theme-value, theme);
93
+ $value: map.get($theme-value, value);
94
+
95
+ @if matches($theme-to-match, $active-theme) {
96
+ @return $value;
97
+ }
98
+ }
99
+
100
+ @return $fallback;
101
+ }
102
+
103
+ @return $token-value;
104
+ }
105
+
46
106
  /// @access private
47
107
  /// @group @carbon/themes
48
108
  @mixin -custom-property($name, $value) {
@@ -17,7 +17,7 @@
17
17
  @return 12px;
18
18
  }
19
19
  // Yn = Yn-1 + {INT[(n-2)/4] + 1} * 2
20
- @return carbon--get-type-size($step - 1) + (floor(($step - 2) / 4) + 1) * 2;
20
+ @return carbon--get-type-size($step - 1) + (floor(($step - 2) * 0.25) + 1) * 2;
21
21
  }
22
22
 
23
23
  /// Type scale follows a custom formula for determining each step size and supports sizes from 12px to 92px