-
-
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(color.palette-variant-create()): add function from `palette.crea…
…te()` to create variant based on schema.
- Loading branch information
1 parent
6a4c0f3
commit 4d5d2b7
Showing
2 changed files
with
32 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
@forward 'variant.add.function'; | ||
@forward 'variant.create.function'; | ||
@forward 'variant.exists.function'; |
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,31 @@ | ||
// Sass. | ||
@use 'sass:list'; | ||
@use 'sass:map'; | ||
|
||
// Modules. | ||
@use '../../../variant'; | ||
@use '../../name'; | ||
|
||
// Status: DONE | ||
// NOTE: consider adding bracketed adjust | ||
// The `palette.variant-create()` function to create variant from list. | ||
// @param `$palette` | ||
// @param `$name` | ||
// @returns | ||
@function create($palette, $name: null) { | ||
@each $palette-name, $colors in $palette { | ||
$allow: if($name, false, true); | ||
@if type-of($colors) == list or type-of($colors) == string { | ||
@if name.index($palette-name, $name) { | ||
$allow: true; | ||
} | ||
@if $allow { | ||
$palette: map.set($palette, $palette-name, variant.create($colors, $type: color)); | ||
} | ||
} | ||
} | ||
@return $palette; | ||
} | ||
|
||
// Examples. | ||
// @debug create((accent: (accent color, (accent basic dark) 3% 0.5, accent light, accent dark), primary: (color, (basic dark) 3% 0.5, light, dark)), accent); |