Skip to content

Commit 30e19ae

Browse files
refactor(variant.create()): add $type argument to retrieve from color name to set key.
1 parent 6311d52 commit 30e19ae

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

variant/_variant.create.function.scss

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
@use '../map';
44
@use '../selector';
55

6+
// Functions.
7+
@use '../color/functions/name/name.retrieve.function' as *;
8+
69
// Status: DONE
710
// The `variant.create()` creates a variant built from `$value`.
811
// @param `$value` A list or string type to create a variant.
912
// @param `$modifier`
1013
// @returns The returned value is a variant of map type where (class: value).
11-
@function create($value, $modifier: null) {
14+
@function create($value, $modifier: null, $type: null) {
1215
$result: ();
1316
@if type-of($value) == map {
1417
@each $name, $side-variant in $value {
@@ -31,10 +34,17 @@
3134
@if type-of($value) == list {
3235
// Remove !important.
3336
$key: list.remove-value($key, !important);
34-
@if list.separator($key) == comma {
35-
$key: list.nth($key, 1);
36-
} @else if list.separator($key) == space and list.has-list($key) {
37-
$key: list.remove-list($key);
37+
38+
// FEATURE: Color variant.
39+
@if $type == color {
40+
$key: map.get(retrieve($key), name);
41+
} @else {
42+
// FEATURE: Check key.
43+
@if list.separator($key) == comma {
44+
$key: list.nth($key, 1);
45+
} @else if list.separator($key) == space and list.has-list($key) {
46+
$key: list.remove-list($key);
47+
}
3848
}
3949
}
4050

@@ -80,6 +90,8 @@
8090
// @debug create((secondary (color '!important', dark, light)));
8191
// @debug create((secondary (color, (dark, -30%), (light, 60%))));
8292

93+
// @debug create((accent, (color, [(light, 30%), (dark, 50%)], dark, light)));
94+
8395
//
8496
// @debug create((medium: 1px solid red, large: 2px solid blue)); // ((): ((): (medium: 1px solid red)))
8597
// @debug create(((top, right): (medium: 1px solid red, large: 2px solid blue))); // ((): ((top, right): (medium: 1px solid red, large: 2px solid blue)))

0 commit comments

Comments
 (0)