Skip to content

Commit ce0cdc4

Browse files
feat(color.name-indicator-remove()): remove indicator or multiple indicators from color name.
1 parent b5679c6 commit ce0cdc4

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Sass.
2+
@use 'sass:list';
3+
@use 'sass:map';
4+
5+
// Functions.
6+
@use '../../../list/list.indexes.function' as list-indexes;
7+
@use '../../../list/list.nth.function' as list-nth;
8+
@use '../../../list/remove/remove.nth.function' as list-remove-nth;
9+
@use '../adjustment/adjustment.has.function';
10+
11+
// Status: DONE
12+
// The `color.indicator-remove()` function.
13+
// @param `$color`
14+
// @param `$indicator`
15+
// @arbitrary `$indicators...`
16+
// @returns
17+
@function remove($color, $indicator, $indicators...) {
18+
@if adjustment.has($color) {
19+
$name: list-remove-nth.nth(
20+
list-nth.nth($color, 1),
21+
list-indexes.indexes(list-nth.nth($color, 1), all, '~=', $indicator, $indicators...)
22+
);
23+
@return list.set-nth($color, 1, $name);
24+
}
25+
@return list-remove-nth.nth($color, list-indexes.indexes($color, all, '~=', $indicator, $indicators...)...);
26+
}
27+
28+
// Examples.
29+
// @debug remove(primary dark ':background', ':background'); // primary dark
30+
// @debug remove(primary dark ':color', ':color'); // primary dark
31+
32+
// multiple
33+
// @debug remove(primary dark ':color', ':color', ':background'); // primary dark
34+
// @debug remove(primary dark ':color', ':'); // primary dark
35+
36+
// adjustment
37+
// @debug remove((primary dark ':color', 5%), ':'); // primary dark, 5%

0 commit comments

Comments
 (0)