-
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
Block API: Add viewStyle
property support to block.json
#55492
Conversation
I would like to change the status of this PR to draft till the actual change to add the viewStyle property was actually merged |
One important consideration when documenting |
All the necessary changes for WordPress core are ready to review in WordPress/wordpress-develop#5531. I have just tested, and there are no changes necessary for |
I've put a more detailed explanation to the property documentation in |
ce6ef75
to
310c47b
Compare
viewStyle
property support to block.json
The changes on the WordPress Core side are ready. See https://core.trac.wordpress.org/ticket/59673 for details. There are some merge conflicts to resolve, so this branch needs to be updated with the latest changes from Do we want to add support for |
310c47b
to
dc22656
Compare
I just rebased and committed the suggestions from your side. I've marked the PR for review and am happy to add any further documentation or testing if needed. |
@fabiankaegy, do you think we have enough to land it? |
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.
@gziolo This looks good to me and I think it is enough to land it 👍
What?
This PR adds the
viewStyle
property to the block.json schema, the documentation for block meta data and also enabled using it in the create-block package.It's the Gutenberg part to the track ticket 59673. See also the Gutenberg issue #54491.
Why?
See issue #54491. The code to register and enqueue the viewStyles happens in core and on trac. In Gutenberg the block.json schema and documentation needs to be changed.
How?
Block metadata
Add property to JSON schema, add property to documentation about block metadata.
@wordpress/create-block
Add property as configurable in create-block, but don't use it by default, because most simple blocks won't need it. But creators of create-block templates can use it. That's also how the
viewScript
property is handled as far as I can see.@wordpress/scripts
As far as I can see, no changes in the @wordpress/scripts package are necessary, since just using a
view.js
which imports aview.scss
(for example) works out of the box and can be set. If theview.js
is in the block.json, it's automatically recognized by the webpack config.Testing Instructions
The Gutenberg part alone has no functional changes per se. Only the schema changes, which helps in IDEs and for validation of
block.json
.Regarding the create-block part: That actually adds functionality, in that a template can set a
viewStyle
property - I guess? But I'm not 100 percent certain, how to test that. I probably would need to create a new template type? Anybody knows?