diff options
Diffstat (limited to 'src/_functions.scss')
| -rw-r--r-- | src/_functions.scss | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/src/_functions.scss b/src/_functions.scss index 8fb0d98..e237ccc 100644 --- a/src/_functions.scss +++ b/src/_functions.scss | |||
| @@ -1,17 +1,17 @@ | |||
| 1 | @use "sass:color"; | 1 | @use 'sass:color'; |
| 2 | @use "sass:math"; | 2 | @use 'sass:math'; |
| 3 | @use "sass:map"; | 3 | @use 'sass:map'; |
| 4 | @use "sass:list"; | 4 | @use 'sass:list'; |
| 5 | @use "sass:meta"; | 5 | @use 'sass:meta'; |
| 6 | 6 | ||
| 7 | @use "pkg:iro-sass/easing"; | 7 | @use 'pkg:iro-sass/src/easing'; |
| 8 | @use "apca"; | 8 | @use 'apca'; |
| 9 | 9 | ||
| 10 | @function palette($base-color, $levels, $ref-color: $base-color) { | 10 | @function palette($base-color, $levels, $ref-color: $base-color) { |
| 11 | $base-lch: color.to-space($base-color, oklch); | 11 | $base-lch: color.to-space($base-color, oklch); |
| 12 | $ref-lch: color.to-space($ref-color, oklch); | 12 | $ref-lch: color.to-space($ref-color, oklch); |
| 13 | 13 | ||
| 14 | $ref-l: color.channel($ref-lch, "lightness"); | 14 | $ref-l: color.channel($ref-lch, 'lightness'); |
| 15 | $ref-y: apca.sRGB_to_Y($ref-lch); | 15 | $ref-y: apca.sRGB_to_Y($ref-lch); |
| 16 | 16 | ||
| 17 | $black-y: apca.sRGB_to_Y(#000); | 17 | $black-y: apca.sRGB_to_Y(#000); |
| @@ -32,19 +32,17 @@ | |||
| 32 | $h: list.nth($level, 3); | 32 | $h: list.nth($level, 3); |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | @if meta.type-of($color) != "color" { | 35 | @if meta.type-of($color) != 'color' { |
| 36 | $y: apca.reverse($color, $ref-y); | 36 | $y: apca.reverse($color, $ref-y); |
| 37 | $l: color.channel($base-lch, "lightness"); | 37 | $l: color.channel($base-lch, 'lightness'); |
| 38 | 38 | ||
| 39 | @if $y != false { | 39 | @if $y != false { |
| 40 | $l: color.channel(apca.Y_to_sRGB($y), "lightness", oklch); | 40 | $l: color.channel(apca.Y_to_sRGB($y), 'lightness', oklch); |
| 41 | } @else { | 41 | } @else { |
| 42 | $y: $ref-y; | 42 | $y: $ref-y; |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | $color: oklch( | 45 | $color: oklch($l ($c * color.channel($base-lch, 'chroma')) ($h + color.channel($base-lch, 'hue'))); |
| 46 | $l ($c * color.channel($base-lch, "chroma")) ($h + color.channel($base-lch, "hue")) | ||
| 47 | ); | ||
| 48 | } @else { | 46 | } @else { |
| 49 | $y: apca.sRGB_to_Y($color); | 47 | $y: apca.sRGB_to_Y($color); |
| 50 | } | 48 | } |
| @@ -53,11 +51,7 @@ | |||
| 53 | $contrast-white: apca.contrast($white-y, $y); | 51 | $contrast-white: apca.contrast($white-y, $y); |
| 54 | 52 | ||
| 55 | $palette: map.set($palette, $key, $color); | 53 | $palette: map.set($palette, $key, $color); |
| 56 | $palette: map.set( | 54 | $palette: map.set($palette, #{$key}-text, if(sass(math.abs($contrast-black) > math.abs($contrast-white)): #000; else: #fff)); |
| 57 | $palette, | ||
| 58 | #{$key}-text, | ||
| 59 | if(sass(math.abs($contrast-black) > math.abs($contrast-white)): #000; else: #fff) | ||
| 60 | ); | ||
| 61 | } | 55 | } |
| 62 | 56 | ||
| 63 | @return $palette; | 57 | @return $palette; |
