From 1e801cd3594c41cc4c4314875b622baed68b4453 Mon Sep 17 00:00:00 2001 From: Sebastian Chwastek Date: Sun, 24 Sep 2017 19:00:00 +0200 Subject: [PATCH 1/2] use `abs()` to get the absolute `$level` value Improve `theme-color-level()` using `abs()`. `abs()` gets the absolute value of `$level`. That way, `if/else` statement can be completely eliminated. --- scss/_functions.scss | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/scss/_functions.scss b/scss/_functions.scss index a63680aa5ca3..c251e4a6e767 100644 --- a/scss/_functions.scss +++ b/scss/_functions.scss @@ -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); - - @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); - } + $level: abs($level); + + @return mix($color-base, $color, $level * $theme-color-interval); } From d9010d67cc9cce93476636b4c76cda7921c8947b Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 26 Sep 2017 00:15:40 +0300 Subject: [PATCH 2/2] Update _functions.scss --- scss/_functions.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scss/_functions.scss b/scss/_functions.scss index c251e4a6e767..5d43b57087b7 100644 --- a/scss/_functions.scss +++ b/scss/_functions.scss @@ -81,6 +81,6 @@ $color: theme-color($color-name); $color-base: if($level > 0, #000, #fff); $level: abs($level); - + @return mix($color-base, $color, $level * $theme-color-interval); }