Skip to content

Commit 5ee7d79

Browse files
authored
fix(material/button): FAB emitting invalid elevation tokens (#31028)
The FAB was re-defining its elevation tokens for each variant, however the logic that converts elevation values from numbers to shadows was running only on the top-level tokens. At runtime this leads to no shadow being shown, because we were emitting a number. These changes remove the elevation overrides for the variants, because they're the same as the base.
1 parent e85c865 commit 5ee7d79

File tree

1 file changed

+4
-31
lines changed

1 file changed

+4
-31
lines changed

src/material/button/_m3-fab.scss

+4-31
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ $prefix: (mat, fab);
6565
);
6666

6767
$elevation-tokens: (
68+
container-elevation-shadow,
69+
focus-container-elevation-shadow,
70+
hover-container-elevation-shadow,
71+
pressed-container-elevation-shadow,
6872
extended-container-elevation-shadow,
6973
extended-focus-container-elevation-shadow,
7074
extended-hover-container-elevation-shadow,
@@ -88,32 +92,24 @@ $prefix: (mat, fab);
8892
primary: (), // Default, no overrides needed.
8993
secondary: (
9094
container-color: map.get($systems, md-sys-color, secondary-container),
91-
container-elevation-shadow: map.get($systems, md-sys-elevation, level3),
9295
container-shape: map.get($systems, md-sys-shape, corner-large),
9396
extended-container-height: if($exclude-hardcoded, null, 56px),
9497
extended-container-shape: map.get($systems, md-sys-shape, corner-large),
9598
extended-label-text-font: map.get($systems, md-sys-typescale, label-large-font),
9699
extended-label-text-size: map.get($systems, md-sys-typescale, label-large-size),
97100
extended-label-text-tracking: map.get($systems, md-sys-typescale, label-large-tracking),
98101
extended-label-text-weight: map.get($systems, md-sys-typescale, label-large-weight),
99-
focus-container-elevation-shadow: map.get($systems, md-sys-elevation, level3),
100102
focus-state-layer-opacity: map.get($systems, md-sys-state, focus-state-layer-opacity),
101103
foreground-color: map.get($systems, md-sys-color, on-secondary-container),
102-
hover-container-elevation-shadow: map.get($systems, md-sys-elevation, level4),
103104
hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity),
104-
pressed-container-elevation-shadow: map.get($systems, md-sys-elevation, level3),
105105
ripple-color: sass-utils.safe-color-change(
106106
map.get($systems, md-sys-color, on-secondary-container),
107107
$alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity)),
108108
small-container-color: map.get($systems, md-sys-color, secondary-container),
109-
small-container-elevation-shadow: map.get($systems, md-sys-elevation, level3),
110109
small-container-shape: map.get($systems, md-sys-shape, corner-medium),
111-
small-focus-container-elevation-shadow: map.get($systems, md-sys-elevation, level3),
112110
small-focus-state-layer-opacity: map.get($systems, md-sys-state, focus-state-layer-opacity),
113111
small-foreground-color: map.get($systems, md-sys-color, on-secondary-container),
114-
small-hover-container-elevation-shadow: map.get($systems, md-sys-elevation, level4),
115112
small-hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity),
116-
small-pressed-container-elevation-shadow: map.get($systems, md-sys-elevation, level3),
117113
small-pressed-state-layer-opacity:
118114
map.get($systems, md-sys-state, pressed-state-layer-opacity),
119115
small-ripple-color: sass-utils.safe-color-change(
@@ -124,32 +120,24 @@ $prefix: (mat, fab);
124120
),
125121
tertiary: (
126122
container-color: map.get($systems, md-sys-color, tertiary-container),
127-
container-elevation-shadow: map.get($systems, md-sys-elevation, level3),
128123
container-shape: map.get($systems, md-sys-shape, corner-large),
129124
extended-container-height: if($exclude-hardcoded, null, 56px),
130125
extended-container-shape: map.get($systems, md-sys-shape, corner-large),
131126
extended-label-text-font: map.get($systems, md-sys-typescale, label-large-font),
132127
extended-label-text-size: map.get($systems, md-sys-typescale, label-large-size),
133128
extended-label-text-tracking: map.get($systems, md-sys-typescale, label-large-tracking),
134129
extended-label-text-weight: map.get($systems, md-sys-typescale, label-large-weight),
135-
focus-container-elevation-shadow: map.get($systems, md-sys-elevation, level3),
136130
focus-state-layer-opacity: map.get($systems, md-sys-state, focus-state-layer-opacity),
137131
foreground-color: map.get($systems, md-sys-color, on-tertiary-container),
138-
hover-container-elevation-shadow: map.get($systems, md-sys-elevation, level4),
139132
hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity),
140-
pressed-container-elevation-shadow: map.get($systems, md-sys-elevation, level3),
141133
ripple-color: sass-utils.safe-color-change(
142134
map.get($systems, md-sys-color, on-tertiary-container),
143135
$alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity)),
144136
small-container-color: map.get($systems, md-sys-color, tertiary-container),
145-
small-container-elevation-shadow: map.get($systems, md-sys-elevation, level3),
146137
small-container-shape: map.get($systems, md-sys-shape, corner-medium),
147-
small-focus-container-elevation-shadow: map.get($systems, md-sys-elevation, level3),
148138
small-focus-state-layer-opacity: map.get($systems, md-sys-state, focus-state-layer-opacity),
149139
small-foreground-color: map.get($systems, md-sys-color, on-tertiary-container),
150-
small-hover-container-elevation-shadow: map.get($systems, md-sys-elevation, level4),
151140
small-hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity),
152-
small-pressed-container-elevation-shadow: map.get($systems, md-sys-elevation, level3),
153141
small-ripple-color: sass-utils.safe-color-change(
154142
map.get($systems, md-sys-color, on-tertiary-container),
155143
$alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity)),
@@ -158,21 +146,6 @@ $prefix: (mat, fab);
158146
)
159147
);
160148

161-
$elevation-tokens: (
162-
container-elevation-shadow,
163-
focus-container-elevation-shadow,
164-
hover-container-elevation-shadow,
165-
pressed-container-elevation-shadow,
166-
);
167-
168-
@each $token in $elevation-tokens {
169-
$elevation: map.get($tokens, $token);
170-
171-
@if ($elevation != null) {
172-
$tokens: map.set($tokens, $token, elevation.get-box-shadow($elevation));
173-
}
174-
}
175-
176149
@return m3-utils.namespace($prefix, ($tokens, $variant-tokens), $token-slots);
177150
}
178151

0 commit comments

Comments
 (0)