|
| 1 | +@use 'sass:map'; |
1 | 2 | @use '../core/theming/theming';
|
2 | 3 | @use '../core/theming/inspection';
|
3 | 4 | @use '../core/typography/typography';
|
|
7 | 8 | @use '../core/style/sass-utils';
|
8 | 9 |
|
9 | 10 | @mixin base($theme) {
|
10 |
| - @include sass-utils.current-selector-or-root() { |
11 |
| - @include token-utils.create-token-values( |
12 |
| - tokens-mat-legacy-button-toggle.$prefix, |
13 |
| - tokens-mat-legacy-button-toggle.get-unthemable-tokens() |
14 |
| - ); |
15 |
| - @include token-utils.create-token-values( |
16 |
| - tokens-mat-standard-button-toggle.$prefix, |
17 |
| - tokens-mat-standard-button-toggle.get-unthemable-tokens() |
18 |
| - ); |
| 11 | + @if inspection.get-theme-version($theme) == 1 { |
| 12 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, base)); |
| 13 | + } |
| 14 | + @else { |
| 15 | + @include sass-utils.current-selector-or-root() { |
| 16 | + @include token-utils.create-token-values( |
| 17 | + tokens-mat-legacy-button-toggle.$prefix, |
| 18 | + tokens-mat-legacy-button-toggle.get-unthemable-tokens() |
| 19 | + ); |
| 20 | + @include token-utils.create-token-values( |
| 21 | + tokens-mat-standard-button-toggle.$prefix, |
| 22 | + tokens-mat-standard-button-toggle.get-unthemable-tokens() |
| 23 | + ); |
| 24 | + } |
19 | 25 | }
|
20 | 26 | }
|
21 | 27 |
|
22 | 28 | @mixin color($theme) {
|
23 |
| - @include sass-utils.current-selector-or-root() { |
24 |
| - @include token-utils.create-token-values(tokens-mat-legacy-button-toggle.$prefix, |
25 |
| - tokens-mat-legacy-button-toggle.get-color-tokens($theme)); |
26 |
| - @include token-utils.create-token-values(tokens-mat-standard-button-toggle.$prefix, |
27 |
| - tokens-mat-standard-button-toggle.get-color-tokens($theme)); |
| 29 | + @if inspection.get-theme-version($theme) == 1 { |
| 30 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, color)); |
| 31 | + } |
| 32 | + @else { |
| 33 | + @include sass-utils.current-selector-or-root() { |
| 34 | + @include token-utils.create-token-values(tokens-mat-legacy-button-toggle.$prefix, |
| 35 | + tokens-mat-legacy-button-toggle.get-color-tokens($theme)); |
| 36 | + @include token-utils.create-token-values(tokens-mat-standard-button-toggle.$prefix, |
| 37 | + tokens-mat-standard-button-toggle.get-color-tokens($theme)); |
| 38 | + } |
28 | 39 | }
|
29 | 40 | }
|
30 | 41 |
|
31 | 42 | @mixin typography($theme) {
|
32 |
| - @include sass-utils.current-selector-or-root() { |
33 |
| - @include token-utils.create-token-values(tokens-mat-legacy-button-toggle.$prefix, |
34 |
| - tokens-mat-legacy-button-toggle.get-typography-tokens($theme)); |
35 |
| - @include token-utils.create-token-values(tokens-mat-standard-button-toggle.$prefix, |
36 |
| - tokens-mat-standard-button-toggle.get-typography-tokens($theme)); |
| 43 | + @if inspection.get-theme-version($theme) == 1 { |
| 44 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, typography)); |
| 45 | + } |
| 46 | + @else { |
| 47 | + @include sass-utils.current-selector-or-root() { |
| 48 | + @include token-utils.create-token-values(tokens-mat-legacy-button-toggle.$prefix, |
| 49 | + tokens-mat-legacy-button-toggle.get-typography-tokens($theme)); |
| 50 | + @include token-utils.create-token-values(tokens-mat-standard-button-toggle.$prefix, |
| 51 | + tokens-mat-standard-button-toggle.get-typography-tokens($theme)); |
| 52 | + } |
37 | 53 | }
|
38 | 54 | }
|
39 | 55 |
|
40 | 56 | @mixin density($theme) {
|
41 |
| - @include sass-utils.current-selector-or-root() { |
42 |
| - @include token-utils.create-token-values(tokens-mat-legacy-button-toggle.$prefix, |
43 |
| - tokens-mat-legacy-button-toggle.get-density-tokens($theme)); |
44 |
| - @include token-utils.create-token-values(tokens-mat-standard-button-toggle.$prefix, |
45 |
| - tokens-mat-standard-button-toggle.get-density-tokens($theme)); |
| 57 | + @if inspection.get-theme-version($theme) == 1 { |
| 58 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, density)); |
| 59 | + } |
| 60 | + @else { |
| 61 | + @include sass-utils.current-selector-or-root() { |
| 62 | + @include token-utils.create-token-values(tokens-mat-legacy-button-toggle.$prefix, |
| 63 | + tokens-mat-legacy-button-toggle.get-density-tokens($theme)); |
| 64 | + @include token-utils.create-token-values(tokens-mat-standard-button-toggle.$prefix, |
| 65 | + tokens-mat-standard-button-toggle.get-density-tokens($theme)); |
| 66 | + } |
46 | 67 | }
|
47 | 68 | }
|
48 | 69 |
|
49 | 70 | @mixin theme($theme) {
|
50 | 71 | @include theming.private-check-duplicate-theme-styles($theme, 'mat-button-toggle') {
|
51 |
| - @include base($theme); |
52 |
| - @if inspection.theme-has($theme, color) { |
53 |
| - @include color($theme); |
| 72 | + @if inspection.get-theme-version($theme) == 1 { |
| 73 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme)); |
54 | 74 | }
|
55 |
| - @if inspection.theme-has($theme, density) { |
56 |
| - @include density($theme); |
57 |
| - } |
58 |
| - @if inspection.theme-has($theme, typography) { |
59 |
| - @include typography($theme); |
| 75 | + @else { |
| 76 | + @include base($theme); |
| 77 | + @if inspection.theme-has($theme, color) { |
| 78 | + @include color($theme); |
| 79 | + } |
| 80 | + @if inspection.theme-has($theme, density) { |
| 81 | + @include density($theme); |
| 82 | + } |
| 83 | + @if inspection.theme-has($theme, typography) { |
| 84 | + @include typography($theme); |
| 85 | + } |
60 | 86 | }
|
61 | 87 | }
|
62 | 88 | }
|
| 89 | + |
| 90 | +@mixin _theme-from-tokens($tokens) { |
| 91 | + @if ($tokens != ()) { |
| 92 | + @include token-utils.create-token-values( |
| 93 | + tokens-mat-standard-button-toggle.$prefix, |
| 94 | + map.get($tokens, tokens-mat-standard-button-toggle.$prefix)); |
| 95 | + } |
| 96 | +} |
0 commit comments