Skip to content

Commit 5bfe892

Browse files
refactor(variant.create()): retrieve color, and use no-property-name among with name in $type equal to color.
1 parent f4a346a commit 5bfe892

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

variant/_variant.create.function.scss

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1+
// Sass.
2+
@use 'sass:list';
3+
14
// Modules.
2-
@use '../list';
35
@use '../map';
4-
@use '../selector';
56

67
// Functions.
7-
@use '../color/name/name.retrieve.function' as *;
8+
@use '../color/name/name.retrieve.function' as color-name-retrieve;
9+
@use '../list/has/has.list.function' as list-has-list;
10+
@use '../list/list.nth.function' as list-nth;
11+
@use '../list/remove/remove.list.function' as list-remove-list;
12+
@use '../list/remove/remove.value.function' as list-remove-value;
813

914
// Status: TODO:
1015
// Category: Property variant
1116
// The `variant.create()` creates a variant built from `$value`.
1217
// @param `$value` A list or string type to create a variant.
1318
// @param `$modifier`
19+
// @param `$type`
1420
// @returns The returned value is a variant of map type where (class: value).
1521
@function create($value, $modifier: null, $type: null) {
1622
$result: ();
@@ -34,17 +40,18 @@
3440
$key: $value;
3541
@if type-of($value) == list and list.length($value) > 0 {
3642
// Remove !important.
37-
$key: list.remove-value($key, !important);
43+
$key: list-remove-value.value($key, !important);
3844

3945
// FEATURE: Color variant.
4046
@if $type == color {
41-
$key: map.get(retrieve($key), name);
47+
$color: color-name-retrieve.retrieve($key);
48+
$key: map.get($color, no-property-name) or map.get($color, name);
4249
} @else {
4350
// FEATURE: Check key.
4451
@if list.separator($key) == comma {
45-
$key: list.nth($key, 1);
46-
} @else if list.separator($key) == space and list.has-list($key) {
47-
$key: list.remove-list($key);
52+
$key: list-nth.nth($key, 1);
53+
} @else if list.separator($key) == space and list-has-list.has-list($key) {
54+
$key: list-remove-list.list($key);
4855
}
4956
}
5057
}

0 commit comments

Comments
 (0)