Skip to content

Commit 12c9364

Browse files
dfreedmcopybara-github
authored andcommitted
fix(icon, iconbutton): Cleanup styling
- Remove duplicate md-ripple sizing in standard icon button - Tokens now have disabled outline color for outlined icon button, remove workaround - Use icon theming API - Also size `<img>` tags in `<md-icon>` PiperOrigin-RevId: 500805749
1 parent 2c6ed71 commit 12c9364

File tree

4 files changed

+21
-44
lines changed

4 files changed

+21
-44
lines changed

icon/lib/_icon.scss

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ $_custom-property-prefix: 'icon';
4545
-moz-osx-font-smoothing: grayscale;
4646
}
4747

48-
span ::slotted(svg) {
49-
fill: currentColor;
50-
height: var(--_size);
51-
width: var(--_size);
48+
span {
49+
::slotted(svg) {
50+
fill: currentColor;
51+
}
52+
::slotted(*) {
53+
height: var(--_size);
54+
width: var(--_size);
55+
}
5256
}
5357
}

iconbutton/lib/_outlined-icon-button.scss

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,10 @@
1818
$_custom-property-prefix: 'outlined-icon-button';
1919

2020
@mixin theme($tokens) {
21-
// TODO(b/233323674): Remove when missing tokens have been added.
22-
$reference: map.merge(
21+
$tokens: theme.validate-theme(
2322
tokens.md-comp-outlined-icon-button-values(),
24-
(
25-
disabled-selected-container-color:
26-
map.get(tokens.md-sys-color-values-light(), on-surface),
27-
disabled-selected-container-opacity: 0.12,
28-
)
23+
$tokens
2924
);
30-
$tokens: theme.validate-theme($reference, $tokens);
3125
$tokens: shared.flatten-disabled-colors($tokens, $variant: 'outlined');
3226
$tokens: shared.resolve-shape-tokens($tokens);
3327
$tokens: theme.create-theme-vars($tokens, $_custom-property-prefix);
@@ -37,15 +31,6 @@ $_custom-property-prefix: 'outlined-icon-button';
3731

3832
@mixin styles() {
3933
$tokens: tokens.md-comp-outlined-icon-button-values();
40-
// TODO(b/233323674): Remove when missing tokens have been added.
41-
$tokens: map.merge(
42-
$tokens,
43-
(
44-
disabled-selected-container-color:
45-
map.get(tokens.md-sys-color-values-light(), on-surface),
46-
disabled-selected-container-opacity: 0.12,
47-
)
48-
);
4934
$tokens: shared.flatten-disabled-colors($tokens, $variant: 'outlined');
5035
$tokens: shared.resolve-shape-tokens($tokens);
5136
$tokens: theme.create-theme-vars($tokens, $_custom-property-prefix);

iconbutton/lib/_shared.scss

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
@use '../../sass/shape';
1616
@use '../../sass/resolvers';
1717
@use '../../tokens';
18+
@use '../../icon/icon';
1819

1920
@mixin styles() {
2021
:host {
@@ -35,7 +36,6 @@
3536
box-sizing: border-box;
3637
cursor: pointer;
3738
display: flex;
38-
fill: currentColor;
3939
justify-content: center;
4040
outline: none;
4141
position: relative;
@@ -44,7 +44,6 @@
4444
z-index: 0;
4545
height: var(--_container-size);
4646
width: var(--_container-size);
47-
font-size: var(--_icon-size);
4847
margin: max(
4948
0px,
5049
calc((#{$touch-target-height} - var(--_container-size)) / 2)
@@ -53,20 +52,15 @@
5352
border-start-end-radius: var(--_container-shape-start-end);
5453
border-end-start-radius: var(--_container-shape-end-start);
5554
border-end-end-radius: var(--_container-shape-end-end);
55+
}
5656

57-
i,
58-
svg,
59-
img {
60-
height: var(--_icon-size);
61-
width: var(--_icon-size);
62-
}
63-
64-
i,
65-
svg,
66-
img,
67-
::slotted(*) {
68-
display: block;
69-
}
57+
.md3-icon-button__icon {
58+
@include icon.theme(
59+
(
60+
size: var(--_icon-size),
61+
weight: inherit,
62+
)
63+
);
7064
}
7165

7266
md-ripple {

iconbutton/lib/_standard-icon-button.scss

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ $_custom-property-prefix: 'icon-button';
6767
pressed-state-layer-color: var(--_unselected-pressed-state-layer-color),
6868
pressed-state-layer-opacity:
6969
var(--_unselected-pressed-state-layer-opacity),
70+
// TODO(b/263517885): replace with ripple.theme(state-layer-shape)
71+
state-layer-shape: var(--_state-layer-shape-start-start),
7072
)
7173
);
7274

@@ -116,12 +118,4 @@ $_custom-property-prefix: 'icon-button';
116118
)
117119
);
118120
}
119-
120-
md-ripple {
121-
// TODO(b/263517885): replace with ripple.theme(state-layer-shape)
122-
border-start-start-radius: var(--_state-layer-shape-start-start);
123-
border-start-end-radius: var(--_state-layer-shape-start-end);
124-
border-end-start-radius: var(--_state-layer-shape-end-start);
125-
border-end-end-radius: var(--_state-layer-shape-end-end);
126-
}
127121
}

0 commit comments

Comments
 (0)