Skip to content

Commit 30bdf0a

Browse files
refactor(indicator.remove()): remove indicator from string.
1 parent 5d095fe commit 30bdf0a

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

variant/indicator/_indicator.remove.function.scss

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,31 @@
1212
// @returns
1313
@function remove($item, $indicator) {
1414
$i: 1;
15-
$item: remove.value($item, '+');
16-
@each $value in $item {
17-
@if type-of($value) == string {
18-
$item: list.set-nth($item, $i, string.replace(#{$value}, all, $indicator, ''));
19-
} @else if type-of($value) == list {
20-
$j: 1;
21-
@each $v in $value {
22-
$value: list.set-nth($value, $j, string.replace(#{$v}, all, $indicator, ''));
23-
$j: $j + 1;
15+
@if type-of($item) == string {
16+
@if string.index($item, $indicator) {
17+
$item: string.slice($item, 2);
18+
}
19+
} @else {
20+
@each $value in $item {
21+
@if type-of($value) == string {
22+
$item: list.set-nth($item, $i, string.replace(#{$value}, all, $indicator, ''));
23+
} @else if type-of($value) == list {
24+
$j: 1;
25+
@each $v in $value {
26+
$value: list.set-nth($value, $j, string.replace(#{$v}, all, $indicator, ''));
27+
$j: $j + 1;
28+
}
29+
30+
$item: list.set-nth($item, $i, $value);
2431
}
2532

26-
$item: list.set-nth($item, $i, $value);
33+
$i: $i + 1;
2734
}
28-
29-
$i: $i + 1;
3035
}
3136
@return $item;
3237
}
38+
39+
// Examples.
40+
// @debug remove(+background, '+');
41+
// @debug remove(+bg, '+');
42+
// @debug type-of(remove(+bg, '+'));

0 commit comments

Comments
 (0)