Skip to content

Instantly share code, notes, and snippets.

@ckvv
Last active September 28, 2022 08:08
Show Gist options
  • Save ckvv/9149beb57b7b4065a03d07af963e71e6 to your computer and use it in GitHub Desktop.
Save ckvv/9149beb57b7b4065a03d07af963e71e6 to your computer and use it in GitHub Desktop.
scss automatically generates palettes
@function getColorPalette($colors) {
$levels: 1, 2, 3, 4, 5, 6, 7, 8, 9;
$interval: 15%;
$_colors: ();
@each $name, $color in $colors {
@debug $levels;
@each $level in $levels {
$_colors: map.deep-merge($_colors, (
#{$name}-#{$level}: color.scale($color, $lightness: $interval * (5 - $level)),
));
}
}
@return $_colors;
}
@debug getColorPalette((
green: #10b981,
red: #ef4444,
));
// output
(
green-1: #8df5d3,
green-2: #63f1c2,
green-3: #38eeb2,
green-4: #14e49f,
green-5: #10b981,
green-6: #0e9d6e,
green-7: #0b825a,
green-8: #096647,
green-9: #064a34,
red-1: #f9b4b4,
red-2: #f69898,
red-3: #f47c7c,
red-4: #f16060,
red-5: #ef4444,
red-6: #eb1a1a,
red-7: #c61111,
red-8: #9c0d0d,
red-9: #710a0a
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment