Skip to content

Commit

Permalink
refactor(indicator.remove()): remove indicator from string.
Browse files Browse the repository at this point in the history
  • Loading branch information
sciborrudnicki committed Nov 25, 2023
1 parent 5d095fe commit 30bdf0a
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions variant/indicator/_indicator.remove.function.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,31 @@
// @returns
@function remove($item, $indicator) {
$i: 1;
$item: remove.value($item, '+');
@each $value in $item {
@if type-of($value) == string {
$item: list.set-nth($item, $i, string.replace(#{$value}, all, $indicator, ''));
} @else if type-of($value) == list {
$j: 1;
@each $v in $value {
$value: list.set-nth($value, $j, string.replace(#{$v}, all, $indicator, ''));
$j: $j + 1;
@if type-of($item) == string {
@if string.index($item, $indicator) {
$item: string.slice($item, 2);
}
} @else {
@each $value in $item {
@if type-of($value) == string {
$item: list.set-nth($item, $i, string.replace(#{$value}, all, $indicator, ''));
} @else if type-of($value) == list {
$j: 1;
@each $v in $value {
$value: list.set-nth($value, $j, string.replace(#{$v}, all, $indicator, ''));
$j: $j + 1;
}

$item: list.set-nth($item, $i, $value);
}

$item: list.set-nth($item, $i, $value);
$i: $i + 1;
}

$i: $i + 1;
}
@return $item;
}

// Examples.
// @debug remove(+background, '+');
// @debug remove(+bg, '+');
// @debug type-of(remove(+bg, '+'));

0 comments on commit 30bdf0a

Please sign in to comment.