-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add a high-level intro to styles in the block editor #38208
Conversation
Thank you for working on the new docs. I appreciate it. While I cannot officially review this PR (as I don't have the rights to do that), here are a couple of things that came to my mind while reading the proposed text:
A couple of tiny typos (in an improvised suggestion markdown :) )
Extra
And again, thanks so much! |
|
||
In essence, these are the essential mechanics a block author needs to care about for their block to be able to be styled by the user. While this can be done completely manually, there's an API that automates this process for common style needs: Block Supports. | ||
|
||
#### Block Supports API |
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.
Sharing feedback I've got privately:
- Some folks shared interest in going deep down into how this works: the filters in use, pointing directly to the code where this happens, etc.
- Point to the existence of some functions useful in "skip serialization" mode (
__experimentalUseColorProps
,__experimentalUseBorderProps
,__experimentalGetSpacingClassesAndStyles
, etc).
I'll incorporate something for the second point directly in this PR.
As for the 1st point. My first instinct was to keep this doc as approachable as possible to block authors, so they don't feel that they need to know how the internals of this API work to implement their blocks. That shouldn't be a requirement. I also understand how that would be useful for core contributors. I'd like to hear thoughts on this, especially from other folks new to this area or that have interacted with this lately.
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 felt that the "styles" document might not be the right place to expand on how block supports work. Would it be better if in this document block supports are treated just like any "local/serializable" style and just link to their document for block authors that want to know more about them?
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 read the content here for block supports and it does make a lot of sense and have value but maybe it's better moved to the block supports document itself.
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.
Would it be better if in this document block supports are treated just like any "local/serializable" style and just link to their document for block authors that want to know more about them?
This sounds like a good idea. Block supports are still in development, so the docs might need a roomy home.
It's probably still relevant to this doc to emphasise that many block supports add inline styles to block containers, and that they're rendered to the page with the block.
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 won't add any further to "how block supports" work and the utility functions in use. This can be done in a different PR and probably can go in the block supports docs.
|
||
In essence, these are the essential mechanics a block author needs to care about for their block to be able to be styled by the user. While this can be done completely manually, there's an API that automates this process for common style needs: Block Supports. | ||
|
||
#### Block Supports API |
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 felt that the "styles" document might not be the right place to expand on how block supports work. Would it be better if in this document block supports are treated just like any "local/serializable" style and just link to their document for block authors that want to know more about them?
|
||
In essence, these are the essential mechanics a block author needs to care about for their block to be able to be styled by the user. While this can be done completely manually, there's an API that automates this process for common style needs: Block Supports. | ||
|
||
#### Block Supports API |
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 read the content here for block supports and it does make a lot of sense and have value but maybe it's better moved to the block supports document itself.
- From UI controls to HTML markup | ||
- Block Supports API | ||
- Current limits of the Block Supports API | ||
3. User-provided Global Styles |
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.
Do we need a chapter about "Editor Styles" and how all these theme provided styles get loaded in the editor as well? (in addition to classic.css and reset.css) or is this specifically about frontend?
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 see this doc as a "map to the main subsystems" someone needs to be aware of, so not about the frontend. I've added a todo task in the issue description to consider this once the global styles section has a draft.
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.
Upon re-reading the whole document, I think the v1 doesn't need to cover this.
"How styles are enqueued into the editor" is a whole new topic that needs to cover a lot of ground by itself: add_editor_style(...)
, add_theme_support('editor-styles')
, add_theme_support('wp-block-styles'),
reset.css/
classic.css, the iframe,
add_filter( 'enqueue_block_editor_assets', ...` and probably some other things I've forgotten. Some of this is already mentioned on theme support.
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.
Thanks for putting this together @oandregal! This reads really well to me, and nicely covers some of the main areas we're hoping to address with the style engine. Thanks for linking through to the relevant issues, too (and nicely articulating the issue of complex blocks like the Table block 🙇).
I hope you don't mind, but I've added a few suggestions, mostly for copy-editing things (typos and grammar), but otherwise it's looking really good to me! (There's a few instances of an
before UI
that I've switched to a
— usually if the vowel sounds like a y
when read aloud, it should be a
).
Since it's documentation, I'd be in favour of seeing what we can get in in the shorter-term and follow up with additions as we need to in follow-up PRs. Also CC: @aaronrobertshaw and @ramonjd for visibility since they've been looking at block supports and style engine things quite a bit recently, too 🙂
This is a fantastic start, thanks for taking the time to document your knowledge on this. |
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 very much for working on this @oandregal, it is greatly appreciated 👍
I think @andrewserong has covered most of the wording related tweaks that could improve things. So I'll limit my comments below to a couple of clarifications that might help avoid some points of confusion I've seen pop up regularly around the block supports API.
Lastly, the level of knowledge this is being aimed at is great. I think it will be tremendously useful for those starting to look closer in this area. Well done!
ac56058
to
d8cfe29
Compare
Pushed a draft for the global styles section so we have a first v1 for this document. Would welcome reviews for this new section. |
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.
The new section on Global Styles reads well to me 👍
I've left some minor comments and suggestions regarding fixing small typos or tiny improvements to wording.
Thanks again for writing this up. I'm sure it will help lots of people.
Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com>
Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com>
Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com>
Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com>
Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com>
Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com>
Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com>
fae09dd
to
aae008e
Compare
Feedback has been incorporated and this is now ready for landing. |
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 is great @oandregal! Thanks for working on this!
I've left minor comments and I'm going to pre approve because I think we can land and iterate more if needed. My only small concern is whether the block supports
section really belongs here.
|
||
- the [WordPress templates](https://developer.wordpress.org/themes/basics/template-files/) provided by the theme, either via PHP (classic theme) or via HTML templates (block theme) ([learn more](https://developer.wordpress.org/themes/block-themes/#differences-and-similarities-between-classic-themes-and-block-themes) about the differences) | ||
- the [blocks](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/) and patterns in use that come with a predefined structure (HTML markup) | ||
- the user modifications to the content: adding content, transforming existing content (convert a given paragraph into a heading), or modifying it (attaching a class or inline styles to a block) |
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.
Since we're talking about final
, it feels to me okay not to mention transforming
.
Co-authored-by: Nik Tsekouras <ntsekouras@outlook.com>
Co-authored-by: Nik Tsekouras <ntsekouras@outlook.com>
Co-authored-by: Nik Tsekouras <ntsekouras@outlook.com>
Co-authored-by: Nik Tsekouras <ntsekouras@outlook.com>
Co-authored-by: Nik Tsekouras <ntsekouras@outlook.com>
Co-authored-by: Nik Tsekouras <ntsekouras@outlook.com>
Co-authored-by: Nik Tsekouras <ntsekouras@outlook.com>
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 think that's a great addition.
These are things that are not covered by this PR but folks mentioned that could be useful to have in some place:
I don't plan to work on them at the moment, but wanted to give them visibility in case anyone has the bandwidth/interest. |
Excellent work, this is going to be super helpful for both contributors and extenders ❤️ |
Great work @oandregal, thanks again for adding in the extra documentation, +1 to the above comment, it's going to be really helpful for folks 😀 |
This PR adds a new document to the handbook: a high-level intro to how styles work in the block editor.
It points to the relevant reference guides and tutorials for readers to dig deeper into each one of the ideas presented. It's aimed to block authors and people working in the block editor project. It intentionally tries to avoid block editor jargon and it doesn't presume any knowledge by the reader, other than a familiarity with the block editor and what a block is.
It needs to be complemented with a couple of new tutorials, to be done in separate PRs. Namely, one that explains how to use block supports, both for static and dynamic blocks. Related #38210
Feedback
Read the doc here.
At the moment, I'm particularly interested in hearing what people think of the general structure and the block styles section. Does this work as a general intro? Anything people find missing? I expect further explanations and code deep downs to be developed in the tutorials.
TODO
Follow-up PRs (up for grabs):
classic.css
andreset.css
. See comment.