Skip to content

Commit

Permalink
refactor(variant.create()): retrieve color, and use `no-property-name…
Browse files Browse the repository at this point in the history
…` among with `name` in `$type` equal to `color`.
  • Loading branch information
sciborrudnicki committed Jan 2, 2024
1 parent f4a346a commit 5bfe892
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions variant/_variant.create.function.scss
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
// Sass.
@use 'sass:list';

// Modules.
@use '../list';
@use '../map';
@use '../selector';

// Functions.
@use '../color/name/name.retrieve.function' as *;
@use '../color/name/name.retrieve.function' as color-name-retrieve;
@use '../list/has/has.list.function' as list-has-list;
@use '../list/list.nth.function' as list-nth;
@use '../list/remove/remove.list.function' as list-remove-list;
@use '../list/remove/remove.value.function' as list-remove-value;

// Status: TODO:
// Category: Property variant
// The `variant.create()` creates a variant built from `$value`.
// @param `$value` A list or string type to create a variant.
// @param `$modifier`
// @param `$type`
// @returns The returned value is a variant of map type where (class: value).
@function create($value, $modifier: null, $type: null) {
$result: ();
Expand All @@ -34,17 +40,18 @@
$key: $value;
@if type-of($value) == list and list.length($value) > 0 {
// Remove !important.
$key: list.remove-value($key, !important);
$key: list-remove-value.value($key, !important);

// FEATURE: Color variant.
@if $type == color {
$key: map.get(retrieve($key), name);
$color: color-name-retrieve.retrieve($key);
$key: map.get($color, no-property-name) or map.get($color, name);
} @else {
// FEATURE: Check key.
@if list.separator($key) == comma {
$key: list.nth($key, 1);
} @else if list.separator($key) == space and list.has-list($key) {
$key: list.remove-list($key);
$key: list-nth.nth($key, 1);
} @else if list.separator($key) == space and list-has-list.has-list($key) {
$key: list-remove-list.list($key);
}
}
}
Expand Down

0 comments on commit 5bfe892

Please sign in to comment.