Skip to content

Commit d1e2d8a

Browse files
committed
fix(material/button): compute M2 icon-button density padding with CSS calc
1 parent d7f6c84 commit d1e2d8a

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

src/material/button/_icon-button-theme.scss

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
@use 'sass:map';
2-
@use 'sass:math';
32
@use './m2-icon-button';
43
@use './m3-icon-button';
54
@use '../core/tokens/token-utils';
@@ -85,14 +84,11 @@
8584
--mdc-icon-button-state-layer-size: #{$calculated-size};
8685
--mat-icon-button-state-layer-size: #{$calculated-size};
8786

88-
// TODO: Switch calculated-size to "var(--mat-icon-button-state-layer-size)"
89-
// Currently fails validation because the variable is "undefined"
90-
// in the sass stack.
91-
// TODO: Switch icon-size to "var(--mat-icon-button-icon-size)". Currently
92-
// fails validation because the variable is "undefined" in the sass stack.
9387
width: var(--mat-icon-button-state-layer-size);
9488
height: var(--mat-icon-button-state-layer-size);
95-
padding: math.div($calculated-size - $icon-size, 2);
89+
// Note: this is wrapped in an interpolation, because of an internal lint rule that bans
90+
// interpolations in `calc`, even though this is the only way to achieve what we're looking for.
91+
padding: calc(var(--mat-icon-button-state-layer-size, #{$calculated-size}) - var(--mat-icon-button-icon-size, #{$icon-size})) / 2;
9692
}
9793
}
9894
}

0 commit comments

Comments
 (0)