|
| 1 | +@use 'sass:map'; |
1 | 2 | @use '@material/radio/radio-theme' as mdc-radio-theme;
|
2 | 3 | @use '@material/form-field' as mdc-form-field;
|
3 | 4 | @use '../core/mdc-helpers/mdc-helpers';
|
|
10 | 11 | @use '../core/tokens/m2/mat/radio' as tokens-mat-radio;
|
11 | 12 |
|
12 | 13 | @mixin base($theme) {
|
13 |
| - @include sass-utils.current-selector-or-root() { |
14 |
| - @include mdc-radio-theme.theme(tokens-mdc-radio.get-unthemable-tokens()); |
15 |
| - @include token-utils.create-token-values( |
16 |
| - tokens-mat-radio.$prefix, tokens-mat-radio.get-unthemable-tokens()); |
| 14 | + @if inspection.get-theme-version($theme) == 1 { |
| 15 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, base)); |
| 16 | + } |
| 17 | + @else { |
| 18 | + @include sass-utils.current-selector-or-root() { |
| 19 | + @include mdc-radio-theme.theme(tokens-mdc-radio.get-unthemable-tokens()); |
| 20 | + @include token-utils.create-token-values( |
| 21 | + tokens-mat-radio.$prefix, tokens-mat-radio.get-unthemable-tokens()); |
| 22 | + } |
17 | 23 | }
|
18 | 24 | }
|
19 | 25 |
|
20 | 26 | @mixin color($theme) {
|
21 |
| - @include mdc-helpers.using-mdc-theme($theme) { |
22 |
| - .mat-mdc-radio-button { |
23 |
| - @include mdc-form-field.core-styles($query: mdc-helpers.$mdc-theme-styles-query); |
24 |
| - } |
| 27 | + @if inspection.get-theme-version($theme) == 1 { |
| 28 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, color)); |
25 | 29 | }
|
26 |
| - |
27 |
| - .mat-mdc-radio-button { |
28 |
| - &.mat-primary { |
29 |
| - @include mdc-radio-theme.theme(tokens-mdc-radio.get-color-tokens($theme, primary)); |
30 |
| - @include token-utils.create-token-values(tokens-mat-radio.$prefix, |
31 |
| - tokens-mat-radio.get-color-tokens($theme, primary)); |
| 30 | + @else { |
| 31 | + @include mdc-helpers.using-mdc-theme($theme) { |
| 32 | + .mat-mdc-radio-button { |
| 33 | + @include mdc-form-field.core-styles($query: mdc-helpers.$mdc-theme-styles-query); |
| 34 | + } |
32 | 35 | }
|
33 | 36 |
|
34 |
| - &.mat-accent { |
35 |
| - @include mdc-radio-theme.theme(tokens-mdc-radio.get-color-tokens($theme)); |
36 |
| - @include token-utils.create-token-values(tokens-mat-radio.$prefix, |
37 |
| - tokens-mat-radio.get-color-tokens($theme)); |
38 |
| - } |
| 37 | + .mat-mdc-radio-button { |
| 38 | + &.mat-primary { |
| 39 | + @include mdc-radio-theme.theme(tokens-mdc-radio.get-color-tokens($theme, primary)); |
| 40 | + @include token-utils.create-token-values(tokens-mat-radio.$prefix, |
| 41 | + tokens-mat-radio.get-color-tokens($theme, primary)); |
| 42 | + } |
39 | 43 |
|
40 |
| - &.mat-warn { |
41 |
| - @include mdc-radio-theme.theme(tokens-mdc-radio.get-color-tokens($theme, warn)); |
42 |
| - @include token-utils.create-token-values(tokens-mat-radio.$prefix, |
43 |
| - tokens-mat-radio.get-color-tokens($theme, warn)); |
| 44 | + &.mat-accent { |
| 45 | + @include mdc-radio-theme.theme(tokens-mdc-radio.get-color-tokens($theme)); |
| 46 | + @include token-utils.create-token-values(tokens-mat-radio.$prefix, |
| 47 | + tokens-mat-radio.get-color-tokens($theme)); |
| 48 | + } |
| 49 | + |
| 50 | + &.mat-warn { |
| 51 | + @include mdc-radio-theme.theme(tokens-mdc-radio.get-color-tokens($theme, warn)); |
| 52 | + @include token-utils.create-token-values(tokens-mat-radio.$prefix, |
| 53 | + tokens-mat-radio.get-color-tokens($theme, warn)); |
| 54 | + } |
44 | 55 | }
|
45 | 56 | }
|
46 | 57 | }
|
47 | 58 |
|
48 | 59 | @mixin typography($theme) {
|
49 |
| - @include sass-utils.current-selector-or-root() { |
50 |
| - @include mdc-radio-theme.theme(tokens-mdc-radio.get-typography-tokens($theme)); |
| 60 | + @if inspection.get-theme-version($theme) == 1 { |
| 61 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, typography)); |
51 | 62 | }
|
| 63 | + @else { |
| 64 | + @include sass-utils.current-selector-or-root() { |
| 65 | + @include mdc-radio-theme.theme(tokens-mdc-radio.get-typography-tokens($theme)); |
| 66 | + } |
52 | 67 |
|
53 |
| - .mat-mdc-radio-button { |
54 |
| - @include mdc-helpers.using-mdc-typography($theme) { |
55 |
| - @include mdc-form-field.core-styles($query: mdc-helpers.$mdc-typography-styles-query); |
| 68 | + .mat-mdc-radio-button { |
| 69 | + @include mdc-helpers.using-mdc-typography($theme) { |
| 70 | + @include mdc-form-field.core-styles($query: mdc-helpers.$mdc-typography-styles-query); |
| 71 | + } |
56 | 72 | }
|
57 | 73 | }
|
58 | 74 | }
|
59 | 75 |
|
60 | 76 | @mixin density($theme) {
|
61 |
| - $density-scale: inspection.get-theme-density($theme); |
62 |
| - |
63 |
| - @include sass-utils.current-selector-or-root() { |
64 |
| - @include mdc-radio-theme.theme(tokens-mdc-radio.get-density-tokens($theme)); |
| 77 | + @if inspection.get-theme-version($theme) == 1 { |
| 78 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, density)); |
65 | 79 | }
|
| 80 | + @else { |
| 81 | + $density-scale: inspection.get-theme-density($theme); |
66 | 82 |
|
67 |
| - @include mdc-helpers.if-touch-targets-unsupported($density-scale) { |
68 |
| - .mat-mdc-radio-touch-target { |
69 |
| - display: none; |
| 83 | + @include sass-utils.current-selector-or-root() { |
| 84 | + @include mdc-radio-theme.theme(tokens-mdc-radio.get-density-tokens($theme)); |
| 85 | + } |
| 86 | + |
| 87 | + @include mdc-helpers.if-touch-targets-unsupported($density-scale) { |
| 88 | + .mat-mdc-radio-touch-target { |
| 89 | + display: none; |
| 90 | + } |
70 | 91 | }
|
71 | 92 | }
|
72 | 93 | }
|
73 | 94 |
|
74 | 95 | @mixin theme($theme) {
|
75 | 96 | @include theming.private-check-duplicate-theme-styles($theme, 'mat-radio') {
|
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); |
| 97 | + @if inspection.get-theme-version($theme) == 1 { |
| 98 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme)); |
82 | 99 | }
|
83 |
| - @if inspection.theme-has($theme, typography) { |
84 |
| - @include typography($theme); |
| 100 | + @else { |
| 101 | + @include base($theme); |
| 102 | + @if inspection.theme-has($theme, color) { |
| 103 | + @include color($theme); |
| 104 | + } |
| 105 | + @if inspection.theme-has($theme, density) { |
| 106 | + @include density($theme); |
| 107 | + } |
| 108 | + @if inspection.theme-has($theme, typography) { |
| 109 | + @include typography($theme); |
| 110 | + } |
85 | 111 | }
|
86 | 112 | }
|
87 | 113 | }
|
| 114 | + |
| 115 | +@mixin _theme-from-tokens($tokens) { |
| 116 | + @if ($tokens != ()) { |
| 117 | + @include mdc-radio-theme.theme(map.get($tokens, tokens-mdc-radio.$prefix)); |
| 118 | + @include token-utils.create-token-values( |
| 119 | + tokens-mat-radio.$prefix, map.get($tokens, tokens-mat-radio.$prefix)); |
| 120 | + } |
| 121 | +} |
0 commit comments