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