-
-
Notifications
You must be signed in to change notification settings - Fork 79k
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
Updated utility API (css-vars utils and new bg/color utils), plus new root CSS variables #34100
Conversation
What are your thoughts (or plans) about using HSL as suggested in this comment #32424 (comment)? While they cannot replace SCSS |
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 like the way you did this!
A bit worried about file size and mostly how people will use this, but that's definitely a good step forward :)
1126322
to
aa1c14e
Compare
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.
A few typos but the overall looks fine 🎉
- Adds new functions to generate additional Sass maps - Adds new root variables for rgb() versions of our theme colors, plus a few extras - Adds ability to change the alpha transparency of text color and background color utilities with new utilities, inline styles, or local CSS var - Updates documentation for color and background-color utilities pages - Deprecates .text-black-50 and .text-white-50 since those (and additional transparency levels) can be generated on the fly Change approach slightly to prevent cascade
- Adds grayscale colors - Adds root and body variables Note that some Sass variables default to `null`, so as we generate and use the CSS variable, we'll be potentially adding some lines of code.
Co-Authored-By: Gaël Poupard <[email protected]>
Consider this a bit of an integration branch for now while work on v5.0.2 continues. I'm using this to consolidate efforts across a handful of PRs.
Changes
cda10d6: Updates
.text-{color}
and.bg-{color}
utilities to use CSS variables.Both
.text-{color}
and.bg-{color}
utilities are now powered by CSS variables. For example, we use the new--bs-primary-rgb: 13, 110, 253
and--bs-text-opacity
(with no default value, but a fallback of1
) in.text-primary
where the new computed style iscolor: rgba(13, 110, 253, 1)
.We generate these new RGB variables with some new functions that convert hex values to RGB and that generate new Sass maps based on our
$theme-colors
map. These new maps are now used to generate our utilities for textcolor
andbackground-color
and include new options for.{text|bg}-black
,.{text|bg}-white
, and.{text|bg}-body
.The utility API has been updated to include a new
css-var
boolean option. When set totrue
, it generates only local CSS variables using the API'sclass
and individual values. This is how we've added our new.text-opacity-*
and.bg-opacity-*
utilities. Add these new classes alonside.text-{color}
and.bg-{color}
utilities to set their alpha transparency on the fly.This also deprecates
.text-black-50
and.text-white-50
since we can create those on the fly now.Fixes V5 Utilities : Add Border Opacity #33320. Fixes Utilities like .text-light should use the root variables defined (in this case, --bs-light) #33985.
c754e3e: Adds additional
:root
CSS variables for all our shades of gray and some$body-
Sass variables.Previously our
:root
CSS variables only included our$colors
and$theme-colors
. Now they also include$grays
. We've also added new CSS variables for common<body>
styles with default values set by their Sass variable counterparts (e.g.,--#{$variable-prefix}body-color: #{$body-color};
).