|
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 | 7 | @use '@material/theme/theme-color' as mdc-theme-color;
|
| 8 | +@use '@material/elevation/elevation-theme' as mdc-elevation-theme; |
8 | 9 |
|
9 | 10 | @use './button-theme-private';
|
10 | 11 | @use '../core/mdc-helpers/mdc-helpers';
|
11 | 12 | @use '../core/theming/theming';
|
12 | 13 | @use '../core/theming/inspection';
|
13 | 14 | @use '../core/typography/typography';
|
14 | 15 | @use '../core/tokens/m2/mdc/button-filled' as tokens-mdc-button-filled;
|
| 16 | +@use '../core/tokens/m2/mdc/button-protected' as tokens-mdc-button-protected; |
15 | 17 |
|
16 |
| -@function on-color($theme, $palette) { |
| 18 | +@function _on-color($theme, $palette) { |
17 | 19 | $is-dark: inspection.get-theme-type($theme) == dark;
|
18 | 20 | @return if(mdc-helpers.variable-safe-contrast-tone($palette, $is-dark) == 'dark', #000, #fff);
|
19 | 21 | }
|
|
24 | 26 | ));
|
25 | 27 | }
|
26 | 28 |
|
27 |
| -@mixin _raised-button-variant($foreground, $background) { |
28 |
| - @include mdc-button-protected-theme.theme(( |
29 |
| - container-color: $background, |
30 |
| - label-text-color: $foreground, |
31 |
| - )); |
32 |
| -} |
33 |
| - |
34 | 29 | @mixin _outlined-button-variant($color) {
|
35 | 30 | @include mdc-button-outlined-theme.theme((
|
36 | 31 | label-text-color: $color,
|
|
78 | 73 | }
|
79 | 74 | }
|
80 | 75 |
|
81 |
| - .mat-mdc-raised-button { |
82 |
| - &.mat-unthemed { |
83 |
| - @include _raised-button-variant($on-surface, $surface); |
84 |
| - } |
85 |
| - |
86 |
| - &.mat-primary { |
87 |
| - @include _raised-button-variant($on-primary, $primary); |
88 |
| - } |
89 |
| - |
90 |
| - &.mat-accent { |
91 |
| - @include _raised-button-variant($on-secondary, $secondary); |
92 |
| - } |
93 |
| - |
94 |
| - &.mat-warn { |
95 |
| - @include _raised-button-variant($on-error, $error); |
96 |
| - } |
97 |
| - |
98 |
| - @include button-theme-private.apply-disabled-style() { |
99 |
| - @include mdc-button-protected-theme.theme(( |
100 |
| - // We need to pass both the disabled and enabled values, because the enabled |
101 |
| - // ones apply to anchors while the disabled ones are for buttons. |
102 |
| - disabled-container-color: $disabled-container-color, |
103 |
| - disabled-label-text-color: $disabled-ink-color, |
104 |
| - container-color: $disabled-container-color, |
105 |
| - label-text-color: $disabled-ink-color, |
106 |
| - container-elevation: 0, |
107 |
| - )); |
108 |
| - } |
109 |
| - } |
110 |
| - |
111 | 76 | .mat-mdc-outlined-button {
|
112 | 77 | @include mdc-button-outlined-theme.theme((
|
113 | 78 | outline-color: rgba(mdc-theme-color.prop-value(on-surface), 0.12)
|
|
151 | 116 | }
|
152 | 117 | }
|
153 | 118 |
|
154 |
| - .mat-mdc-unelevated-button { |
155 |
| - $surface: inspection.get-theme-color($theme, background, card); |
156 |
| - $primary: inspection.get-theme-color($theme, primary); |
157 |
| - $accent: inspection.get-theme-color($theme, accent); |
158 |
| - $error: inspection.get-theme-color($theme, warn); |
| 119 | + $surface: inspection.get-theme-color($theme, background, card); |
| 120 | + $primary: inspection.get-theme-color($theme, primary); |
| 121 | + $accent: inspection.get-theme-color($theme, accent); |
| 122 | + $error: inspection.get-theme-color($theme, warn); |
159 | 123 |
|
160 |
| - $on-surface: on-color($theme, $surface); |
161 |
| - $on-primary: on-color($theme, $primary); |
162 |
| - $on-accent: on-color($theme, $accent); |
163 |
| - $on-error: on-color($theme, $error); |
| 124 | + $on-surface: _on-color($theme, $surface); |
| 125 | + $on-primary: _on-color($theme, $primary); |
| 126 | + $on-accent: _on-color($theme, $accent); |
| 127 | + $on-error: _on-color($theme, $error); |
164 | 128 |
|
| 129 | + .mat-mdc-unelevated-button { |
165 | 130 | $default-color-tokens: tokens-mdc-button-filled.get-color-tokens($theme, $surface, $on-surface);
|
166 | 131 | $primary-color-tokens: tokens-mdc-button-filled.get-color-tokens($theme, $primary, $on-primary);
|
167 | 132 | $accent-color-tokens: tokens-mdc-button-filled.get-color-tokens($theme, $accent, $on-accent);
|
|
182 | 147 | &.mat-warn {
|
183 | 148 | @include mdc-button-filled-theme.theme($warn-color-tokens);
|
184 | 149 | }
|
| 150 | + } |
| 151 | + |
| 152 | + .mat-mdc-raised-button { |
| 153 | + $default-color-tokens: tokens-mdc-button-protected.get-color-tokens( |
| 154 | + $theme, |
| 155 | + $surface, |
| 156 | + $on-surface |
| 157 | + ); |
| 158 | + $primary-color-tokens: tokens-mdc-button-filled.get-color-tokens($theme, $primary, $on-primary); |
| 159 | + $accent-color-tokens: tokens-mdc-button-filled.get-color-tokens($theme, $accent, $on-accent); |
| 160 | + $warn-color-tokens: tokens-mdc-button-filled.get-color-tokens($theme, $error, $on-error); |
185 | 161 |
|
| 162 | + &.mat-unthemed { |
| 163 | + @include mdc-button-protected-theme.theme($default-color-tokens); |
| 164 | + } |
| 165 | + |
| 166 | + &.mat-primary { |
| 167 | + @include mdc-button-protected-theme.theme($primary-color-tokens); |
| 168 | + } |
| 169 | + |
| 170 | + &.mat-accent { |
| 171 | + @include mdc-button-protected-theme.theme($accent-color-tokens); |
| 172 | + } |
| 173 | + |
| 174 | + &.mat-warn { |
| 175 | + @include mdc-button-protected-theme.theme($warn-color-tokens); |
| 176 | + } |
| 177 | + |
| 178 | + // TODO(wagnermaciel): Remove this workaround when b/301126527 is resolved |
| 179 | + @include mdc-helpers.disable-mdc-fallback-declarations { |
| 180 | + @include mdc-elevation-theme.elevation(2); |
| 181 | + |
| 182 | + &:hover, &:focus { |
| 183 | + @include mdc-elevation-theme.elevation(4); |
| 184 | + } |
| 185 | + |
| 186 | + &:active, &:focus:active { |
| 187 | + @include mdc-elevation-theme.elevation(8); |
| 188 | + } |
| 189 | + } |
| 190 | + } |
| 191 | + |
| 192 | + $is-dark: inspection.get-theme-type($theme) == dark; |
| 193 | + $disabled-ink-color: rgba($on-surface, if($is-dark, 0.5, 0.38)); |
| 194 | + $disabled-container-color: rgba($on-surface, 0.12); |
| 195 | + |
| 196 | + .mat-mdc-raised-button { |
186 | 197 | @include button-theme-private.apply-disabled-style() {
|
187 |
| - $is-dark: inspection.get-theme-type($theme) == dark; |
188 |
| - $disabled-ink-color: rgba($on-surface, if($is-dark, 0.5, 0.38)); |
189 |
| - $disabled-container-color: rgba($on-surface, 0.12); |
| 198 | + @include mdc-elevation-theme.elevation(0); |
| 199 | + @include mdc-button-protected-theme.theme(( |
| 200 | + disabled-container-color: $disabled-container-color, |
| 201 | + disabled-label-text-color: $disabled-ink-color, |
| 202 | + container-color: $disabled-container-color, |
| 203 | + label-text-color: $disabled-ink-color, |
| 204 | + )); |
| 205 | + } |
| 206 | + } |
190 | 207 |
|
| 208 | + .mat-mdc-unelevated-button { |
| 209 | + @include button-theme-private.apply-disabled-style() { |
191 | 210 | @include mdc-button-filled-theme.theme((
|
192 | 211 | disabled-container-color: $disabled-container-color,
|
193 | 212 | disabled-label-text-color: $disabled-ink-color,
|
|
0 commit comments