Skip to content

Commit 93071d4

Browse files
asynclizcopybara-github
authored andcommitted
refactor(dialog): reduce CSS size
Reduces the size by removing private (`--_*`) custom properties. These are not needed since the component does not share styles across variants. Size before: 4597b / 1322b gzip Size after: 4092b (-13%) / 1194b gzip (-10%) PiperOrigin-RevId: 600905310
1 parent 7f6dda5 commit 93071d4

File tree

1 file changed

+50
-42
lines changed

1 file changed

+50
-42
lines changed

dialog/internal/_dialog.scss

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -34,37 +34,45 @@
3434
}
3535

3636
@mixin styles() {
37-
$tokens: tokens.md-comp-dialog-values();
3837
$md-sys-color: tokens.md-sys-color-values-light();
3938
$md-sys-motion: tokens.md-sys-motion-values();
39+
$tokens: tokens.md-comp-dialog-values();
40+
@each $token, $value in $tokens {
41+
$tokens: map.set($tokens, $token, var(--md-dialog-#{$token}, #{$value}));
42+
}
4043

41-
:host {
42-
@each $token, $value in $tokens {
43-
--_#{$token}: var(--md-dialog-#{$token}, #{$value});
44-
}
44+
// Support logical shape properties
45+
$tokens: map.merge(
46+
$tokens,
47+
(
48+
'container-shape-start-start':
49+
var(
50+
--md-dialog-container-shape-start-start,
51+
map.get($tokens, 'container-shape')
52+
),
53+
'container-shape-start-end':
54+
var(
55+
--md-dialog-container-shape-start-end,
56+
map.get($tokens, 'container-shape')
57+
),
58+
'container-shape-end-end':
59+
var(
60+
--md-dialog-container-shape-end-end,
61+
map.get($tokens, 'container-shape')
62+
),
63+
'container-shape-end-start':
64+
var(
65+
--md-dialog-container-shape-end-start,
66+
map.get($tokens, 'container-shape')
67+
),
68+
)
69+
);
4570

46-
// Support logical shape properties
47-
--_container-shape-start-start: var(
48-
--md-dialog-container-shape-start-start,
49-
var(--_container-shape)
50-
);
51-
--_container-shape-start-end: var(
52-
--md-dialog-container-shape-start-end,
53-
var(--_container-shape)
54-
);
55-
--_container-shape-end-end: var(
56-
--md-dialog-container-shape-end-end,
57-
var(--_container-shape)
58-
);
59-
--_container-shape-end-start: var(
60-
--md-dialog-container-shape-end-start,
61-
var(--_container-shape)
62-
);
63-
64-
border-start-start-radius: var(--_container-shape-start-start);
65-
border-start-end-radius: var(--_container-shape-start-end);
66-
border-end-end-radius: var(--_container-shape-end-end);
67-
border-end-start-radius: var(--_container-shape-end-start);
71+
:host {
72+
border-start-start-radius: map.get($tokens, 'container-shape-start-start');
73+
border-start-end-radius: map.get($tokens, 'container-shape-start-end');
74+
border-end-end-radius: map.get($tokens, 'container-shape-end-end');
75+
border-end-start-radius: map.get($tokens, 'container-shape-end-start');
6876
display: contents;
6977
margin: auto;
7078
max-height: min(560px, calc(100% - 48px));
@@ -123,13 +131,13 @@
123131

124132
.headline {
125133
align-items: center;
126-
color: var(--_headline-color);
134+
color: map.get($tokens, 'headline-color');
127135
display: flex;
128136
flex-direction: column;
129-
font-family: var(--_headline-font);
130-
font-size: var(--_headline-size);
131-
line-height: var(--_headline-line-height);
132-
font-weight: var(--_headline-weight);
137+
font-family: map.get($tokens, 'headline-font');
138+
font-size: map.get($tokens, 'headline-size');
139+
line-height: map.get($tokens, 'headline-line-height');
140+
font-weight: map.get($tokens, 'headline-weight');
133141
position: relative;
134142
}
135143

@@ -147,12 +155,12 @@
147155
}
148156

149157
slot[name='icon']::slotted(*) {
150-
color: var(--_icon-color);
158+
color: map.get($tokens, 'icon-color');
151159
fill: currentColor;
152-
font-size: var(--_icon-size);
160+
font-size: map.get($tokens, 'icon-size');
153161
margin-top: 24px;
154-
height: var(--_icon-size);
155-
width: var(--_icon-size);
162+
height: map.get($tokens, 'icon-size');
163+
width: map.get($tokens, 'icon-size');
156164
}
157165

158166
.has-icon slot[name='headline']::slotted(*) {
@@ -181,7 +189,7 @@
181189
}
182190

183191
.container::before {
184-
background: var(--_container-color);
192+
background: map.get($tokens, 'container-color');
185193
border-radius: inherit;
186194
content: '';
187195
inset: 0;
@@ -208,11 +216,11 @@
208216
}
209217

210218
.content {
211-
color: var(--_supporting-text-color);
212-
font-family: var(--_supporting-text-font);
213-
font-size: var(--_supporting-text-size);
214-
line-height: var(--_supporting-text-line-height);
215-
font-weight: var(--_supporting-text-weight);
219+
color: map.get($tokens, 'supporting-text-color');
220+
font-family: map.get($tokens, 'supporting-text-font');
221+
font-size: map.get($tokens, 'supporting-text-size');
222+
line-height: map.get($tokens, 'supporting-text-line-height');
223+
font-weight: map.get($tokens, 'supporting-text-weight');
216224
height: min-content; // Needed for Safari
217225
position: relative;
218226
}

0 commit comments

Comments
 (0)