|
3 | 3 | @use 'sass:list';
|
4 | 4 | @use 'sass:string';
|
5 | 5 |
|
6 |
| -@mixin transition($args...) { |
7 |
| - $property: all; |
8 |
| - $speed: .3s; |
9 |
| - |
10 |
| - @each $arg in $args { |
11 |
| - @if (meta.type-of($arg) == 'number') { |
12 |
| - $speed: $arg; |
13 |
| - } @else { |
14 |
| - $property: $arg; |
15 |
| - } |
16 |
| - } |
17 |
| - |
18 |
| - transition: $property $speed cubic-bezier(0.4, 0.0, 0.2, 1); |
19 |
| -} |
20 |
| - |
21 |
| -@mixin media($breakpoint: 'xs') { |
22 |
| - @media (min-width: #{map.get($breakpoints, $breakpoint)}) { |
23 |
| - @content; |
24 |
| - } |
25 |
| -} |
26 |
| - |
27 | 6 | @mixin background($arg) {
|
28 | 7 | background: map.get($colorPalette, '#{$arg}') or $arg;
|
29 | 8 | }
|
|
71 | 50 | @mixin border-radius($args...) {
|
72 | 51 | $borderRadius: map.get($radius, 'md');
|
73 | 52 | $position: null;
|
74 |
| - $side: ( |
75 |
| - top: ('top-left', 'top-right'), |
76 |
| - bottom: ('bottom-left', 'bottom-right'), |
77 |
| - left: ('top-left', 'bottom-left'), |
78 |
| - right: ('top-right', 'bottom-right') |
79 |
| - ); |
80 |
| - |
| 53 | + |
81 | 54 | @each $arg in $args {
|
82 |
| - @if (map.get($radius, $arg)) { |
83 |
| - $borderRadius: map.get($radius, $arg); |
84 |
| - } |
85 |
| - |
86 |
| - @if (map.get($side, $arg)) { |
87 |
| - $position: map.get($side, $arg); |
88 |
| - } |
| 55 | + @if (map.get($radius, $arg)) { |
| 56 | + $borderRadius: map.get($radius, $arg); |
| 57 | + } |
| 58 | + |
| 59 | + $side: ( |
| 60 | + top: $borderRadius $borderRadius 0 0, |
| 61 | + bottom: 0 0 $borderRadius $borderRadius, |
| 62 | + left: $borderRadius 0 0 $borderRadius, |
| 63 | + right: 0 $borderRadius $borderRadius 0, |
| 64 | + diagonal: $borderRadius 0, |
| 65 | + reverse-diagonal: 0 $borderRadius |
| 66 | + ); |
| 67 | + |
| 68 | + @if (map.get($side, $arg)) { |
| 69 | + $position: map.get($side, $arg); |
| 70 | + } |
89 | 71 | }
|
| 72 | + |
| 73 | + border-radius: $position or $borderRadius; |
| 74 | + } |
90 | 75 |
|
91 |
| - @if ($position) { |
92 |
| - @each $key in $position { |
93 |
| - border-#{$key}-radius: $borderRadius; |
94 |
| - } |
95 |
| - } @else { |
96 |
| - border-radius: $borderRadius; |
97 |
| - } |
| 76 | +@mixin layer($stack: 'default') { |
| 77 | + z-index: #{map.get($layers, $stack)}; |
98 | 78 | }
|
99 | 79 |
|
100 |
| -@mixin visibility($args...) { |
| 80 | +@mixin layout($args...) { |
| 81 | + $layouts: (flex, inline-flex, grid, inline-grid); |
| 82 | + $alignments: ( |
| 83 | + vertical: ( |
| 84 | + 'v-center': center, |
| 85 | + 'v-start': flex-start, |
| 86 | + 'v-end': flex-end, |
| 87 | + 'v-baseline': baseline, |
| 88 | + 'v-stretch': stretch |
| 89 | + ), |
| 90 | + horizontal: ( |
| 91 | + 'h-center': center, |
| 92 | + 'h-start': flex-start, |
| 93 | + 'h-end': flex-end, |
| 94 | + 'h-between': space-between, |
| 95 | + 'h-around': space-around, |
| 96 | + 'h-evenly': space-evenly, |
| 97 | + 'h-stretch': stretch |
| 98 | + ) |
| 99 | + ); |
| 100 | + |
101 | 101 | @each $arg in $args {
|
102 |
| - @if list.index($displayValues, $arg) { |
| 102 | + @if (list.index($layouts, $arg)) { |
103 | 103 | display: $arg;
|
104 | 104 | }
|
105 | 105 |
|
106 |
| - @if list.index($overflowValues, $arg) { |
107 |
| - overflow: $arg; |
108 |
| - } |
109 |
| - |
110 |
| - @if (meta.type-of($arg) == 'number') { |
111 |
| - opacity: $arg; |
| 106 | + @if (map.get($spacing, $arg)) { |
| 107 | + gap: map.get($spacing, $arg); |
112 | 108 | }
|
113 |
| - } |
114 |
| -} |
115 |
| - |
116 |
| -@mixin layer($stack: 'default') { |
117 |
| - z-index: #{map.get($layers, $stack)}; |
118 |
| -} |
119 |
| - |
120 |
| -@mixin size($args...) { |
121 |
| - $singlePrefix: string.slice(list.nth(#{$args}, 1), 1, 1); |
122 |
| - $isSingle: list.length($args) == 1 |
123 |
| - and $singlePrefix != 'w' |
124 |
| - and $singlePrefix != 'h'; |
125 |
| - |
126 |
| - @if ($isSingle) { |
127 |
| - width: $args; |
128 |
| - height: $args; |
129 |
| - } @else { |
130 |
| - @each $arg in $args { |
131 |
| - @if (meta.type-of($arg) == string) { |
132 |
| - $prefix: string.slice($arg, 1, 1); |
133 |
| - $value: string.slice($arg, 2, -1); |
134 | 109 |
|
135 |
| - @if ($prefix == 'w') { |
136 |
| - width: string.unquote($value); |
137 |
| - } |
138 |
| - |
139 |
| - @if ($prefix == 'h') { |
140 |
| - height: string.unquote($value); |
141 |
| - } |
142 |
| - } @else { |
143 |
| - @if (index($args, $arg) == 1) { |
144 |
| - width: $arg; |
145 |
| - } |
| 110 | + @if (meta.type-of($arg) == 'string') { |
| 111 | + @if (string.index($arg, 'v-')) { |
| 112 | + align-items: map.get(map.get($alignments, vertical), $arg) |
| 113 | + } |
146 | 114 |
|
147 |
| - @if (index($args, $arg) == 2) { |
148 |
| - height: $arg; |
149 |
| - } |
| 115 | + @if (string.index($arg, 'h-')) { |
| 116 | + justify-content: map.get(map.get($alignments, horizontal), $arg) |
150 | 117 | }
|
151 | 118 | }
|
152 |
| - } |
153 |
| -} |
154 |
| - |
155 |
| -@mixin typography($args...) { |
156 |
| - @each $arg in $args { |
157 |
| - $color: map.get($colorPalette, '#{$arg}'); |
158 |
| - $type: map.get($fontTypes, '#{$arg}'); |
159 |
| - $size: map.get($fontSizes, '#{$arg}'); |
160 |
| - $height: map.get($lineHeights, '#{$arg}'); |
161 |
| - $decoration: map.get($decorations, '#{$arg}'); |
162 |
| - |
163 |
| - @if ($color) { |
164 |
| - color: $color; |
165 |
| - } |
166 |
| - |
167 |
| - @if ($type) { |
168 |
| - font-family: $type; |
169 |
| - } |
170 | 119 |
|
171 |
| - @if ($size) { |
172 |
| - font-size: $size; |
| 120 | + @if ($arg == 'center') { |
| 121 | + align-items: center; |
| 122 | + justify-content: center; |
173 | 123 | }
|
174 | 124 |
|
175 |
| - @if list.index($fontWeights, $arg) { |
176 |
| - font-weight: $arg; |
| 125 | + @if (list.index($flexDirectionValues, $arg)) { |
| 126 | + flex-direction: $arg; |
177 | 127 | }
|
178 | 128 |
|
179 |
| - @if list.index($textAlignValues, $arg) { |
180 |
| - text-align: $arg; |
| 129 | + @if (meta.type-of($arg) == 'number') { |
| 130 | + grid-template-columns: repeat($arg, minmax(0, 1fr)); |
181 | 131 | }
|
182 | 132 |
|
183 |
| - @if ($decoration) { |
184 |
| - text-decoration: $decoration; |
| 133 | + @if (list.index($flexWrapValues, $arg)) { |
| 134 | + flex-wrap: $arg; |
185 | 135 | }
|
| 136 | + } |
| 137 | +} |
186 | 138 |
|
187 |
| - @if ($height or (meta.type-of($arg) == 'number' and $arg < 100)) { |
188 |
| - line-height: $height or $arg; |
189 |
| - } |
| 139 | +@mixin media($breakpoint: 'xs') { |
| 140 | + @media (min-width: #{map.get($breakpoints, $breakpoint)}) { |
| 141 | + @content; |
190 | 142 | }
|
191 | 143 | }
|
192 | 144 |
|
|
230 | 182 | }
|
231 | 183 | }
|
232 | 184 |
|
| 185 | +@mixin size($args...) { |
| 186 | + $singlePrefix: string.slice(list.nth(#{$args}, 1), 1, 1); |
| 187 | + $isSingle: list.length($args) == 1 |
| 188 | + and $singlePrefix != 'w' |
| 189 | + and $singlePrefix != 'h'; |
| 190 | + |
| 191 | + @if ($isSingle) { |
| 192 | + width: $args; |
| 193 | + height: $args; |
| 194 | + } @else { |
| 195 | + @each $arg in $args { |
| 196 | + @if (meta.type-of($arg) == string) { |
| 197 | + $prefix: string.slice($arg, 1, 1); |
| 198 | + $value: string.slice($arg, 2, -1); |
| 199 | + |
| 200 | + @if ($prefix == 'w') { |
| 201 | + width: string.unquote($value); |
| 202 | + } |
| 203 | + |
| 204 | + @if ($prefix == 'h') { |
| 205 | + height: string.unquote($value); |
| 206 | + } |
| 207 | + } @else { |
| 208 | + @if (index($args, $arg) == 1) { |
| 209 | + width: $arg; |
| 210 | + } |
| 211 | + |
| 212 | + @if (index($args, $arg) == 2) { |
| 213 | + height: $arg; |
| 214 | + } |
| 215 | + } |
| 216 | + } |
| 217 | + } |
| 218 | +} |
| 219 | + |
233 | 220 | @mixin spacing($args...) {
|
234 | 221 | $margin: (0 0 0 0);
|
235 | 222 | $padding: (0 0 0 0);
|
|
342 | 329 | }
|
343 | 330 | }
|
344 | 331 |
|
345 |
| -@mixin layout($args...) { |
346 |
| - $layouts: (flex, inline-flex, grid, inline-grid); |
347 |
| - $alignments: ( |
348 |
| - vertical: ( |
349 |
| - 'v-center': center, |
350 |
| - 'v-start': flex-start, |
351 |
| - 'v-end': flex-end, |
352 |
| - 'v-baseline': baseline, |
353 |
| - 'v-stretch': stretch |
354 |
| - ), |
355 |
| - horizontal: ( |
356 |
| - 'h-center': center, |
357 |
| - 'h-start': flex-start, |
358 |
| - 'h-end': flex-end, |
359 |
| - 'h-between': space-between, |
360 |
| - 'h-around': space-around, |
361 |
| - 'h-evenly': space-evenly, |
362 |
| - 'h-stretch': stretch |
363 |
| - ) |
364 |
| - ); |
| 332 | +@mixin transition($args...) { |
| 333 | + $property: all; |
| 334 | + $speed: .3s; |
365 | 335 |
|
366 | 336 | @each $arg in $args {
|
367 |
| - @if (list.index($layouts, $arg)) { |
368 |
| - display: $arg; |
| 337 | + @if (meta.type-of($arg) == 'number') { |
| 338 | + $speed: $arg; |
| 339 | + } @else { |
| 340 | + $property: $arg; |
369 | 341 | }
|
| 342 | + } |
370 | 343 |
|
371 |
| - @if (map.get($spacing, $arg)) { |
372 |
| - gap: map.get($spacing, $arg); |
| 344 | + transition: $property $speed cubic-bezier(0.4, 0.0, 0.2, 1); |
| 345 | +} |
| 346 | + |
| 347 | +@mixin typography($args...) { |
| 348 | + @each $arg in $args { |
| 349 | + $color: map.get($colorPalette, '#{$arg}'); |
| 350 | + $type: map.get($fontTypes, '#{$arg}'); |
| 351 | + $size: map.get($fontSizes, '#{$arg}'); |
| 352 | + $height: map.get($lineHeights, '#{$arg}'); |
| 353 | + $decoration: map.get($decorations, '#{$arg}'); |
| 354 | + |
| 355 | + @if ($color) { |
| 356 | + color: $color; |
373 | 357 | }
|
374 | 358 |
|
375 |
| - @if (meta.type-of($arg) == 'string') { |
376 |
| - @if (string.index($arg, 'v-')) { |
377 |
| - align-items: map.get(map.get($alignments, vertical), $arg) |
378 |
| - } |
379 |
| - |
380 |
| - @if (string.index($arg, 'h-')) { |
381 |
| - justify-content: map.get(map.get($alignments, horizontal), $arg) |
382 |
| - } |
| 359 | + @if ($type) { |
| 360 | + font-family: $type; |
383 | 361 | }
|
384 | 362 |
|
385 |
| - @if ($arg == 'center') { |
386 |
| - align-items: center; |
387 |
| - justify-content: center; |
| 363 | + @if ($size) { |
| 364 | + font-size: $size; |
388 | 365 | }
|
389 | 366 |
|
390 |
| - @if (list.index($flexDirectionValues, $arg)) { |
391 |
| - flex-direction: $arg; |
| 367 | + @if list.index($fontWeights, $arg) { |
| 368 | + font-weight: $arg; |
392 | 369 | }
|
393 | 370 |
|
394 |
| - @if (meta.type-of($arg) == 'number') { |
395 |
| - grid-template-columns: repeat($arg, minmax(0, 1fr)); |
| 371 | + @if list.index($textAlignValues, $arg) { |
| 372 | + text-align: $arg; |
396 | 373 | }
|
397 | 374 |
|
398 |
| - @if (list.index($flexWrapValues, $arg)) { |
399 |
| - flex-wrap: $arg; |
| 375 | + @if ($decoration) { |
| 376 | + text-decoration: $decoration; |
| 377 | + } |
| 378 | + |
| 379 | + @if ($height or (meta.type-of($arg) == 'number' and $arg < 100)) { |
| 380 | + line-height: $height or $arg; |
| 381 | + } |
| 382 | + } |
| 383 | +} |
| 384 | + |
| 385 | +@mixin visibility($args...) { |
| 386 | + @each $arg in $args { |
| 387 | + @if list.index($displayValues, $arg) { |
| 388 | + display: $arg; |
| 389 | + } |
| 390 | + |
| 391 | + @if list.index($overflowValues, $arg) { |
| 392 | + overflow: $arg; |
| 393 | + } |
| 394 | + |
| 395 | + @if (meta.type-of($arg) == 'number') { |
| 396 | + opacity: $arg; |
400 | 397 | }
|
401 | 398 | }
|
402 | 399 | }
|
0 commit comments