Skip to content

Commit

Permalink
fix(icon, iconbutton): Cleanup styling
Browse files Browse the repository at this point in the history
 - 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
  • Loading branch information
dfreedm authored and copybara-github committed Jan 9, 2023
1 parent 2c6ed71 commit 12c9364
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 44 deletions.
12 changes: 8 additions & 4 deletions icon/lib/_icon.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ $_custom-property-prefix: 'icon';
-moz-osx-font-smoothing: grayscale;
}

span ::slotted(svg) {
fill: currentColor;
height: var(--_size);
width: var(--_size);
span {
::slotted(svg) {
fill: currentColor;
}
::slotted(*) {
height: var(--_size);
width: var(--_size);
}
}
}
19 changes: 2 additions & 17 deletions iconbutton/lib/_outlined-icon-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,10 @@
$_custom-property-prefix: 'outlined-icon-button';

@mixin theme($tokens) {
// TODO(b/233323674): Remove when missing tokens have been added.
$reference: map.merge(
$tokens: theme.validate-theme(
tokens.md-comp-outlined-icon-button-values(),
(
disabled-selected-container-color:
map.get(tokens.md-sys-color-values-light(), on-surface),
disabled-selected-container-opacity: 0.12,
)
$tokens
);
$tokens: theme.validate-theme($reference, $tokens);
$tokens: shared.flatten-disabled-colors($tokens, $variant: 'outlined');
$tokens: shared.resolve-shape-tokens($tokens);
$tokens: theme.create-theme-vars($tokens, $_custom-property-prefix);
Expand All @@ -37,15 +31,6 @@ $_custom-property-prefix: 'outlined-icon-button';

@mixin styles() {
$tokens: tokens.md-comp-outlined-icon-button-values();
// TODO(b/233323674): Remove when missing tokens have been added.
$tokens: map.merge(
$tokens,
(
disabled-selected-container-color:
map.get(tokens.md-sys-color-values-light(), on-surface),
disabled-selected-container-opacity: 0.12,
)
);
$tokens: shared.flatten-disabled-colors($tokens, $variant: 'outlined');
$tokens: shared.resolve-shape-tokens($tokens);
$tokens: theme.create-theme-vars($tokens, $_custom-property-prefix);
Expand Down
24 changes: 9 additions & 15 deletions iconbutton/lib/_shared.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
@use '../../sass/shape';
@use '../../sass/resolvers';
@use '../../tokens';
@use '../../icon/icon';

@mixin styles() {
:host {
Expand All @@ -35,7 +36,6 @@
box-sizing: border-box;
cursor: pointer;
display: flex;
fill: currentColor;
justify-content: center;
outline: none;
position: relative;
Expand All @@ -44,7 +44,6 @@
z-index: 0;
height: var(--_container-size);
width: var(--_container-size);
font-size: var(--_icon-size);
margin: max(
0px,
calc((#{$touch-target-height} - var(--_container-size)) / 2)
Expand All @@ -53,20 +52,15 @@
border-start-end-radius: var(--_container-shape-start-end);
border-end-start-radius: var(--_container-shape-end-start);
border-end-end-radius: var(--_container-shape-end-end);
}

i,
svg,
img {
height: var(--_icon-size);
width: var(--_icon-size);
}

i,
svg,
img,
::slotted(*) {
display: block;
}
.md3-icon-button__icon {
@include icon.theme(
(
size: var(--_icon-size),
weight: inherit,
)
);
}

md-ripple {
Expand Down
10 changes: 2 additions & 8 deletions iconbutton/lib/_standard-icon-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ $_custom-property-prefix: 'icon-button';
pressed-state-layer-color: var(--_unselected-pressed-state-layer-color),
pressed-state-layer-opacity:
var(--_unselected-pressed-state-layer-opacity),
// TODO(b/263517885): replace with ripple.theme(state-layer-shape)
state-layer-shape: var(--_state-layer-shape-start-start),
)
);

Expand Down Expand Up @@ -116,12 +118,4 @@ $_custom-property-prefix: 'icon-button';
)
);
}

md-ripple {
// TODO(b/263517885): replace with ripple.theme(state-layer-shape)
border-start-start-radius: var(--_state-layer-shape-start-start);
border-start-end-radius: var(--_state-layer-shape-start-end);
border-end-start-radius: var(--_state-layer-shape-end-start);
border-end-end-radius: var(--_state-layer-shape-end-end);
}
}

0 comments on commit 12c9364

Please sign in to comment.