From a8d6946bbc6b4c835b2812ddb8eae98393777199 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sun, 13 Feb 2022 16:01:03 +0100 Subject: Improved accent structure --- src/_functions.scss | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src/_functions.scss') diff --git a/src/_functions.scss b/src/_functions.scss index 56fdf39..c45dcfb 100644 --- a/src/_functions.scss +++ b/src/_functions.scss @@ -78,10 +78,12 @@ } } - $wanted-contrast: nth($wanted-contrasts, $wanted-idx); + $wanted: nth($wanted-contrasts, $wanted-idx); + $wanted-key: nth($wanted, 1); + $wanted-contrast: nth($wanted, 2); @if $contrast >= $wanted-contrast { - $result: append($result, $color); + $result: map.set($result, $wanted-key, $color); $wanted-idx: $wanted-idx + 1; } @else { $colors-idx: $colors-idx + $dir * 1; @@ -90,19 +92,23 @@ $last-color: nth($colors, if($dir == -1, 1, $colors-len)); - @for $i from $wanted-idx through $wanted-len { - $result: append($result, $last-color); + @if $wanted-idx <= $wanted-len { + @for $i from $wanted-idx through $wanted-len { + $wanted: nth($wanted-contrasts, $i); + $wanted-key: nth($wanted, 1); + $result: map.set($result, $wanted-key, $last-color); + } } @return $result; } -@function accent-palette($base, $dir: 1) { +@function color-palette($base, $dir: 1) { @return ( - --hi: blend.scale($base, $lightness: $dir * 15%, $chroma: $dir * 10%), - --main: $base, - --lo: blend.scale($base, $lightness: $dir * -15%, $chroma: $dir * -10%), - --lo2: blend.scale($base, $lightness: $dir * -25%, $chroma: $dir * -20%), + --bg-hi: blend.scale($base, $lightness: $dir * 15%, $chroma: $dir * 10%), + --bg: $base, + --obj: blend.scale($base, $lightness: $dir * -15%, $chroma: $dir * -10%), + --obj-lo: blend.scale($base, $lightness: $dir * -25%, $chroma: $dir * -20%), --semi: rgba($base, .4), --selection: rgba($base, .99), --fg: blend.contrast($base), @@ -118,11 +124,9 @@ $colors: multi-contrast(blend.lch($lightness * 1% 0 0), $grays, config.$wanted-grays); - $palette: (); - - @for $i from 1 through length($colors) { - $palette: map.set($palette, --gray#{$i}, hsl(color(--gray-h), color(--gray-s), lightness(nth($colors, $i)))); + @each $key, $color in $colors { + $colors: map.set($colors, $key, hsl(color(--gray --h), color(--gray --s), lightness($color))); } - @return $palette; + @return $colors; } -- cgit v1.2.3-54-g00ecf