|
4 | 4 | @use '@material/button/button-filled-theme' as mdc-button-filled-theme;
|
5 | 5 | @use '@material/button/button-protected-theme' as mdc-button-protected-theme;
|
6 | 6 | @use '@material/button/button-outlined-theme' as mdc-button-outlined-theme;
|
7 |
| -@use '@material/theme/theme-color' as mdc-theme-color; |
8 | 7 | @use '@material/elevation/elevation-theme' as mdc-elevation-theme;
|
9 | 8 |
|
10 | 9 | @use './button-theme-private';
|
|
13 | 12 | @use '../core/theming/inspection';
|
14 | 13 | @use '../core/typography/typography';
|
15 | 14 | @use '../core/tokens/m2/mdc/filled-button' as tokens-mdc-filled-button;
|
| 15 | +@use '../core/tokens/m2/mdc/outlined-button' as tokens-mdc-outlined-button; |
16 | 16 | @use '../core/tokens/m2/mdc/protected-button' as tokens-mdc-protected-button;
|
17 | 17 | @use '../core/tokens/m2/mdc/text-button' as tokens-mdc-text-button;
|
18 | 18 |
|
|
21 | 21 | @return if(mdc-helpers.variable-safe-contrast-tone($palette, $is-dark) == 'dark', #000, #fff);
|
22 | 22 | }
|
23 | 23 |
|
24 |
| -@mixin _outlined-button-variant($color) { |
25 |
| - @include mdc-button-outlined-theme.theme(( |
26 |
| - label-text-color: $color, |
27 |
| - )); |
28 |
| -} |
29 |
| - |
30 | 24 | @mixin base($theme) {
|
31 | 25 | // TODO(mmalerba): Move button base tokens here
|
32 | 26 | }
|
33 | 27 |
|
34 | 28 | @mixin color($theme) {
|
35 |
| - @include mdc-helpers.using-mdc-theme($theme) { |
36 |
| - $is-dark: inspection.get-theme-type($theme) == dark; |
37 |
| - $on-surface: mdc-theme-color.prop-value(on-surface); |
38 |
| - $disabled-ink-color: rgba($on-surface, if($is-dark, 0.5, 0.38)); |
39 |
| - $primary: mdc-theme-color.prop-value(primary); |
40 |
| - $secondary: mdc-theme-color.prop-value(secondary); |
41 |
| - $error: mdc-theme-color.prop-value(error); |
42 |
| - |
43 |
| - .mat-mdc-outlined-button { |
44 |
| - @include mdc-button-outlined-theme.theme(( |
45 |
| - outline-color: rgba(mdc-theme-color.prop-value(on-surface), 0.12) |
46 |
| - )); |
47 |
| - |
48 |
| - &.mat-unthemed { |
49 |
| - @include _outlined-button-variant($on-surface); |
50 |
| - } |
51 |
| - |
52 |
| - &.mat-primary { |
53 |
| - @include _outlined-button-variant($primary); |
54 |
| - } |
55 |
| - |
56 |
| - &.mat-accent { |
57 |
| - @include _outlined-button-variant($secondary); |
58 |
| - } |
59 |
| - |
60 |
| - &.mat-warn { |
61 |
| - @include _outlined-button-variant($error); |
62 |
| - } |
| 29 | + $surface: inspection.get-theme-color($theme, background, card); |
| 30 | + $primary: inspection.get-theme-color($theme, primary); |
| 31 | + $accent: inspection.get-theme-color($theme, accent); |
| 32 | + $error: inspection.get-theme-color($theme, warn); |
63 | 33 |
|
64 |
| - @include button-theme-private.apply-disabled-style() { |
65 |
| - @include mdc-button-outlined-theme.theme(( |
66 |
| - // We need to pass both the disabled and enabled values, because the enabled |
67 |
| - // ones apply to anchors while the disabled ones are for buttons. |
68 |
| - label-text-color: $disabled-ink-color, |
69 |
| - disabled-label-text-color: $disabled-ink-color, |
70 |
| - outline-color: rgba($on-surface, 0.12), |
71 |
| - disabled-outline-color: rgba($on-surface, 0.12), |
72 |
| - )); |
73 |
| - } |
74 |
| - } |
| 34 | + $on-surface: _on-color($theme, $surface); |
| 35 | + $on-primary: _on-color($theme, $primary); |
| 36 | + $on-accent: _on-color($theme, $accent); |
| 37 | + $on-error: _on-color($theme, $error); |
75 | 38 |
|
| 39 | + // TODO: remove these when tokenizing the ripples. |
| 40 | + @include mdc-helpers.using-mdc-theme($theme) { |
76 | 41 | // Ripple colors
|
77 | 42 | .mat-mdc-button, .mat-mdc-outlined-button {
|
78 | 43 | @include button-theme-private.ripple-theme-styles($theme, false);
|
|
83 | 48 | }
|
84 | 49 | }
|
85 | 50 |
|
86 |
| - $surface: inspection.get-theme-color($theme, background, card); |
87 |
| - $primary: inspection.get-theme-color($theme, primary); |
88 |
| - $accent: inspection.get-theme-color($theme, accent); |
89 |
| - $error: inspection.get-theme-color($theme, warn); |
90 |
| - |
91 |
| - $on-surface: _on-color($theme, $surface); |
92 |
| - $on-primary: _on-color($theme, $primary); |
93 |
| - $on-accent: _on-color($theme, $accent); |
94 |
| - $on-error: _on-color($theme, $error); |
95 |
| - |
96 | 51 | .mat-mdc-button {
|
97 | 52 | @include mdc-button-text-theme.theme(tokens-mdc-text-button.get-color-tokens($theme));
|
98 | 53 |
|
|
179 | 134 | }
|
180 | 135 | }
|
181 | 136 |
|
182 |
| - $is-dark: inspection.get-theme-type($theme) == dark; |
183 |
| - $disabled-ink-color: rgba($on-surface, if($is-dark, 0.5, 0.38)); |
184 |
| - $disabled-container-color: rgba($on-surface, 0.12); |
| 137 | + .mat-mdc-outlined-button { |
| 138 | + $default-color-tokens: tokens-mdc-outlined-button.get-color-tokens( |
| 139 | + $theme, |
| 140 | + $on-surface, |
| 141 | + $on-surface |
| 142 | + ); |
| 143 | + $primary-color-tokens: tokens-mdc-outlined-button.get-color-tokens( |
| 144 | + $theme, |
| 145 | + $primary, |
| 146 | + $on-primary |
| 147 | + ); |
| 148 | + $accent-color-tokens: tokens-mdc-outlined-button.get-color-tokens($theme, $accent, $on-accent); |
| 149 | + $warn-color-tokens: tokens-mdc-outlined-button.get-color-tokens($theme, $error, $on-error); |
185 | 150 |
|
186 |
| - // TODO: these disabled styles are a bit too specific currently. |
187 |
| - // Once the buttons are fully tokenized, we should rework how they're applied. |
188 |
| - .mat-mdc-button { |
189 |
| - @include button-theme-private.apply-disabled-style() { |
190 |
| - @include mdc-button-text-theme.theme(( |
191 |
| - disabled-label-text-color: $disabled-ink-color, |
192 |
| - label-text-color: $disabled-ink-color, |
193 |
| - )); |
| 151 | + &.mat-unthemed { |
| 152 | + @include mdc-button-outlined-theme.theme($default-color-tokens); |
194 | 153 | }
|
195 |
| - } |
196 | 154 |
|
197 |
| - .mat-mdc-raised-button { |
198 |
| - @include button-theme-private.apply-disabled-style() { |
199 |
| - @include mdc-elevation-theme.elevation(0); |
200 |
| - @include mdc-button-protected-theme.theme(( |
201 |
| - disabled-container-color: $disabled-container-color, |
202 |
| - disabled-label-text-color: $disabled-ink-color, |
203 |
| - container-color: $disabled-container-color, |
204 |
| - label-text-color: $disabled-ink-color, |
205 |
| - )); |
| 155 | + &.mat-primary { |
| 156 | + @include mdc-button-outlined-theme.theme($primary-color-tokens); |
206 | 157 | }
|
207 |
| - } |
208 | 158 |
|
209 |
| - .mat-mdc-unelevated-button { |
210 |
| - @include button-theme-private.apply-disabled-style() { |
211 |
| - @include mdc-button-filled-theme.theme(( |
212 |
| - disabled-container-color: $disabled-container-color, |
213 |
| - disabled-label-text-color: $disabled-ink-color, |
214 |
| - container-color: $disabled-container-color, |
215 |
| - label-text-color: $disabled-ink-color, |
216 |
| - )); |
| 159 | + &.mat-accent { |
| 160 | + @include mdc-button-outlined-theme.theme($accent-color-tokens); |
| 161 | + } |
| 162 | + |
| 163 | + &.mat-warn { |
| 164 | + @include mdc-button-outlined-theme.theme($warn-color-tokens); |
217 | 165 | }
|
218 | 166 | }
|
219 | 167 | }
|
|
0 commit comments