-
Notifications
You must be signed in to change notification settings - Fork 904
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(icon)!: remove css custom props from icon and apply values d…
…irectly on host BREAKING CHANGE: Remove css custom properties from icon and prefer applying normal css properties on host except for font-family. PiperOrigin-RevId: 553577562
- Loading branch information
1 parent
65bc8f4
commit ff60a88
Showing
7 changed files
with
92 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,7 +94,7 @@ Load the font with | |
<link href="https://fonts.googleapis.com/icon?family=Material+Symbols+Sharp" rel="stylesheet"> | ||
``` | ||
To use Sharp icons, set `--md-icon-font` to `'Material Symbols Sharp'`. | ||
To use Sharp icons, set `font-family` to `'Material Symbols Sharp'`. | ||
### Fill | ||
|
@@ -109,7 +109,7 @@ filled. Along with weight, fill is a primary attribute that impacts the overall | |
look of a symbol. | ||
All styles of Material Symbols can be filled by setting | ||
`--md-icon-font-variation-settings` to `'FILL' 1`. | ||
`font-variation-settings` to `'FILL' 1`. | ||
## Accessibility | ||
|
@@ -138,13 +138,9 @@ If using SVG icons, add an `aria-label` attribute to the SVG element. | |
### Tokens | ||
Token | Default value | ||
----------------------------------- | ----------------------------- | ||
`--md-icon-color` | `inherit` | ||
`--md-icon-font` | `'Material Symbols Outlined'` | ||
`--md-icon-font-variation-settings` | `inherit` | ||
`--md-icon-size` | `24px` | ||
`--md-icon-weight` | `400` | ||
Token | Default value | ||
---------------- | ----------------------------- | ||
`--md-icon-font` | `'Material Symbols Outlined'` | ||
* [All tokens](https://github.com/material-components/material-web/blob/main/icon/internal/_md-comp-icon.scss) | ||
<!-- {.external} --> | ||
|
@@ -159,9 +155,15 @@ Token | Default value | |
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,[email protected],100..700,0..1" rel="stylesheet"> | ||
<style> | ||
:root { | ||
--md-icon-color: #006A6A; | ||
--md-icon-size: 48px; | ||
md-icon { | ||
color: #006A6A; | ||
font-size: 48px; | ||
} | ||
md-icon, | ||
md-icon > * { | ||
/* Resizes any slotted images or SVGs */ | ||
width: 48px; | ||
height: 48px; | ||
} | ||
.rounded { | ||
--md-icon-font: 'Material Symbols Rounded'; | ||
|
@@ -170,7 +172,7 @@ Token | Default value | |
--md-icon-font: 'Material Symbols Sharp'; | ||
} | ||
md-icon[filled] { | ||
--md-icon-font-variation-settings: 'FILL' 1; | ||
font-variation-settings: 'FILL' 1; | ||
} | ||
</style> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// Copyright 2023 Google LLC | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
// go/keep-sorted start | ||
@use './values'; | ||
// go/keep-sorted end | ||
|
||
$supported-tokens: ( | ||
// go/keep-sorted start | ||
'font', | ||
// 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'), | ||
// go/keep-sorted end | ||
); | ||
} | ||
|
||
@function values($exclude-hardcoded-values: false) { | ||
$tokens: values.validate( | ||
(), | ||
$supported-tokens: $supported-tokens, | ||
$new-tokens: _get-new-tokens($exclude-hardcoded-values) | ||
); | ||
|
||
@return $tokens; | ||
} |