Skip to content

Commit 208fab2

Browse files
authored
fix(material/button-toggle): Add remaining typography tokens needed for M3 (#28578)
1 parent b26fe35 commit 208fab2

File tree

4 files changed

+24
-15
lines changed

4 files changed

+24
-15
lines changed

src/material-experimental/theming/_custom-tokens.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,10 @@
134134
/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values
135135
/// @return {Map} A set of custom tokens for the mat-button-toggle
136136
@function button-toggle($systems, $exclude-hardcoded) {
137-
@return ((
138-
shape: _hardcode(9999px, $exclude-hardcoded),
137+
@return mat.private-merge-all(
138+
_generate-typography-tokens($systems, label-text, label-large),
139+
(
140+
shape: map.get($systems, md-sys-shape, corner-full),
139141
hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity),
140142
focus-state-layer-opacity: map.get($systems, md-sys-state, focus-state-layer-opacity),
141143
text-color: map.get($systems, md-sys-color, on-surface),
@@ -157,7 +159,6 @@
157159
$alpha: 0.12,
158160
),
159161
divider-color: map.get($systems, md-sys-color, outline),
160-
text-font: map.get($systems, md-sys-typescale, label-large-font),
161162
), (
162163
// Color variants:
163164
primary: (

src/material/button-toggle/button-toggle.scss

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ $_standard-tokens: (
7979

8080
@include token-utils.use-tokens($_legacy-tokens...) {
8181
@include token-utils.create-token-slot(color, text-color);
82-
@include token-utils.create-token-slot(font-family, text-font);
82+
@include token-utils.create-token-slot(font-family, label-text-font);
83+
@include token-utils.create-token-slot(font-size, label-text-size);
84+
@include token-utils.create-token-slot(line-height, label-text-line-height);
85+
@include token-utils.create-token-slot(font-weight, label-text-weight);
86+
@include token-utils.create-token-slot(letter-spacing, label-text-tracking);
8387

8488
&.cdk-keyboard-focused .mat-button-toggle-focus-overlay {
8589
@include token-utils.create-token-slot(opacity, focus-state-layer-opacity);
@@ -116,7 +120,11 @@ $_standard-tokens: (
116120
$divider-color: var(#{token-utils.get-token-variable(divider-color)});
117121
@include token-utils.create-token-slot(color, text-color);
118122
@include token-utils.create-token-slot(background-color, background-color);
119-
@include token-utils.create-token-slot(font-family, text-font);
123+
@include token-utils.create-token-slot(font-family, label-text-font);
124+
@include token-utils.create-token-slot(font-size, label-text-size);
125+
@include token-utils.create-token-slot(line-height, label-text-line-height);
126+
@include token-utils.create-token-slot(font-weight, label-text-weight);
127+
@include token-utils.create-token-slot(letter-spacing, label-text-tracking);
120128

121129
.mat-button-toggle-group-appearance-standard & + & {
122130
border-left: solid 1px $divider-color;

src/material/core/tokens/m2/mat/_legacy-button-toggle.scss

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ $prefix: (mat, legacy-button-toggle);
3434
// Tokens that can be configured through Angular Material's typography theming API.
3535
@function get-typography-tokens($theme) {
3636
@return (
37-
// TODO(crisbeto): other components have tokens for all typography dimensions (font weight,
38-
// letter spacing etc). The button toggle only has the font to match what it had in the
39-
// old theming API and to reduce internal breakages. We should introduce more typography
40-
// tokens at some point.
41-
text-font: inspection.get-theme-typography($theme, body-1, font-family),
37+
label-text-font: inspection.get-theme-typography($theme, body-1, font-family),
38+
label-text-line-height: inspection.get-theme-typography($theme, body-1, line-height),
39+
label-text-size: inspection.get-theme-typography($theme, body-1, font-size),
40+
label-text-tracking: inspection.get-theme-typography($theme, body-1, letter-spacing),
41+
label-text-weight: inspection.get-theme-typography($theme, body-1, font-weight),
4242
);
4343
}
4444

src/material/core/tokens/m2/mat/_standard-button-toggle.scss

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ $prefix: (mat, standard-button-toggle);
5252
// Tokens that can be configured through Angular Material's typography theming API.
5353
@function get-typography-tokens($theme) {
5454
@return (
55-
// TODO(crisbeto): other components have tokens for all typography dimensions (font weight,
56-
// letter spacing etc). The button toggle only has the font to match what it had in the
57-
// old theming API and to reduce internal breakages. We should introduce more typography
58-
// tokens at some point.
59-
text-font: inspection.get-theme-typography($theme, body-1, font-family),
55+
label-text-font: inspection.get-theme-typography($theme, body-1, font-family),
56+
label-text-line-height: inspection.get-theme-typography($theme, body-1, line-height),
57+
label-text-size: inspection.get-theme-typography($theme, body-1, font-size),
58+
label-text-tracking: inspection.get-theme-typography($theme, body-1, letter-spacing),
59+
label-text-weight: inspection.get-theme-typography($theme, body-1, font-weight),
6060
);
6161
}
6262

0 commit comments

Comments
 (0)