Skip to content

Commit 7699304

Browse files
feat(color/functions): add color.name-adjust() to adjust hsl color in name.
1 parent 788044c commit 7699304

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Modules.
2+
@use '../../list';
3+
@use '../../map';
4+
@use '../../meta';
5+
6+
// Functions.
7+
@use 'color.name.function' as *;
8+
9+
// Status: DONE
10+
// The `color.name-adjust()` function adjusts single/multiple color `$name`.
11+
// @param `$name` The `string` or `list` name to adjust.
12+
// @param `$adjust` The `list` or `map` type to adjust.
13+
// @returns The returned value is a list of adjusted color name(s).
14+
@function name-adjust($name, $adjust) {
15+
$i: 1;
16+
$name: if(list.separator($name) == space, ($name,), $name);
17+
@each $value in $name {
18+
$adjustment: if(meta.type-of($adjust) == map, $adjust, list.nth($adjust, $i));
19+
$name: list.set-nth(
20+
$name,
21+
$i,
22+
name(
23+
$value,
24+
$hue: map.get($adjustment, hue),
25+
$saturation: map.get($adjustment, saturation),
26+
$lightness: map.get($adjustment, lightness),
27+
$alpha: map.get($adjustment, alpha),
28+
)
29+
);
30+
$i: $i + 1;
31+
}
32+
@return $name;
33+
}
34+
35+
// Examples.
36+
// @debug name-adjust(accent test1, (lightness: 3%)); // (accent test1 color, 3%)
37+
// @debug name-adjust(accent test1, ((lightness: 3%),)); // (accent test1 color, 3%)
38+
// @debug name-adjust((accent test1, primary test2, secondary test3), ((lightness: 3%),)); // (accent test1 color, 3%), primary test2 color, secondary test3 color
39+
// @debug name-adjust((accent test1, primary test2, secondary test3), (lightness: 3%)); // (accent test1 color, 3%), (primary test2 color, 3%), (secondary test3 color, 3%)

0 commit comments

Comments
 (0)