Skip to content

Commit

Permalink
Merge pull request #5150 from scherler:icon_size
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 582411939
  • Loading branch information
copybara-github committed Nov 14, 2023
2 parents 3e66c3e + b4c9b81 commit 128abcb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
11 changes: 3 additions & 8 deletions docs/components/icon.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ If using SVG icons, add an `aria-label` attribute to the SVG element.
Token | Default value
---------------- | -----------------------------
`--md-icon-font` | `'Material Symbols Outlined'`
`--md-icon-size` | `24px`
* [All tokens](https://github.com/material-components/material-web/blob/main/icon/internal/_md-comp-icon.scss)
* [All tokens](https://github.com/material-components/material-web/blob/main/tokens/_md-comp-icon.scss)
<!-- {.external} -->
### Example
Expand All @@ -157,13 +158,7 @@ Token | Default value
<style>
md-icon {
color: #006A6A;
font-size: 48px;
}
md-icon,
md-icon > * {
/* Resizes any slotted images or SVGs */
width: 48px;
height: 48px;
--md-icon-size: 48px;
}
.rounded {
--md-icon-font: 'Material Symbols Rounded';
Expand Down
11 changes: 7 additions & 4 deletions icon/internal/_icon.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,18 @@

@mixin styles() {
$tokens: tokens.md-comp-icon-values();
@each $token, $value in $tokens {
$tokens: map.set($tokens, $token, var(--md-icon-#{$token}, #{$value}));
}

:host {
font-size: 24px;
width: 24px;
height: 24px;
font-size: map.get($tokens, 'size');
width: map.get($tokens, 'size');
height: map.get($tokens, 'size');
color: inherit;
font-variation-settings: inherit;
font-weight: 400;
font-family: var(--md-icon-font, #{map.get($tokens, font)});
font-family: map.get($tokens, 'font');
display: inline-flex;
font-style: normal;
line-height: 1;
Expand Down
2 changes: 2 additions & 0 deletions tokens/_md-comp-icon.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
$supported-tokens: (
// go/keep-sorted start
'font',
'size',
// go/keep-sorted end
);

@function _get-new-tokens($exclude-hardcoded-values) {
@return (
// go/keep-sorted start
font: if($exclude-hardcoded-values, null, 'Material Symbols Outlined'),
size: if($exclude-hardcoded-values, null, 24px),
// go/keep-sorted end
);
}
Expand Down

0 comments on commit 128abcb

Please sign in to comment.