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 PR is more an issue than a PR but the Netlify deployment will help.
Before
Some recent PRs created
_map.scss
and so$utilities-text-colors
,$utilities-bg-colors
and$utilities-border-colors
. This new system doesn't contain any regressions for a Bootstrap user but we have spotted a limitation.Let's take a look at how the border colors were created:
At that time it was possible to change the value associated with "white". For example you could do the following and the
.border-white
would display a yellow border:Now
The new system in
_maps.scss
is a little bit different but seems very close:But if you try to modify the value associated with "white", it doesn't do anything:
It can be seen here where I try to change to "white" value to have a yellow background displayed with a
bg-white
. It stays white because ofvar(--bs-white-rgb)
.Why?
The explanation seems to come from
rgba-css-var
that in fact only uses the key (in fact--bs-{key-name}-rgb
) and not the value.It means that you could do:
Only matters the fact that the key is added to the
map-merge
.It can be seen here where I set a
null
value to the "body" key and it still works;var(--bs-body-bg-rgb)
is used.Impact and bypassing
In Boosted, we used this possibility to change the value for a given key. In this PR, one of the solution find to retrieve this same behavior was to add an extra parameter to
rgba-css-var
to provide the modified value:The result can be seen here where
.border-white
displays a yellow border.It is kinda ugly and it doesn't work combined to the opacities.
Other solutions
@louismaximepiton tried 2 other different approaches.
First solution
This solution adds more CSS variables; maybe too much (bundle will be bigger).
To try it, please uncomment
scss/_functions.scss
andscss_root.scss
what is between "First solution start" and "Solutions proposal end".Second solution
This version gets rid of
to-rgb
s in_maps.scss
and use the value but we don't like this version too much because CSS variables wouldn't be used anymore.To try it, please uncomment
scss/_functions.scss
andscss/_maps.scss
what is between "Second solution start" and "Solutions proposal end".