Skip to content

Commit 702ccbe

Browse files
authored
fix(material/button): align prefixes with MDC (#27936)
We were using the `button-filled` and `button-protected` prefixes for our tokens, likely because that's the naming that MDC is using in their filenames. This was incorrect, because MDC uses the `filled-button` and `protected-button` prefixes for the actual tokens. This will be problematic when start looking up tokens based on their names so this PR updates the prefixes to be in line with MDC.
1 parent f5895a3 commit 702ccbe

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed

src/material/button/_button-theme.scss

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
@use '../core/theming/theming';
1313
@use '../core/theming/inspection';
1414
@use '../core/typography/typography';
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+
@use '../core/tokens/m2/mdc/filled-button' as tokens-mdc-filled-button;
16+
@use '../core/tokens/m2/mdc/protected-button' as tokens-mdc-protected-button;
1717

1818
@function _on-color($theme, $palette) {
1919
$is-dark: inspection.get-theme-type($theme) == dark;
@@ -131,10 +131,10 @@
131131
$on-error: _on-color($theme, $error);
132132

133133
.mat-mdc-unelevated-button {
134-
$default-color-tokens: tokens-mdc-button-filled.get-color-tokens($theme, $surface, $on-surface);
135-
$primary-color-tokens: tokens-mdc-button-filled.get-color-tokens($theme, $primary, $on-primary);
136-
$accent-color-tokens: tokens-mdc-button-filled.get-color-tokens($theme, $accent, $on-accent);
137-
$warn-color-tokens: tokens-mdc-button-filled.get-color-tokens($theme, $error, $on-error);
134+
$default-color-tokens: tokens-mdc-filled-button.get-color-tokens($theme, $surface, $on-surface);
135+
$primary-color-tokens: tokens-mdc-filled-button.get-color-tokens($theme, $primary, $on-primary);
136+
$accent-color-tokens: tokens-mdc-filled-button.get-color-tokens($theme, $accent, $on-accent);
137+
$warn-color-tokens: tokens-mdc-filled-button.get-color-tokens($theme, $error, $on-error);
138138

139139
&.mat-unthemed {
140140
@include mdc-button-filled-theme.theme($default-color-tokens);
@@ -154,18 +154,18 @@
154154
}
155155

156156
.mat-mdc-raised-button {
157-
$default-color-tokens: tokens-mdc-button-protected.get-color-tokens(
157+
$default-color-tokens: tokens-mdc-protected-button.get-color-tokens(
158158
$theme,
159159
$surface,
160160
$on-surface
161161
);
162-
$primary-color-tokens: tokens-mdc-button-protected.get-color-tokens(
162+
$primary-color-tokens: tokens-mdc-protected-button.get-color-tokens(
163163
$theme,
164164
$primary,
165165
$on-primary
166166
);
167-
$accent-color-tokens: tokens-mdc-button-protected.get-color-tokens($theme, $accent, $on-accent);
168-
$warn-color-tokens: tokens-mdc-button-protected.get-color-tokens($theme, $error, $on-error);
167+
$accent-color-tokens: tokens-mdc-protected-button.get-color-tokens($theme, $accent, $on-accent);
168+
$warn-color-tokens: tokens-mdc-protected-button.get-color-tokens($theme, $error, $on-error);
169169

170170
&.mat-unthemed {
171171
@include mdc-button-protected-theme.theme($default-color-tokens);
@@ -235,13 +235,13 @@
235235
$density-scale: theming.clamp-density(inspection.get-theme-density($theme), -3);
236236

237237
.mat-mdc-raised-button {
238-
$density-tokens: tokens-mdc-button-protected.get-density-tokens($theme);
238+
$density-tokens: tokens-mdc-protected-button.get-density-tokens($theme);
239239
@include mdc-button-protected-theme.theme($density-tokens);
240240
@include button-theme-private.touch-target-density($density-scale);
241241
}
242242

243243
.mat-mdc-unelevated-button {
244-
$density-tokens: tokens-mdc-button-filled.get-density-tokens($theme);
244+
$density-tokens: tokens-mdc-filled-button.get-density-tokens($theme);
245245
@include mdc-button-filled-theme.theme($density-tokens);
246246
@include button-theme-private.touch-target-density($density-scale);
247247
}

src/material/button/button.scss

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
@use '../core/mdc-helpers/mdc-helpers';
1313
@use '../core/style/private' as style-private;
1414
@use '../core/focus-indicators/private' as focus-indicators-private;
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+
@use '../core/tokens/m2/mdc/filled-button' as tokens-mdc-filled-button;
16+
@use '../core/tokens/m2/mdc/protected-button' as tokens-mdc-protected-button;
1717

1818
@include mdc-helpers.disable-mdc-fallback-declarations {
1919
@include mdc-button.static-styles-without-ripple($query: mdc-helpers.$mdc-base-styles-query);
@@ -46,25 +46,25 @@
4646
// Note that we don't include a feature query, because this mixins declare
4747
// all the "slots" for CSS variables that will be defined in the theme.
4848
.mat-mdc-unelevated-button {
49-
$mdc-button-filled-slots: tokens-mdc-button-filled.get-token-slots();
49+
$mdc-filled-button-slots: tokens-mdc-filled-button.get-token-slots();
5050

5151
// Add the slots for MDC text button.
52-
@include mdc-button-filled-theme.theme-styles($mdc-button-filled-slots);
52+
@include mdc-button-filled-theme.theme-styles($mdc-filled-button-slots);
5353

5454
// Add default values for MDC text button tokens that aren't outputted by the theming API.
55-
@include mdc-button-filled-theme.theme(tokens-mdc-button-filled.get-unthemable-tokens());
55+
@include mdc-button-filled-theme.theme(tokens-mdc-filled-button.get-unthemable-tokens());
5656
}
5757

5858
// Note that we don't include a feature query, because this mixins declare
5959
// all the "slots" for CSS variables that will be defined in the theme.
6060
.mat-mdc-raised-button {
61-
$mdc-button-protected-slots: tokens-mdc-button-protected.get-token-slots();
61+
$mdc-button-protected-slots: tokens-mdc-protected-button.get-token-slots();
6262

6363
// Add the slots for MDC text button.
6464
@include mdc-button-protected-theme.theme-styles($mdc-button-protected-slots);
6565

6666
// Add default values for MDC text button tokens that aren't outputted by the theming API.
67-
@include mdc-button-protected-theme.theme(tokens-mdc-button-protected.get-unthemable-tokens());
67+
@include mdc-button-protected-theme.theme(tokens-mdc-protected-button.get-unthemable-tokens());
6868
}
6969
}
7070

src/material/core/tokens/m2/mdc/_button-filled.scss renamed to src/material/core/tokens/m2/mdc/_filled-button.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@use '../../../theming/theming';
77

88
// The prefix used to generate the fully qualified name for tokens in this file.
9-
$prefix: (mdc, button-filled);
9+
$prefix: (mdc, filled-button);
1010

1111
// Tokens that can't be configured through Angular Material's current theming API,
1212
// but may be in a future version of the theming API.

src/material/core/tokens/m2/mdc/_button-protected.scss renamed to src/material/core/tokens/m2/mdc/_protected-button.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@use '../../../theming/theming';
77

88
// The prefix used to generate the fully qualified name for tokens in this file.
9-
$prefix: (mdc, button-protected);
9+
$prefix: (mdc, protected-button);
1010

1111
// Tokens that can't be configured through Angular Material's current theming API,
1212
// but may be in a future version of the theming API.

src/material/core/tokens/tests/test-validate-tokens.scss

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
@use '@material/textfield/outlined-text-field-theme' as mdc-outlined-text-field-theme;
2626
@use '@material/theme/validate' as mdc-validate;
2727

28-
@use '../m2/mdc/button-protected' as tokens-mdc-button-protected;
29-
@use '../m2/mdc/button-filled' as tokens-mdc-button-filled;
28+
@use '../m2/mdc/protected-button' as tokens-mdc-protected-button;
29+
@use '../m2/mdc/filled-button' as tokens-mdc-filled-button;
3030
@use '../m2/mdc/circular-progress' as tokens-mdc-circular-progress;
3131
@use '../m2/mdc/linear-progress' as tokens-mdc-linear-progress;
3232
@use '../m2/mdc/elevated-card' as tokens-mdc-elevated-card;
@@ -161,12 +161,12 @@
161161
$reference: mdc-outlined-text-field-theme.$light-theme
162162
);
163163
@include validate-slots(
164-
$component: 'm2.mdc.button-filled',
165-
$slots: tokens-mdc-button-filled.get-token-slots(),
164+
$component: 'm2.mdc.filled-button',
165+
$slots: tokens-mdc-filled-button.get-token-slots(),
166166
$reference: mdc-button-filled-theme.$light-theme
167167
);
168168
@include validate-slots(
169-
$component: 'm2.mdc.button-protected',
170-
$slots: tokens-mdc-button-protected.get-token-slots(),
169+
$component: 'm2.mdc.protected-button',
170+
$slots: tokens-mdc-protected-button.get-token-slots(),
171171
$reference: mdc-button-protected-theme.$light-theme
172172
);

0 commit comments

Comments
 (0)