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