forked from angular/components
-
Notifications
You must be signed in to change notification settings - Fork 9
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): switch text button to tokens for color and…
… density Switches the color and density styles for the text button to tokens.
- Loading branch information
Showing
4 changed files
with
160 additions
and
57 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,99 @@ | ||
@use 'sass:map'; | ||
@use '../../token-utils'; | ||
@use '../../../style/sass-utils'; | ||
@use '../../../theming/inspection'; | ||
@use '../../../theming/theming'; | ||
|
||
// The prefix used to generate the fully qualified name for tokens in this file. | ||
$prefix: (mdc, text-button); | ||
|
||
// Tokens that can't be configured through Angular Material's current theming API, | ||
// but may be in a future version of the theming API. | ||
// | ||
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`. | ||
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in | ||
// our CSS. | ||
@function get-unthemable-tokens() { | ||
@return ( | ||
container-shape: 4px, | ||
|
||
// TODO: handle these through the typography styles eventually. | ||
label-text-font: null, | ||
label-text-size: null, | ||
label-text-tracking: null, | ||
label-text-transform: null, | ||
label-text-weight: null, | ||
|
||
// ============================================================================================= | ||
// = TOKENS NOT USED IN ANGULAR MATERIAL = | ||
// ============================================================================================= | ||
hover-label-text-color: null, | ||
focus-label-text-color: null, | ||
pressed-label-text-color: null, | ||
focus-state-layer-color: null, | ||
focus-state-layer-opacity: null, | ||
hover-state-layer-color: null, | ||
hover-state-layer-opacity: null, | ||
pressed-state-layer-color: null, | ||
pressed-state-layer-opacity: null, | ||
with-icon-disabled-icon-color: null, | ||
with-icon-focus-icon-color: null, | ||
with-icon-hover-icon-color: null, | ||
with-icon-icon-color: null, | ||
with-icon-icon-size: null, | ||
with-icon-pressed-icon-color: null, | ||
focus-ring-color: null, | ||
focus-ring-offset: null, | ||
keep-touch-target: false, | ||
); | ||
} | ||
|
||
// 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; | ||
$on-surface: if($is-dark, #fff, #000); | ||
|
||
@return ( | ||
label-text-color: $on-surface, | ||
disabled-label-text-color: rgba($on-surface, if($is-dark, 0.5, 0.38)), | ||
); | ||
} | ||
|
||
// Generates the mapping for the properties that change based on the button palette color. | ||
@function private-get-color-palette-color-tokens($theme, $palette-name) { | ||
$palette: map.get($theme, $palette-name); | ||
|
||
@return ( | ||
label-text-color: inspection.get-theme-color($theme, $palette-name) | ||
); | ||
} | ||
|
||
// 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) { | ||
$scale: theming.clamp-density(inspection.get-theme-density($theme), -3); | ||
|
||
@return ( | ||
container-height: map.get(( | ||
0: 36px, | ||
-1: 32px, | ||
-2: 28px, | ||
-3: 24px, | ||
), $scale), | ||
); | ||
} | ||
|
||
// 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