]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Improve theme-color-level() using abs() (#24074)
authorschwastek <31923722+schwastek@users.noreply.github.com>
Tue, 26 Sep 2017 12:05:59 +0000 (14:05 +0200)
committerXhmikosR <xhmikosr@gmail.com>
Tue, 26 Sep 2017 12:05:59 +0000 (15:05 +0300)
`abs()` gets the absolute value of `$level`.
That way, `if/else` statement can be completely eliminated.

scss/_functions.scss

index a63680aa5ca38349c7019c80a5cd52b19737cdde..5d43b57087b7e73ac669a6d843b67d90aebab81e 100644 (file)
 @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);
 }