Skip to content

Commit 17fd2c9

Browse files
schwastekXhmikosR
authored andcommitted
Improve theme-color-level() using abs() (#24074)
`abs()` gets the absolute value of `$level`. That way, `if/else` statement can be completely eliminated.
1 parent f615f37 commit 17fd2c9

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

scss/_functions.scss

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,7 @@
8080
@function theme-color-level($color-name: "primary", $level: 0) {
8181
$color: theme-color($color-name);
8282
$color-base: if($level > 0, #000, #fff);
83+
$level: abs($level);
8384

84-
@if $level < 0 {
85-
// Lighter values need a quick double negative for the Sass math to work
86-
@return mix($color-base, $color, $level * -1 * $theme-color-interval);
87-
} @else {
88-
@return mix($color-base, $color, $level * $theme-color-interval);
89-
}
85+
@return mix($color-base, $color, $level * $theme-color-interval);
9086
}

0 commit comments

Comments
 (0)