Derive ‘-invert’ sass variables from primary colors (Fixes #706) #2594
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a bugfix. Fixes #706.
Proposed solution
When overriding the primary color variables, the corresponding
-invert
variables do not get updated since these are derived from their parent's base color, like so:$primary: $turquoise
,$primary-invert: $turquoise-invert
.Issues arise when attempting to override one of these variables with your own colors, since their corresponding
-invert
variable will still be based on its parent's base color instead of its parent.Since the
-invert
variables are supposed to find an appropriate contrast to its parent color, I think it is better to derive it from its parent variable directly usingfindColorInvert()
.Tradeoffs
This solution can impact any user that overrides variables such as
$primary
without also overriding its corresponding-invert
variable, possibly causing some light text to become dark and vice versa.Testing Done
Tested by setting
$primary
to#fff
inderived-variables.sass
and building the css, resulting in:Compared to what it previously outputted when doing the same thing:
Changelog updated?
Yes.