summaryrefslogtreecommitdiffstats
path: root/src/_functions.scss
diff options
context:
space:
mode:
Diffstat (limited to 'src/_functions.scss')
-rw-r--r--src/_functions.scss16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/_functions.scss b/src/_functions.scss
index 7c0ded3..8553833 100644
--- a/src/_functions.scss
+++ b/src/_functions.scss
@@ -107,21 +107,29 @@
107 @return $result; 107 @return $result;
108} 108}
109 109
110@function palette($base-color, $contrasts, $range: 1, $reference-color: $base-color) { 110@function palette($base-color, $contrasts, $range: 1, $desaturate: true, $reference-color: $base-color) {
111 $palette: (); 111 $palette: ();
112 112
113 @if list.nth(list.nth($contrasts, 1), 2) > list.nth(list.nth($contrasts, list.length($contrasts)), 2) { 113 @if list.nth(list.nth($contrasts, 1), 2) > list.nth(list.nth($contrasts, list.length($contrasts)), 2) {
114 $contrasts: iro.fn-list-reverse($contrasts); 114 $contrasts: iro.fn-list-reverse($contrasts);
115 } 115 }
116 116
117 $reference-lightness: blend.lightness($reference-color);
117 $i: -100%; 118 $i: -100%;
118 119
119 @while $i <= 100% { 120 @while $i <= 100% {
120 $palette: list.append($palette, blend.scale($base-color, $l: $range * $i, $c: -.8 * math.abs($i))); 121 $c: if($desaturate, .8 * if($reference-lightness >= 50%, -1 * math.clamp(0%, $i, 100%), math.clamp(-100%, $i, 0%)), 0%);
121 $i: $i + config.$palette-precision; 122 $palette: list.append($palette, blend.scale($base-color, $l: $range * $i, $c: $c));
123 $i: $i + config.$palette-precision;
122 } 124 }
123 125
124 @return multi-contrast($base-color, $palette, $contrasts, $reference-color); 126 $palette: multi-contrast($base-color, $palette, $contrasts, $reference-color);
127
128 @each $key, $color in $palette {
129 $palette: map.set($palette, #{$key}-text, blend.contrast($color))
130 }
131
132 @return $palette;
125} 133}
126 134
127@function px-to-em($size, $base: iro.$vars-root-size) { 135@function px-to-em($size, $base: iro.$vars-root-size) {