Created
May 27, 2022 01:29
-
-
Save fireflysemantics/d32e455a9137fb4dbaa2b73d06276b6b to your computer and use it in GitHub Desktop.
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
/// Creates a map of hues to colors for a theme. This is used to define a theme palette in terms | |
/// of the Material Design hues. | |
/// @param {Map} $base-palette Map of hue keys to color values for the basis for this palette. | |
/// @param {String | Number} $default Default hue for this palette. | |
/// @param {String | Number} $lighter "lighter" hue for this palette. | |
/// @param {String | Number} $darker "darker" hue for this palette. | |
/// @param {String | Number} $text "text" hue for this palette. | |
/// @returns {Map} A complete Angular Material theming palette. | |
@function define-palette($base-palette, $default: 500, $lighter: 100, $darker: 700, | |
$text: $default) { | |
$result: map.merge($base-palette, ( | |
default: _get-color-from-palette($base-palette, $default), | |
lighter: _get-color-from-palette($base-palette, $lighter), | |
darker: _get-color-from-palette($base-palette, $darker), | |
text: _get-color-from-palette($base-palette, $text), | |
default-contrast: get-contrast-color-from-palette($base-palette, $default), | |
lighter-contrast: get-contrast-color-from-palette($base-palette, $lighter), | |
darker-contrast: get-contrast-color-from-palette($base-palette, $darker) | |
)); | |
// For each hue in the palette, add a "-contrast" color to the map. | |
@each $hue, $color in $base-palette { | |
$result: map.merge($result, ( | |
'#{$hue}-contrast': get-contrast-color-from-palette($base-palette, $hue) | |
)); | |
} | |
@return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment