-
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): switch outlined button to tokens API
- Loading branch information
1 parent
999029a
commit 5c53741
Showing
4 changed files
with
159 additions
and
38 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,96 @@ | ||
@use '../../token-utils'; | ||
@use '../../../mdc-helpers/mdc-helpers'; | ||
@use '../../../style/sass-utils'; | ||
@use '../../../theming/inspection'; | ||
|
||
// The prefix used to generate the fully qualified name for tokens in this file. | ||
$prefix: (mdc, button-protected); | ||
|
||
// 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 ( | ||
keep-touch-target: false, | ||
|
||
outline-width: 1px, | ||
container-shape: 4px, | ||
|
||
hover-state-layer-opacity: 0.04, | ||
focus-state-layer-opacity: 0.12, | ||
pressed-state-layer-opacity: 0.12, | ||
|
||
hover-label-text-color: null, | ||
focus-label-text-color: null, | ||
pressed-label-text-color: null, | ||
|
||
hover-outline-color: null, | ||
focus-outline-color: null, | ||
pressed-outline-color: null, | ||
|
||
focus-ring-color: null, | ||
focus-ring-offset: null, | ||
|
||
with-icon-icon-size: null, | ||
with-icon-icon-color: null, | ||
with-icon-hover-icon-color: null, | ||
with-icon-focus-icon-color: null, | ||
with-icon-pressed-icon-color: null, | ||
with-icon-disabled-icon-color: null, | ||
|
||
label-text-size: null, | ||
label-text-font: null, | ||
label-text-weight: null, | ||
label-text-tracking: null, | ||
label-text-transform: null, | ||
|
||
container-height: null | ||
); | ||
} | ||
|
||
@function _on-color($theme, $palette) { | ||
@if ($palette) { | ||
$is-dark: inspection.get-theme-type($theme) == dark; | ||
@return if(mdc-helpers.variable-safe-contrast-tone($palette, $is-dark) == 'dark', #000, #fff); | ||
} | ||
} | ||
|
||
// Tokens that can be configured through Angular Material's color theming API. | ||
@function get-color-tokens($theme, $color: null, $on-color: null) { | ||
$surface: inspection.get-theme-color($theme, background, card); | ||
$on-surface: _on-color($theme, $surface); | ||
|
||
@return ( | ||
focus-state-layer-color: $color, | ||
hover-state-layer-color: $color, | ||
pressed-state-layer-color: $color, | ||
disabled-outline-color: rgba($on-surface, 0.12), | ||
disabled-label-text-color: rgba($on-surface, 0.38), | ||
label-text-color: if($color, $color, inherit), | ||
outline-color: rgba($on-surface, 0.12) | ||
); | ||
} | ||
|
||
// 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