summaryrefslogtreecommitdiffstats
path: root/src/_vars.scss
diff options
context:
space:
mode:
Diffstat (limited to 'src/_vars.scss')
-rw-r--r--src/_vars.scss116
1 files changed, 62 insertions, 54 deletions
diff --git a/src/_vars.scss b/src/_vars.scss
index 71f0b1f..cafdb3d 100644
--- a/src/_vars.scss
+++ b/src/_vars.scss
@@ -1,3 +1,4 @@
1@use 'sass:math';
1@use 'iro-sass/src/index' as iro; 2@use 'iro-sass/src/index' as iro;
2@use 'include-media/dist/include-media' as media; 3@use 'include-media/dist/include-media' as media;
3@use '@oddbird/blend'; 4@use '@oddbird/blend';
@@ -17,6 +18,42 @@ media.$unit-intervals: (
17 '': 0 18 '': 0
18); 19);
19 20
21$grays: ();
22
23@for $i from 0 through 100 {
24 $grays: append($grays, $i * 1%);
25}
26
27$grays-rev: iro.fn-list-reverse($grays);
28
29@function find-gray($lightness, $contrast) {
30 $base: blend.lch($lightness 0 0);
31 $dir: if($contrast < 0, -1, 1) * if($lightness >= 50%, 1, -1);
32 $args: ();
33
34 @if $dir == 1 {
35 @each $gray in $grays-rev {
36 @if $gray < $lightness {
37 $args: append($args, blend.lch($gray 0 0));
38 }
39 }
40 } @else {
41 @each $gray in $grays {
42 @if $gray > $lightness {
43 $args: append($args, blend.lch($gray 0 0));
44 }
45 }
46 }
47
48 @if length($args) == 0 {
49 @return $base;
50 }
51
52 $args: append($args, math.abs($contrast));
53 $result: blend.contrast($base, $args...);
54 @return hsl(fn.color(--gray-h), fn.color(--gray-s), lightness($result));
55}
56
20// 57//
21 58
22@include iro.props-store(( 59@include iro.props-store((
@@ -95,9 +132,28 @@ media.$unit-intervals: (
95 ); 132 );
96} 133}
97 134
135@function gray-palette($lightness) {
136 @return (
137 --gray1: find-gray($lightness, -1.1),
138 --gray2: find-gray($lightness, -1.05),
139 --gray3: find-gray($lightness, 1),
140 --gray4: find-gray($lightness, 1.15),
141 --gray5: find-gray($lightness, 1.37),
142 --gray6: find-gray($lightness, 1.73),
143 --gray7: find-gray($lightness, 2.4),
144 --gray8: find-gray($lightness, 3.26),
145 --gray9: find-gray($lightness, 7.14),
146 --gray10: find-gray($lightness, 11),
147 --gray11: find-gray($lightness, 17.4),
148 );
149}
150
98@include iro.fn-execute { 151@include iro.fn-execute {
99 @include iro.props-store(( 152 @include iro.props-store((
100 --colors: ( 153 --colors: (
154 --gray-h: 220,
155 --gray-s: 5%,
156
101 --bg-hi2: fn.color(--gray1, null), // Lightest background 157 --bg-hi2: fn.color(--gray1, null), // Lightest background
102 --bg-hi: fn.color(--gray2, null), // Lighter background 158 --bg-hi: fn.color(--gray2, null), // Lighter background
103 --bg: fn.color(--gray3, null), // Background 159 --bg: fn.color(--gray3, null), // Background
@@ -139,35 +195,11 @@ media.$unit-intervals: (
139 ), 'colors'); 195 ), 'colors');
140 196
141 @include iro.props-store(( 197 @include iro.props-store((
142 --colors: ( 198 --colors: gray-palette(94%)
143 --gray1: hsl(210, 0%, 100%), // 1.11
144 --gray2: hsl(210, 0%, 98%), // 1.07
145 --gray3: hsl(210, 0%, 95%), // 1
146 --gray4: hsl(210, 0%, 90%), // 1.11
147 --gray5: hsl(210, 0%, 87%), // 1.2
148 --gray6: hsl(210, 0%, 78%), // 1.51
149 --gray7: hsl(210, 0%, 69%), // 1.93
150 --gray8: hsl(210, 0%, 55%), // 3
151 --gray9: hsl(210, 0%, 38%), // 5.53
152 --gray10: hsl(210, 0%, 19%), // 11.78
153 --gray11: hsl(210, 0%, 0%), // 18.75
154 )
155 ), 'palette-light'); 199 ), 'palette-light');
156 200
157 @include iro.props-store(( 201 @include iro.props-store((
158 --colors: ( 202 --colors: gray-palette(100%)
159 --gray1: hsl(210, 0%, 100%), // 1
160 --gray2: hsl(210, 0%, 100%), // 1
161 --gray3: hsl(210, 0%, 100%), // 1
162 --gray4: hsl(210, 0%, 95%), // 1.11
163 --gray5: hsl(210, 0%, 92%), // 1.19
164 --gray6: hsl(210, 0%, 82%), // 1.52
165 --gray7: hsl(210, 0%, 73%), // 1.94
166 --gray8: hsl(210, 0%, 58%), // 3.03
167 --gray9: hsl(210, 0%, 41%), // 5.48
168 --gray10: hsl(210, 0%, 22%), // 11.72
169 --gray11: hsl(210, 0%, 0%), // 21
170 )
171 ), 'palette-light-raised'); 203 ), 'palette-light-raised');
172} 204}
173 205
@@ -188,37 +220,13 @@ media.$unit-intervals: (
188 ), 220 ),
189 ) 221 )
190 ), 'colors-dark'); 222 ), 'colors-dark');
191 223
192 @include iro.props-store(( 224 @include iro.props-store((
193 --colors: ( 225 --colors: gray-palette(9%)
194 --gray1: hsl(210, 0%, 6%), // 1.1
195 --gray2: hsl(210, 0%, 8%), // 1.05
196 --gray3: hsl(210, 0%, 10%), // 1
197 --gray4: hsl(210, 0%, 14%), // 1.12
198 --gray5: hsl(210, 0%, 20%), // 1.37
199 --gray6: hsl(210, 0%, 26%), // 1.73
200 --gray7: hsl(210, 0%, 34%), // 2.4
201 --gray8: hsl(210, 0%, 42%), // 3.26
202 --gray9: hsl(210, 0%, 65%), // 7.14
203 --gray10: hsl(210, 0%, 86%), // 12.57
204 --gray11: hsl(210, 0%, 100%), // 17.4
205 )
206 ), 'palette-dark'); 226 ), 'palette-dark');
207 227
208 @include iro.props-store(( 228 @include iro.props-store((
209 --colors: ( 229 --colors: gray-palette(16%)
210 --gray1: hsl(210, 0%, 10%), // 1.12
211 --gray2: hsl(210, 0%, 12%), // 1.06
212 --gray3: hsl(210, 0%, 14%), // 1
213 --gray4: hsl(210, 0%, 18%), // 1.14
214 --gray5: hsl(210, 0%, 23%), // 1.38
215 --gray6: hsl(210, 0%, 29%), // 1.75
216 --gray7: hsl(210, 0%, 37%), // 2.39
217 --gray8: hsl(210, 0%, 45%), // 3.27
218 --gray9: hsl(210, 0%, 69%), // 7.15
219 --gray10: hsl(210, 0%, 90%), // 12.43
220 --gray11: hsl(210, 0%, 100%), // 15.52
221 )
222 ), 'palette-dark-raised'); 230 ), 'palette-dark-raised');
223} 231}
224 232