Skip to content

Commit

Permalink
refactor(name.adjust-multiple()): check whether color name were adjus…
Browse files Browse the repository at this point in the history
…ted.
  • Loading branch information
sciborrudnicki committed Dec 5, 2023
1 parent 6a4054e commit e5fc8d6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions color/functions/name/_name.adjust-multiple.function.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,26 @@
// Prepare variables.
$adjustment: list.last($names);
$names: list.remove-nth($names, -1);
$adjusted: ();

// Adjustments.
$result: ();
$index: 1;
@each $adjust in if(type-of($adjustment) == map, ($adjustment,), $adjustment) {
@if type-of($adjustment) == map {
// FEATURE: Adjust all names.
@if list.index(map.keys($adjust), hue, saturation, lightness, alpha) {
@if list.index(map.keys($adjust), hue, saturation, lightness, alpha) and not list.index($adjusted, $i) {
@for $i from 1 through list.length($names) {
$names: list.set-nth($names, $i, adjust(list.nth($names, $i), $adjust));
$adjusted: list.append($adjusted, $i);
}
} @else {
// FEATURE: Adjust names by color name.
@each $adjusted-name, $adjust in $adjust {
@for $i from 1 through list.length($names) {
@if index(list.nth($names, $i), $adjusted-name) {
@if index(list.nth($names, $i), $adjusted-name) and not list.index($adjusted, $i) {
$names: list.set-nth($names, $i, adjust(list.nth($names, $i), $adjust));
$adjusted: list.append($adjusted, $i);
}
}
}
Expand All @@ -41,12 +44,14 @@
// FEATURE: Adjustments as list.
@for $i from 1 through list.length($names) {
@if map.get($adjust, name) {
@if index(list.nth($names, $i), map.get($adjust, name)) {
@if index(list.nth($names, $i), map.get($adjust, name)) and not list.index($adjusted, $i) {
$names: list.set-nth($names, $i, adjust(list.nth($names, $i), $adjust));
$adjusted: list.append($adjusted, $i);
}
} @else {
@if $i == $index {
@if $i == $index and not list.index($adjusted, $i) {
$names: list.set-nth($names, $i, adjust(list.nth($names, $i), $adjust));
$adjusted: list.append($adjusted, $i);
}
}
}
Expand Down

0 comments on commit e5fc8d6

Please sign in to comment.