-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(palette.delete()): add function to delete by palette name, varia…
…nt class and its colors from palettes.
- Loading branch information
1 parent
83291f6
commit 871103c
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Sass. | ||
@use 'sass:list'; | ||
|
||
// Functions. | ||
@use '../../map/map.remove.function'; | ||
|
||
// Module functions. | ||
@use '../name/name.index.function'; | ||
@use 'color/color.remove.function'; | ||
|
||
// Status: DONE | ||
// The `color.palette-delete()` or `palette.delete()` function. | ||
// @param `$palette` Color palettes of `map` type. | ||
// @param `$name` Palette name or its part of `string` or `list` type. | ||
// @param `$class` Variant class name or its part of `string` or `list` type. | ||
// @param `$separator` Separator between `$colors`. | ||
// @arbitrary `$colors...` Colors to remove from palette variant. | ||
// @returns The returned value is `$palette`. | ||
@function delete($palette, $name, $class: null, $separator: null, $colors...) { | ||
// FEATURE: Remove colors. | ||
@if list.length($colors) > 0 { | ||
$palette: color.remove($palette, $name, $class, $separator, $colors...); | ||
} @else { | ||
@each $palette-name, $variant in $palette { | ||
@if name.index($palette-name, $name) { | ||
// FEATURE: Remove variant. | ||
@if $class { | ||
@each $variant-class, $variant-color in $variant { | ||
@if name.index($variant-class, $class) { | ||
$palette: map.remove($palette, ($name, $class)); | ||
} | ||
} | ||
} @else { | ||
// FEATURE: Remove palette. | ||
$palette: map.remove($palette, $name); | ||
} | ||
} | ||
} | ||
} | ||
@return $palette; | ||
} | ||
|
||
// Alias name for `delete`. | ||
// @function remove($palette, $name, $class: null, $separator: null, $colors...) { | ||
// @return delete($palette, $name, $class, $separator, $colors...); | ||
// } |