|
3 | 3 | /// @author <a href="https://github.com/simeonoff" target="_blank">Simeon Simeonoff</a>
|
4 | 4 | ////
|
5 | 5 |
|
6 |
| -/// Help debug sass maps. |
7 |
| -/// @access privet |
8 |
| -/// @example scss - Sample usage |
9 |
| -/// input[type="checkbox"] { |
10 |
| -/// @include hide-default(); |
11 |
| -/// } |
12 |
| - |
13 |
| -//@mixin debug-map($map) { |
14 |
| -// @at-root { |
15 |
| -// @debug-map { |
16 |
| -// __toString__: inspect($map); |
17 |
| -// __length__: length($map); |
18 |
| -// __keys__: map-keys($map); |
19 |
| -// |
20 |
| -// __properties__ { |
21 |
| -// @each $key, $value in $map { |
22 |
| -// #{$key}: inspect($value); |
23 |
| -// } |
24 |
| -// } |
25 |
| -// } |
26 |
| -// } |
27 |
| -//} |
28 |
| - |
29 | 6 | /// Hides the element from the DOM.
|
30 | 7 | /// @access public
|
31 | 8 | /// @example scss - Sample usage
|
|
218 | 195 | /// @include css-vars-from-theme($my-theme);
|
219 | 196 | /// }
|
220 | 197 | @mixin css-vars-from-theme($theme, $prefix: null) {
|
| 198 | + $name: map-get($theme, 'name'); |
| 199 | + $ignore: ('name', 'palette', 'variant', 'selector'); |
| 200 | + |
221 | 201 | @each $key, $value in $theme {
|
222 |
| - @if $key != 'name' and $key != 'palette' and type-of($value) != 'map' { |
| 202 | + @if not(index($ignore, $key)) and type-of($value) != 'map' { |
223 | 203 | @if $prefix {
|
224 |
| - --#{$prefix}-#{$key}: #{$value}; |
| 204 | + --#{$prefix}-#{$key}: var(--#{$name}-#{$key}, #{$value}); |
225 | 205 | } @else {
|
226 |
| - --#{$key}: #{$value}; |
| 206 | + --#{$key}: var(--#{$name}-#{$key}, #{$value}); |
227 | 207 | }
|
228 | 208 | }
|
229 | 209 | }
|
230 | 210 | }
|
231 | 211 |
|
232 |
| -/// Add theme colors to the global root scope |
233 |
| -/// Ensures the operation is done only once. |
234 |
| -/// @access private |
235 |
| -/// @param {map} $theme - The component theme to register as css vars. |
236 |
| -/// @requires {mixin} css-vars-from-theme |
237 |
| -@mixin igx-root-css-vars($theme) { |
238 |
| - $scope: &; |
239 |
| - |
240 |
| - @if map-get($themes, $scope) == null { |
241 |
| - $id: unique-id(); |
242 |
| - $themes: map-merge($themes, (#{$scope}: $id)) !global; |
243 |
| - @include igx-css-vars($theme); |
244 |
| - } |
245 |
| -} |
246 |
| - |
247 | 212 | /// Add theme colors to a scope.
|
248 | 213 | /// @access public
|
249 | 214 | /// @param {map} $theme - The component theme to be used
|
250 | 215 | /// @requires {mixin} css-vars-from-theme
|
251 |
| -@mixin igx-css-vars($theme) { |
252 |
| - $scope: if(is-root(), ':root', '&'); |
253 |
| - $prefix: map-get($theme, 'name'); |
| 216 | +@mixin igx-css-vars($theme, $scope: null, $prefix: null) { |
| 217 | + $s: map-get($theme, 'selector'); |
| 218 | + $n: map-get($theme, 'name'); |
| 219 | + $name: if($scope, $scope, $s or $n); |
254 | 220 |
|
255 | 221 | @if not(legacy()) {
|
256 |
| - #{$scope} { |
257 |
| - @include css-vars-from-theme($theme, $prefix); |
| 222 | + @if is-root() { |
| 223 | + #{$name} { |
| 224 | + @include css-vars-from-theme($theme, $prefix); |
| 225 | + } |
| 226 | + } @else { |
| 227 | + &, |
| 228 | + #{$name} { |
| 229 | + @include css-vars-from-theme($theme, $prefix); |
| 230 | + } |
258 | 231 | }
|
259 | 232 | }
|
260 | 233 | }
|
|
0 commit comments