-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
theme.json docs: clarify naming schema for CSS Custom Properties #28639
Conversation
|
||
- **Presets**: [color palettes](https://developer.wordpress.org/block-editor/developers/themes/theme-support/#block-color-palettes), [font sizes](https://developer.wordpress.org/block-editor/developers/themes/theme-support/#block-font-sizes), or [gradients](https://developer.wordpress.org/block-editor/developers/themes/theme-support/#block-gradient-presets) declared by the theme are converted to CSS Custom Properties and enqueued both the front-end and the editors. | ||
|
||
{% codetabs %} |
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'm not sure this codetabs
thing is going to work the way I expected it to work. This has been used to show ES5/ESNext code examples side by side. Can we use it for other things as well?
I thought I'd figure it out by pushing the changes to the handbook and see. If it works well, I think it can be expanded to a few things in this document.
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.
Clever use, I think it will work. 👍
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.
It didn't go very well :( I've created #28655 to see if I can fix it. Comparing it to other codetabs
uses, I don't see any missing markup.
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.
Using single words fixed it 💪
Size Change: +405 B (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
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.
This makes sense to me and offers clarification and guidance around naming conventions.
I don't have any suggestions myself, so will approve but will leave open if @jasmussen wants to push anything up prior to merge. 👍
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.
Thank you, so helpful! I think this is the key bit:
**Presets** such as `--wp--preset--color--black` can be divided into the following chunks:
- `--wp`: prefix to namespace the CSS variable.
- `preset `: indicates is a CSS variable that belongs to the presets.
- `color`: indicates which preset category the variable belongs to. It can be `color`, `font-size`, `gradients`.
- `black`: the `slug` of the particular preset value.
I think this structure makes a lot of sense. In most cases, I'd prefer a prefix, and a very short variable name. But for global styles, and because of how it works, I understand it's important with a structured system for these, in addition to the preset. So this seems good.
Question, though, what does the --
mean instead of just -
? I'm guessing it's a BEM-like category separator, whereas a single dash is just meant as a word-hyphen?
@youknowriad is AFK at the moment, but just wanted to leave a ping in his inbox for when he's back!
Thank you André!
Hadn't thought about it in terms of its similarity to BEM naming, but it's definitely similar: it separates "categories". The rationale for using
|
ok, I've added a new section called "why using |
This PR updates the theme.json docs to include more information about the naming schema of CSS Custom Properties generated by the system.
View docs live.