-
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
Global Styles: update metadata and add support for padding #27099
Conversation
Size Change: +305 B (0%) Total Size: 1.2 MB
ℹ️ View Unchanged
|
588f8fd
to
d2a3cf7
Compare
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.
Hi @nosolosw the changes work well on my tests 👍 I really like that the contexts for all blocks that previously we passed from the server are now computed on the client.
I'm not totally sure about passing STYLE_PROPERTIES from the server to the client.
packages/edit-site/src/components/editor/global-styles-provider.js
Outdated
Show resolved
Hide resolved
@@ -14,7 +14,6 @@ import { | |||
useMemo, | |||
} from '@wordpress/element'; | |||
import { useEntityProp } from '@wordpress/core-data'; | |||
import { __EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY } from '@wordpress/blocks'; |
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.
If global styles does not use __EXPERIMENTAL_STYLE_PROPERTY from @wordpress/blocks I guess the need to have this data in '@wordpress/blocks' is not present anymore as we now don't reuse this data between block-editor and global styles?
We still have the need to have this metadata on the client and server. What's the advantage of passing it on the server to edit-site especially but continue to use the hardcoded client information on the block-editor?
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 we should remove that and use this setting! Didn't do it in this PR because it felt too much.
contexts={ | ||
settings.__experimentalGlobalStylesContexts | ||
metadata={ | ||
settings.__experimentalGlobalStylesMetadata |
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.
Previously we discussed passing this type of metadata from the server to the client to promote reusability. @youknowriad referred he did not like the idea of having metadata (like presets structure or style properties) as a setting. I'm cc @youknowriad in case he has any thoughts on this change, specifically the passing of STYLE_PROPERTY as a setting from the server.
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.
In the interest of agility, I've duplicated in the client the style property metadata. The conversation can continue, and if we want to pass down the metadata to the client we can address it in a follow-up PR.
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 what's important for me is that the settings of the BlockEditorProvider
make sense in isolation, in contexts without global styles, without WordPress and someone passing config there to build his own editor should be able to understand and pass the right config depending on what he wants.
So just make sure, that assumption stands :P
d2a3cf7
to
b43a2c2
Compare
@jorgefilipecosta your suggestions are addressed! |
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.
LGTM 👍
packages/edit-site/src/components/editor/global-styles-provider.js
Outdated
Show resolved
Hide resolved
e4ee01a
to
88700df
Compare
Follow-up that adds the padding control at #27154 |
This PR does a couple of things:
Reduces the amount of metadata we send to the client. Before this PR we sent all the metadata for every context, now the client derives the contexts from existing data. Fixes Reduce the amount of data Global Styles sends to the client #26802
While we allowed padding to be set at the block level (block attributes) we didn't do the same for the global level (theme.json). This is a bug that happened due to the distributed nature of the metadata that we had. Note that this needs a follow-up PR to add the padding control to the global styles sidebar.
How to test
Test that it works as before:
Tests that it padding works properly: