-
-
Notifications
You must be signed in to change notification settings - Fork 335
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
Suggested implementation of themes refactoring #1340
base: main
Are you sure you want to change the base?
Suggested implementation of themes refactoring #1340
Conversation
9d33bcc
to
e65a3f0
Compare
- introduce "grist-base", "grist-theme" and "grist-custom" css layers in order to easily handle priority of css variables and base css rules - apply css default variables and css reset on the "grist-base" layer. Note that the way default html/body css is loaded has been changed to be simpler, but maybe I assumed too much here, I didn't dig too deep to get the whole context - apply custom theme css variables on the "grist-theme" layer - a potential custom.css file should wrap its code in the "grist-custom" layer, as the updated example file suggests This will allow base/theme/custom CSS to generate the same variable names while being sure custom css takes precedence theme variables, and theme variables take precedence over default variables.
Until now themes could only describe each component variable. This made creating a theme difficult: we had to override all component variables (hundreds of them) if we wanted to change one color shade used globally. Here is an idea of a cssVars.designTokens prop that is a combination of current `colors`, `vars` and `theme` props: - all design tokens are overridable by a theme - colors are now named in a more abstract way so that it makes sense for a theme changing the primary color Everything is explained in details in the cssVars.designTokens comments
Use new design tokens on right panel header tabs, without removing component-specific variables. Component-specific variables now target designTokens, that are themselves overridable by a theme, allowing to prevent repeating lots of definitions in the theme file.
e65a3f0
to
f9027ce
Compare
Approach makes sense to me. Thank you.
Making all the tokens required in |
Great :)
So to be 100% clear, you mean at least this?
But do you also mean this?
I'd argue if we think those component-specific variables are kinda legacy and we eventually want to remove them, I'd say making them required in a theme object is maybe too much trouble? Since the idea is themes would not want to change those, as Here are a few thoughts:
Yeah I guess this way of doing was more to show the structure, indeed "grist-tokens" is not necessary. I'd argue if *everything* is listed in a theme object, the concept of "grist-base" variables is also debatable: every design token variable is tied to the theme, and then there is the custom css layer that comes on top. |
Only the variables we'd like to change from theme to theme. So yes to colors, but no to z-indexes. Padding and font size are more interesting; I can see an argument that making them required would be more of a nuisance, as they won't always change across themes. A compromise might be to make the vars (e.g. fonts, padding, etc.) optional, and the colors required, with the vars being inherited from the base layer.
No, I agree that it's too much trouble to make those required.
I had a similar thing in mind. A base theme defining the default, non-color variables makes a lot of sense to me. The current system is awkward because things live in two places, as you said. If we can narrow that down to one, that'd be great! |
Context
Here is an example of implementation following discussions in #1295 (up until George's comment).
Proposed solution
Everything is detailed in comments and commit messages, here is a summary of it:
cssVars.colors
andcssVars.vars
, have one big unique object that holds all the design tokens (cssVars.designTokens
), that can all be overriden by a theme. Contrary to before where default colors could not be changed. The idea would be that the new object replaces the 2 others.cssVars.theme
, make the specific component variables target the new design tokens. In the end, in each Theme, specific component variables can be removed, and we can decide to define only the more global design token values (see GristDark).Questions that popped up:
cssVars
being used for the undefined variables. I'm not sure this is a great idea as it could lead to oversights when implementing new themes or updating current ones. I'm not sure it's actually an issue either. As we can easily create a new Theme by extending an existing one anyway. What do you think?Related issues
#1295
Has this been tested?
ping @dsagal @georgegevoian