Duplicate Sass variables as CSS variables #422
Replies: 3 comments
-
Original issue thread: https://github.iu.edu/UITS/rivet-source/issues/246 |
Beta Was this translation helpful? Give feedback.
-
Here's another solution to integrating token-izing design system variables into CSS. Use the Why you should use CSS env(), April 5, 2019 |
Beta Was this translation helpful? Give feedback.
-
Was thinking about the breakpoints that are defined in Rivet. It would be nice if there was some way to customize breakpoints. The breakpoints in the Rivet Header is not as tight as I'd like it, when there isn't much content in it. We can't use CSS variables in media queries, but we will eventually be able to have custom Change the width of the viewport, to see the "header" change size and color. There are three breakpoints. And one of them is overwritten by the "implementation" of the library. Read CSS comments for more. |
Beta Was this translation helpful? Give feedback.
-
Currently, all style variables are declared as Sass variables.
https://github.iu.edu/UITS/rivet-source/blob/develop/src/sass/core/_variables.scss
This works well for Rivet itself. It works fine if you're importing Rivet into a project that also uses Sass. But if you're using Less or no preprocessor or don't want to compile Rivet, there's no way to take advantage of these definitions. Instead, offer the variables also as CSS variables. There's good browser support for any browser over the last 1.5 years. If projects are still supporting IE, they won't be able to use CSS variables, but for everyone else, this would be a big advantage. It would minimally really help prototyping. And for those not wanting to use it, it is ignored.
Relevant articles:
To maintain backwards compatibility, Rivet should still use Sass variables internally. Just dually offer CSS variables. Given these would be global variables, it would be best to prefix them with
rvt-
. For example, this is how you could extend_variables.scss
:Beta Was this translation helpful? Give feedback.
All reactions