Skip to content

Commit 901a5cb

Browse files
asynclizcopybara-github
authored andcommitted
chore(elevation): move private custom properties off of host
Elevation doesn't have variant styles, but it still uses shorter private custom properties to reduce its CSS size. I added a comment explaining why and moved the custom properties into the inner shadow dom so they can't be set on the host. No size changes. PiperOrigin-RevId: 601128500
1 parent 044ee51 commit 901a5cb

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

elevation/internal/_elevation.scss

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@
2727

2828
@mixin styles() {
2929
$tokens: tokens.md-comp-elevation-values();
30+
@each $token, $value in $tokens {
31+
$tokens: map.set($tokens, $token, var(--md-elevation-#{$token}, #{$value}));
32+
}
3033

3134
:host {
32-
@each $token, $value in $tokens {
33-
--_#{$token}: var(--md-elevation-#{$token}, #{$value});
34-
}
35-
3635
display: flex;
3736
pointer-events: none;
3837
}
@@ -53,6 +52,13 @@
5352
.shadow::after {
5453
content: '';
5554
transition-property: box-shadow, opacity;
55+
56+
// Elevation doesn't share styles with multiple variants, so we normally
57+
// would not use private custom properties. However, these variables are
58+
// repeated several times in the styles below, and a shorter custom property
59+
// reduces the CSS size, minified and gzip.
60+
--_level: #{map.get($tokens, 'level')};
61+
--_shadow-color: #{map.get($tokens, 'shadow-color')};
5662
}
5763

5864
// Key box shadow

0 commit comments

Comments
 (0)