|
| 1 | +@use 'sass:map'; |
1 | 2 | @use '@material/snackbar/snackbar-theme' as mdc-snackbar-theme;
|
2 | 3 | @use '../core/theming/theming';
|
3 | 4 | @use '../core/theming/inspection';
|
|
8 | 9 | @use '../core/tokens/m2/mat/snack-bar' as tokens-mat-snack-bar;
|
9 | 10 |
|
10 | 11 | @mixin base($theme) {
|
| 12 | + @if inspection.get-theme-version($theme) == 1 { |
| 13 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, base)); |
| 14 | + } |
| 15 | + @else { |
11 | 16 | // Add default values for tokens not related to color, typography, or density.
|
12 |
| - @include sass-utils.current-selector-or-root() { |
13 |
| - @include mdc-snackbar-theme.theme(tokens-mdc-snack-bar.get-unthemable-tokens()); |
| 17 | + @include sass-utils.current-selector-or-root() { |
| 18 | + @include mdc-snackbar-theme.theme(tokens-mdc-snack-bar.get-unthemable-tokens()); |
| 19 | + } |
14 | 20 | }
|
15 | 21 | }
|
16 | 22 |
|
17 | 23 | @mixin color($theme) {
|
18 |
| - @include sass-utils.current-selector-or-root() { |
19 |
| - @include mdc-snackbar-theme.theme(tokens-mdc-snack-bar.get-color-tokens($theme)); |
20 |
| - @include token-utils.create-token-values( |
21 |
| - tokens-mat-snack-bar.$prefix, |
22 |
| - tokens-mat-snack-bar.get-color-tokens($theme) |
23 |
| - ); |
| 24 | + @if inspection.get-theme-version($theme) == 1 { |
| 25 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, color)); |
| 26 | + } |
| 27 | + @else { |
| 28 | + @include sass-utils.current-selector-or-root() { |
| 29 | + @include mdc-snackbar-theme.theme(tokens-mdc-snack-bar.get-color-tokens($theme)); |
| 30 | + @include token-utils.create-token-values( |
| 31 | + tokens-mat-snack-bar.$prefix, |
| 32 | + tokens-mat-snack-bar.get-color-tokens($theme) |
| 33 | + ); |
| 34 | + } |
24 | 35 | }
|
25 | 36 | }
|
26 | 37 |
|
27 | 38 | @mixin typography($theme) {
|
28 |
| - @include sass-utils.current-selector-or-root() { |
29 |
| - @include mdc-snackbar-theme.theme(tokens-mdc-snack-bar.get-typography-tokens($theme)); |
| 39 | + @if inspection.get-theme-version($theme) == 1 { |
| 40 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, typography)); |
| 41 | + } |
| 42 | + @else { |
| 43 | + @include sass-utils.current-selector-or-root() { |
| 44 | + @include mdc-snackbar-theme.theme(tokens-mdc-snack-bar.get-typography-tokens($theme)); |
| 45 | + } |
30 | 46 | }
|
31 | 47 | }
|
32 | 48 |
|
33 | 49 | @mixin density($theme) {}
|
34 | 50 |
|
35 | 51 | @mixin theme($theme) {
|
36 | 52 | @include theming.private-check-duplicate-theme-styles($theme, 'mat-snack-bar') {
|
37 |
| - @include base($theme); |
38 |
| - @if inspection.theme-has($theme, color) { |
39 |
| - @include color($theme); |
40 |
| - } |
41 |
| - @if inspection.theme-has($theme, density) { |
42 |
| - @include density($theme); |
| 53 | + @if inspection.get-theme-version($theme) == 1 { |
| 54 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme)); |
43 | 55 | }
|
44 |
| - @if inspection.theme-has($theme, typography) { |
45 |
| - @include typography($theme); |
| 56 | + @else { |
| 57 | + @include base($theme); |
| 58 | + @if inspection.theme-has($theme, color) { |
| 59 | + @include color($theme); |
| 60 | + } |
| 61 | + @if inspection.theme-has($theme, density) { |
| 62 | + @include density($theme); |
| 63 | + } |
| 64 | + @if inspection.theme-has($theme, typography) { |
| 65 | + @include typography($theme); |
| 66 | + } |
46 | 67 | }
|
47 | 68 | }
|
48 | 69 | }
|
49 | 70 |
|
| 71 | +@mixin _theme-from-tokens($tokens) { |
| 72 | + @if ($tokens != ()) { |
| 73 | + @include mdc-snackbar-theme.theme(map.get($tokens, tokens-mdc-snack-bar.$prefix)); |
| 74 | + @include token-utils.create-token-values( |
| 75 | + tokens-mat-snack-bar.$prefix, map.get($tokens, tokens-mat-snack-bar.$prefix)); |
| 76 | + } |
| 77 | +} |
0 commit comments