-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(material/button): clean up fab tokens
Reworks the tokens setup for the FAB by: * Introducing a custom tokens map. It was necessary both for these changes and will come in handy later for the ripples. * Using tokens specifically for the disabled state instead of passing in the non-disabled ones. This aligns the FAB with the rest of the library and allows us to reduce the specificity. * Introducing a tokens specifically for the icon/text color. Currently we have an ad-hoc variable declared directly in the component styles. * Using our own mixins for the elevation instead of MDC's. Our mixin calls into MDC eventually, but it has some safeguards as well. * Generating the tokens that we pass into MDC's theme using our APIs, instead of creating the map directly.
- Loading branch information
Showing
4 changed files
with
117 additions
and
69 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
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,57 @@ | ||
@use '../../token-utils'; | ||
@use '../../../theming/inspection'; | ||
@use '../../../style/sass-utils'; | ||
|
||
// The prefix used to generate the fully qualified name for tokens in this file. | ||
$prefix: (mat, fab); | ||
|
||
// Tokens that can't be configured through Angular Material's current theming API, | ||
// but may be in a future version of the theming API. | ||
@function get-unthemable-tokens() { | ||
@return (); | ||
} | ||
|
||
// Tokens that can be configured through Angular Material's color theming API. | ||
@function get-color-tokens($theme) { | ||
$is-dark: inspection.get-theme-type($theme) == dark; | ||
$surface: if($is-dark, #fff, #000); | ||
|
||
@return ( | ||
// Color of icons and text projected into a FAB. | ||
foreground-color: inspection.get-theme-color($theme, foreground, base), | ||
|
||
// MDC doesn't have tokens for disabled FABs so we need to implemented them ourselves. | ||
// Background color of the container when the FAB is disabled. | ||
disabled-state-container-color: rgba($surface, 0.12), | ||
// Color of the icons and projected text when the FAB is disabled. | ||
disabled-state-foreground-color: rgba($surface, if($is-dark, 0.5, 0.38)), | ||
); | ||
} | ||
|
||
// Generates the mapping for the properties that change based on the FAB palette color. | ||
@function private-get-color-palette-color-tokens($theme, $palette-name) { | ||
@return ( | ||
foreground-color: inspection.get-theme-color($theme, $palette-name, default-contrast), | ||
); | ||
} | ||
|
||
// Tokens that can be configured through Angular Material's typography theming API. | ||
@function get-typography-tokens($theme) { | ||
@return (); | ||
} | ||
|
||
// Tokens that can be configured through Angular Material's density theming API. | ||
@function get-density-tokens($theme) { | ||
@return (); | ||
} | ||
|
||
// Combines the tokens generated by the above functions into a single map with placeholder values. | ||
// This is used to create token slots. | ||
@function get-token-slots() { | ||
@return sass-utils.deep-merge-all( | ||
get-unthemable-tokens(), | ||
get-color-tokens(token-utils.$placeholder-color-config), | ||
get-typography-tokens(token-utils.$placeholder-typography-config), | ||
get-density-tokens(token-utils.$placeholder-density-config) | ||
); | ||
} |
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