|
| 1 | +@use 'sass:map'; |
1 | 2 | @use '../core/theming/theming';
|
2 | 3 | @use '../core/theming/inspection';
|
3 | 4 | @use '../core/typography/typography';
|
|
6 | 7 | @use '../core/tokens/m2/mat/expansion' as tokens-mat-expansion;
|
7 | 8 |
|
8 | 9 | @mixin base($theme) {
|
9 |
| - @include sass-utils.current-selector-or-root() { |
10 |
| - @include token-utils.create-token-values( |
11 |
| - tokens-mat-expansion.$prefix, tokens-mat-expansion.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 | + @include sass-utils.current-selector-or-root() { |
| 15 | + @include token-utils.create-token-values( |
| 16 | + tokens-mat-expansion.$prefix, tokens-mat-expansion.get-unthemable-tokens()); |
| 17 | + } |
12 | 18 | }
|
13 | 19 | }
|
14 | 20 |
|
15 | 21 | @mixin color($theme) {
|
16 |
| - @include sass-utils.current-selector-or-root() { |
17 |
| - @include token-utils.create-token-values(tokens-mat-expansion.$prefix, |
18 |
| - tokens-mat-expansion.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 token-utils.create-token-values(tokens-mat-expansion.$prefix, |
| 28 | + tokens-mat-expansion.get-color-tokens($theme)); |
| 29 | + } |
19 | 30 | }
|
20 | 31 | }
|
21 | 32 |
|
22 | 33 | @mixin typography($theme) {
|
23 |
| - // TODO(mmalerba): Stop calling this and resolve resulting screen diffs. |
24 |
| - $theme: inspection.private-get-typography-back-compat-theme($theme); |
| 34 | + @if inspection.get-theme-version($theme) == 1 { |
| 35 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, typography)); |
| 36 | + } |
| 37 | + @else { |
| 38 | + // TODO(mmalerba): Stop calling this and resolve resulting screen diffs. |
| 39 | + $theme: inspection.private-get-typography-back-compat-theme($theme); |
25 | 40 |
|
26 |
| - @include sass-utils.current-selector-or-root() { |
27 |
| - @include token-utils.create-token-values(tokens-mat-expansion.$prefix, |
28 |
| - tokens-mat-expansion.get-typography-tokens($theme)); |
| 41 | + @include sass-utils.current-selector-or-root() { |
| 42 | + @include token-utils.create-token-values(tokens-mat-expansion.$prefix, |
| 43 | + tokens-mat-expansion.get-typography-tokens($theme)); |
| 44 | + } |
29 | 45 | }
|
30 | 46 | }
|
31 | 47 |
|
32 | 48 | @mixin density($theme) {
|
33 |
| - @include sass-utils.current-selector-or-root() { |
34 |
| - @include token-utils.create-token-values(tokens-mat-expansion.$prefix, |
35 |
| - tokens-mat-expansion.get-density-tokens($theme)); |
| 49 | + @if inspection.get-theme-version($theme) == 1 { |
| 50 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, density)); |
| 51 | + } |
| 52 | + @else { |
| 53 | + @include sass-utils.current-selector-or-root() { |
| 54 | + @include token-utils.create-token-values(tokens-mat-expansion.$prefix, |
| 55 | + tokens-mat-expansion.get-density-tokens($theme)); |
| 56 | + } |
36 | 57 | }
|
37 | 58 | }
|
38 | 59 |
|
39 | 60 | @mixin theme($theme) {
|
40 | 61 | @include theming.private-check-duplicate-theme-styles($theme, 'mat-expansion') {
|
41 |
| - @include base($theme); |
42 |
| - @if inspection.theme-has($theme, color) { |
43 |
| - @include color($theme); |
44 |
| - } |
45 |
| - @if inspection.theme-has($theme, density) { |
46 |
| - @include density($theme); |
| 62 | + @if inspection.get-theme-version($theme) == 1 { |
| 63 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme)); |
47 | 64 | }
|
48 |
| - @if inspection.theme-has($theme, typography) { |
49 |
| - @include typography($theme); |
| 65 | + @else { |
| 66 | + @include base($theme); |
| 67 | + @if inspection.theme-has($theme, color) { |
| 68 | + @include color($theme); |
| 69 | + } |
| 70 | + @if inspection.theme-has($theme, density) { |
| 71 | + @include density($theme); |
| 72 | + } |
| 73 | + @if inspection.theme-has($theme, typography) { |
| 74 | + @include typography($theme); |
| 75 | + } |
50 | 76 | }
|
51 | 77 | }
|
52 | 78 | }
|
| 79 | + |
| 80 | + |
| 81 | +@mixin _theme-from-tokens($tokens) { |
| 82 | + @if ($tokens != ()) { |
| 83 | + @include token-utils.create-token-values( |
| 84 | + tokens-mat-expansion.$prefix, map.get($tokens, tokens-mat-expansion.$prefix)); |
| 85 | + } |
| 86 | +} |
0 commit comments