Skip to content

Commit b4fcae4

Browse files
authoredMar 16, 2025··
fix(material/core): include alternative tokens (#30633)
1 parent 75713b0 commit b4fcae4

File tree

3 files changed

+76
-4
lines changed

3 files changed

+76
-4
lines changed
 

‎src/material/core/tokens/m3/definitions/_md-comp-elevated-card.scss

+12-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
@use './md-sys-state';
1515

16+
// Indicates whether alternative tokens should be used
17+
$_alternate-tokens: false;
18+
1619
$_default: (
1720
'md-sys-color': md-sys-color.values-light(),
1821
'md-sys-elevation': md-sys-elevation.values(),
@@ -21,7 +24,7 @@ $_default: (
2124
);
2225

2326
@function values($deps: $_default, $exclude-hardcoded-values: false) {
24-
@return (
27+
$values: (
2528
'container-color': map.get($deps, 'md-sys-color', 'surface-container-low'),
2629
'container-elevation': map.get($deps, 'md-sys-elevation', 'level1'),
2730
'container-shadow-color': map.get($deps, 'md-sys-color', 'shadow'),
@@ -50,4 +53,12 @@ $_default: (
5053
'pressed-state-layer-opacity':
5154
map.get($deps, 'md-sys-state', 'pressed-state-layer-opacity')
5255
);
56+
57+
@if ($_alternate-tokens) {
58+
$values: map.merge($values, (
59+
'container-color': map.get($deps, 'md-sys-color', 'surface'),
60+
));
61+
}
62+
63+
@return $values;
5364
}

‎src/material/core/tokens/m3/definitions/_md-sys-color.scss

+44-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77

88
@use './md-ref-palette';
99

10+
// Indicates whether alternative tokens should be used
11+
$_alternate-tokens: false;
12+
1013
$_default-dark: (
1114
'md-ref-palette': md-ref-palette.values(),
1215
);
1316

1417
@function values-dark($deps: $_default-dark) {
15-
@return (
18+
$values: (
1619
'background': map.get($deps, 'md-ref-palette', 'neutral6'),
1720
'error': map.get($deps, 'md-ref-palette', 'error80'),
1821
'error-container': map.get($deps, 'md-ref-palette', 'error30'),
@@ -64,14 +67,32 @@ $_default-dark: (
6467
'tertiary-fixed': map.get($deps, 'md-ref-palette', 'tertiary90'),
6568
'tertiary-fixed-dim': map.get($deps, 'md-ref-palette', 'tertiary80')
6669
);
70+
71+
@if ($_alternate-tokens) {
72+
$values: map.merge($values, (
73+
'background': map.get($deps, 'md-ref-palette', 'neutral10'),
74+
'on-surface-variant': map.get($deps, 'md-ref-palette', 'neutral-variant80'),
75+
'surface': map.get($deps, 'md-ref-palette', 'neutral10'),
76+
'surface-bright': #37393b,
77+
'surface-container': #1e1f20,
78+
'surface-container-high': #282a2c,
79+
'surface-container-highest': #333537,
80+
'surface-container-low': #1b1b1b,
81+
'surface-container-lowest': #0e0e0e,
82+
'surface-dim': #131313,
83+
'surface-tint': #d1e1ff,
84+
));
85+
}
86+
87+
@return $values;
6788
}
6889

6990
$_default-light: (
7091
'md-ref-palette': md-ref-palette.values(),
7192
);
7293

7394
@function values-light($deps: $_default-light) {
74-
@return (
95+
$values: (
7596
'background': map.get($deps, 'md-ref-palette', 'neutral98'),
7697
'error': map.get($deps, 'md-ref-palette', 'error40'),
7798
'error-container': map.get($deps, 'md-ref-palette', 'error90'),
@@ -123,4 +144,25 @@ $_default-light: (
123144
'tertiary-fixed': map.get($deps, 'md-ref-palette', 'tertiary90'),
124145
'tertiary-fixed-dim': map.get($deps, 'md-ref-palette', 'tertiary80')
125146
);
147+
148+
@if ($_alternate-tokens) {
149+
$values: map.merge($values, (
150+
'background': map.get($deps, 'md-ref-palette', 'neutral100'),
151+
'on-error-container': map.get($deps, 'md-ref-palette', 'error10'),
152+
'on-primary-container': map.get($deps, 'md-ref-palette', 'primary10'),
153+
'on-secondary-container': map.get($deps, 'md-ref-palette', 'secondary10'),
154+
'on-tertiary-container': map.get($deps, 'md-ref-palette', 'tertiary10'),
155+
'surface': map.get($deps, 'md-ref-palette', 'neutral100'),
156+
'surface-bright': map.get($deps, 'md-ref-palette', 'neutral100'),
157+
'surface-container': #f0f4f9,
158+
'surface-container-high': #e9eef6,
159+
'surface-container-highest': #dde3ea,
160+
'surface-container-low': #f8fafd,
161+
'surface-container-lowest': map.get($deps, 'md-ref-palette', 'primary100'),
162+
'surface-dim': #d3dbe5,
163+
'surface-tint': #6991d6,
164+
));
165+
}
166+
167+
@return $values;
126168
}

‎src/material/core/tokens/m3/definitions/_md-sys-typescale.scss

+20-1
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77

88
@use './md-ref-typeface';
99

10+
// Indicates whether alternative tokens should be used
11+
$_alternate-tokens: false;
12+
1013
$_default: (
1114
'md-ref-typeface': md-ref-typeface.values(),
1215
);
1316

1417
@function values($deps: $_default, $exclude-hardcoded-values: false) {
15-
@return (
18+
$values: (
1619
// Warning: risk of reduced fidelity from using this composite typography token.
1720
// Tokens md.sys.typescale.body-large.tracking cannot be represented in the "font"
1821
// property shorthand. Consider using the discrete properties instead.
@@ -305,4 +308,20 @@ $_default: (
305308
'title-small-tracking': if($exclude-hardcoded-values, null, 0.006rem),
306309
'title-small-weight': map.get($deps, 'md-ref-typeface', 'weight-medium')
307310
);
311+
312+
@if ($_alternate-tokens) {
313+
$values: map.merge($values, (
314+
'body-large-tracking': if($exclude-hardcoded-values, null, 0),
315+
'body-medium-tracking': if($exclude-hardcoded-values, null, 0),
316+
'body-small-tracking': if($exclude-hardcoded-values, null, 0.006rem),
317+
'display-large-tracking': if($exclude-hardcoded-values, null, 0),
318+
'label-large-tracking': if($exclude-hardcoded-values, null, 0),
319+
'label-medium-tracking': if($exclude-hardcoded-values, null, 0.006rem),
320+
'label-small-tracking': if($exclude-hardcoded-values, null, 0.006rem),
321+
'title-medium-tracking': if($exclude-hardcoded-values, null, 0),
322+
'title-small-tracking': if($exclude-hardcoded-values, null, 0),
323+
));
324+
}
325+
326+
@return $values;
308327
}

0 commit comments

Comments
 (0)
Please sign in to comment.