forked from angular/components
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(material/core): switch ripple to tokens theming API (angular…
…#28042) Switches the ripple element color to be controlled through a token.
- Loading branch information
Showing
4 changed files
with
88 additions
and
21 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
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,49 @@ | ||
@use 'sass:meta'; | ||
@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, ripple); | ||
|
||
// 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; | ||
$base: inspection.get-theme-color($theme, foreground, base); | ||
|
||
// If the base is a color *type* we can use it directly in the `rgba` call below. | ||
// If it's anything else (e.g. a CSS variable) we fall back to using static colors | ||
// since we don't have a way of adjusting the opacity. | ||
$color: if(meta.type-of($base) == color, $base, if($is-dark, #fff, #000)); | ||
|
||
@return ( | ||
color: rgba($color, 0.1), | ||
); | ||
} | ||
|
||
// 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) | ||
); | ||
} |