`abs()` gets the absolute value of `$level`.
That way, `if/else` statement can be completely eliminated.
@function theme-color-level($color-name: "primary", $level: 0) {
$color: theme-color($color-name);
$color-base: if($level > 0, #000, #fff);
+ $level: abs($level);
- @if $level < 0 {
- // Lighter values need a quick double negative for the Sass math to work
- @return mix($color-base, $color, $level * -1 * $theme-color-interval);
- } @else {
- @return mix($color-base, $color, $level * $theme-color-interval);
- }
+ @return mix($color-base, $color, $level * $theme-color-interval);
}