0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-11-29 11:24:18 +01:00

Improve theme-color-level() using abs() (#24074)

`abs()` gets the absolute value of `$level`.
That way, `if/else` statement can be completely eliminated.
This commit is contained in:
schwastek 2017-09-26 14:05:59 +02:00 committed by XhmikosR
parent f615f372e5
commit 17fd2c9f84

View File

@ -80,11 +80,7 @@
@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);
}