|
14 | 14 | @use '../core/typography/typography';
|
15 | 15 | @use '../core/tokens/m2/mdc/filled-button' as tokens-mdc-filled-button;
|
16 | 16 | @use '../core/tokens/m2/mdc/protected-button' as tokens-mdc-protected-button;
|
| 17 | +@use '../core/tokens/m2/mdc/text-button' as tokens-mdc-text-button; |
17 | 18 |
|
18 | 19 | @function _on-color($theme, $palette) {
|
19 | 20 | $is-dark: inspection.get-theme-type($theme) == dark;
|
20 | 21 | @return if(mdc-helpers.variable-safe-contrast-tone($palette, $is-dark) == 'dark', #000, #fff);
|
21 | 22 | }
|
22 | 23 |
|
23 |
| -@mixin _button-variant($color) { |
24 |
| - @include mdc-button-text-theme.theme(( |
25 |
| - label-text-color: $color, |
26 |
| - )); |
27 |
| -} |
28 |
| - |
29 | 24 | @mixin _outlined-button-variant($color) {
|
30 | 25 | @include mdc-button-outlined-theme.theme((
|
31 | 26 | label-text-color: $color,
|
|
40 | 35 | @include mdc-helpers.using-mdc-theme($theme) {
|
41 | 36 | $is-dark: inspection.get-theme-type($theme) == dark;
|
42 | 37 | $on-surface: mdc-theme-color.prop-value(on-surface);
|
43 |
| - $surface: mdc-theme-color.prop-value(surface); |
44 | 38 | $disabled-ink-color: rgba($on-surface, if($is-dark, 0.5, 0.38));
|
45 |
| - $disabled-container-color: rgba($on-surface, 0.12); |
46 | 39 | $primary: mdc-theme-color.prop-value(primary);
|
47 |
| - $on-primary: mdc-theme-color.prop-value(on-primary); |
48 | 40 | $secondary: mdc-theme-color.prop-value(secondary);
|
49 |
| - $on-secondary: mdc-theme-color.prop-value(on-secondary); |
50 | 41 | $error: mdc-theme-color.prop-value(error);
|
51 |
| - $on-error: mdc-theme-color.prop-value(on-error); |
52 |
| - |
53 |
| - .mat-mdc-button { |
54 |
| - &.mat-unthemed { |
55 |
| - @include _button-variant($on-surface); |
56 |
| - } |
57 |
| - |
58 |
| - &.mat-primary { |
59 |
| - @include _button-variant($primary); |
60 |
| - } |
61 |
| - |
62 |
| - &.mat-accent { |
63 |
| - @include _button-variant($secondary); |
64 |
| - } |
65 |
| - |
66 |
| - &.mat-warn { |
67 |
| - @include _button-variant($error); |
68 |
| - } |
69 |
| - |
70 |
| - @include button-theme-private.apply-disabled-style() { |
71 |
| - @include mdc-button-text-theme.theme(( |
72 |
| - // We need to pass both the disabled and enabled values, because the enabled |
73 |
| - // ones apply to anchors while the disabled ones are for buttons. |
74 |
| - disabled-label-text-color: $disabled-ink-color, |
75 |
| - label-text-color: $disabled-ink-color |
76 |
| - )); |
77 |
| - } |
78 |
| - } |
79 | 42 |
|
80 | 43 | .mat-mdc-outlined-button {
|
81 | 44 | @include mdc-button-outlined-theme.theme((
|
|
130 | 93 | $on-accent: _on-color($theme, $accent);
|
131 | 94 | $on-error: _on-color($theme, $error);
|
132 | 95 |
|
| 96 | + .mat-mdc-button { |
| 97 | + @include mdc-button-text-theme.theme(tokens-mdc-text-button.get-color-tokens($theme)); |
| 98 | + |
| 99 | + &.mat-primary { |
| 100 | + @include mdc-button-text-theme.theme( |
| 101 | + tokens-mdc-text-button.private-get-color-palette-color-tokens($theme, primary)); |
| 102 | + } |
| 103 | + |
| 104 | + &.mat-accent { |
| 105 | + @include mdc-button-text-theme.theme( |
| 106 | + tokens-mdc-text-button.private-get-color-palette-color-tokens($theme, accent)); |
| 107 | + } |
| 108 | + |
| 109 | + &.mat-warn { |
| 110 | + @include mdc-button-text-theme.theme( |
| 111 | + tokens-mdc-text-button.private-get-color-palette-color-tokens($theme, warn)); |
| 112 | + } |
| 113 | + } |
| 114 | + |
133 | 115 | .mat-mdc-unelevated-button {
|
134 | 116 | $default-color-tokens: tokens-mdc-filled-button.get-color-tokens($theme, $surface, $on-surface);
|
135 | 117 | $primary-color-tokens: tokens-mdc-filled-button.get-color-tokens($theme, $primary, $on-primary);
|
|
201 | 183 | $disabled-ink-color: rgba($on-surface, if($is-dark, 0.5, 0.38));
|
202 | 184 | $disabled-container-color: rgba($on-surface, 0.12);
|
203 | 185 |
|
| 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 | + )); |
| 194 | + } |
| 195 | + } |
| 196 | + |
204 | 197 | .mat-mdc-raised-button {
|
205 | 198 | @include button-theme-private.apply-disabled-style() {
|
206 | 199 | @include mdc-elevation-theme.elevation(0);
|
|
234 | 227 | @mixin density($theme) {
|
235 | 228 | $density-scale: theming.clamp-density(inspection.get-theme-density($theme), -3);
|
236 | 229 |
|
| 230 | + .mat-mdc-button { |
| 231 | + $density-tokens: tokens-mdc-text-button.get-density-tokens($theme); |
| 232 | + @include mdc-button-text-theme.theme($density-tokens); |
| 233 | + @include button-theme-private.touch-target-density($density-scale); |
| 234 | + |
| 235 | + // TODO(crisbeto): before the introduction of tokens, MDC's density mixin was adding |
| 236 | + // `margin-top: 0` and `margin-bottom: 0` in its `density` mixin which a lot of internal |
| 237 | + // clients came to depend upon. Preserve it to make tokens easier to land. |
| 238 | + @if ($density-scale < 0) { |
| 239 | + &.mat-mdc-button-base { |
| 240 | + margin-top: 0; |
| 241 | + margin-bottom: 0; |
| 242 | + } |
| 243 | + } |
| 244 | + } |
| 245 | + |
237 | 246 | .mat-mdc-raised-button {
|
238 | 247 | $density-tokens: tokens-mdc-protected-button.get-density-tokens($theme);
|
239 | 248 | @include mdc-button-protected-theme.theme($density-tokens);
|
|
246 | 255 | @include button-theme-private.touch-target-density($density-scale);
|
247 | 256 | }
|
248 | 257 |
|
249 |
| - .mat-mdc-button, |
250 | 258 | .mat-mdc-outlined-button {
|
251 | 259 | // Use `mat-mdc-button-base` to increase the specificity over the button's structural styles.
|
252 | 260 | &.mat-mdc-button-base {
|
|
0 commit comments