From 800dc309ba5c23dee5bb136670b6c69cb5ef46d0 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Fri, 15 Nov 2019 14:44:19 +0100 Subject: [PATCH] feat(palette): separate text coloring function to a new function --- scss/_palette.scss | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scss/_palette.scss b/scss/_palette.scss index 57b0732..11dcc1f 100644 --- a/scss/_palette.scss +++ b/scss/_palette.scss @@ -33,6 +33,14 @@ $whiteness_value: 0.8; @return $luminance } +@function getTextColorFromBackground($background-color, $light-color, $dark-color) { + @if (luminance($background-color ) < 255 * $whiteness_value) { + @return $light-color; + } @else { + @return $dark-color; + } +} + $color-primary: get-color("primary"); $color-secondary: get-color("secondary"); $color-warning: get-color("warning"); @@ -50,11 +58,7 @@ $color-mark: get-color("yellow"); @mixin background-color($background-color, $light-color, $dark-color) { background-color: $background-color!important; - @if (luminance($background-color ) < 255 * $whiteness_value) { - color: $light-color; - } @else { - color: $dark-color; - } + color: getTextColorFromBackground($background-color, $light-color, $dark-color); } .text {