mirror of
https://github.com/twbs/bootstrap.git
synced 2024-12-01 13:24:25 +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:
parent
f615f372e5
commit
17fd2c9f84
@ -80,11 +80,7 @@
|
|||||||
@function theme-color-level($color-name: "primary", $level: 0) {
|
@function theme-color-level($color-name: "primary", $level: 0) {
|
||||||
$color: theme-color($color-name);
|
$color: theme-color($color-name);
|
||||||
$color-base: if($level > 0, #000, #fff);
|
$color-base: if($level > 0, #000, #fff);
|
||||||
|
$level: abs($level);
|
||||||
|
|
||||||
@if $level < 0 {
|
@return mix($color-base, $color, $level * $theme-color-interval);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user