-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve theme-color-level() using abs() #24074
Conversation
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
Outdated
@return mix($color-base, $color, $level * $theme-color-interval); | ||
} | ||
$level: abs($level); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains trailing whitespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@schwastek: please fix the lint errors.
/CC @andresgalante |
@XhmikosR I'll build this one and test it out but I can't be definitive about it because I am not great with scss functions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it totally makes sense to use abs
here, but please someone else confirm too.
I've pull @schwastek branch, build it locally and tested changing the themes maps on variables. It works and compiles without errors. As I mention before I can't say for sure, but to me the absolut method makes sense. @schwastek great work! 👍 |
Concerns function
theme-color-level()
in_functions.scss
file.Use internal Sass function
abs()
to get the absolute value of$level
argument.That way,
if/else
statement can be completely eliminated.Screenshot
Both - old and new functions - return the same values.
Test
Check out this pull request locally or reproduce it from scratch:
scripts
section inpackage.json
with:_functions.scss
:_debug.scss
: