We could try to use the same approach with createTheme builder, to generate a CSS properties names and theme class name.
Let's imagine that vars.color.brand will return --optionalProjectPrefix-color-brand or var(--optionalProjectPrefix-color-brand). Now we can bind a values defined in TS files to a values in CSS theme, because CSS properties names generates automatically and in case we will try use non defined values, a TypeScript compiller may catch us and generate error.
To use this approach we have to provide JS variables into CSS, so we have to use any CSS-in-JS library. We could use a https://github.com/callstack/linaria with zero runtime. We also may generate theme class with this tool.
The problem with derived styles
Not clear how to create derived styles for UI components.
We may want to have a button with a background color based on accent color but with changed HUE. How to implement it?
We need access to a accent color, then change value of this color. How to do it?
Currently we use too complex theming approach. To update theme, user must do:
The problems
The potential solutions
CSS in JS way
https://github.com/vanilla-extract-css/vanilla-extract project uses this approach to define styles
We could try to use the same approach with
createTheme
builder, to generate a CSS properties names and theme class name.Let's imagine that
vars.color.brand
will return--optionalProjectPrefix-color-brand
orvar(--optionalProjectPrefix-color-brand)
. Now we can bind a values defined in TS files to a values in CSS theme, because CSS properties names generates automatically and in case we will try use non defined values, a TypeScript compiller may catch us and generate error.To use this approach we have to provide JS variables into CSS, so we have to use any CSS-in-JS library. We could use a https://github.com/callstack/linaria with zero runtime. We also may generate theme class with this tool.
The problem with derived styles
Not clear how to create derived styles for UI components.
We may want to have a button with a background color based on accent color but with changed HUE. How to implement it?