Skip to content

Create Block: Improve block templates#41273

Merged
gziolo merged 2 commits intotrunkfrom
update/create-block-tweaks
May 24, 2022
Merged

Create Block: Improve block templates#41273
gziolo merged 2 commits intotrunkfrom
update/create-block-tweaks

Conversation

@gziolo
Copy link
Copy Markdown
Member

@gziolo gziolo commented May 24, 2022

What?

Similar to #41272 that adds the information that the scaffolded block was tested with WordPress 6.0.

This PR fixes a few tiny issues I discovered when working on my own template for @wordpress/create-block:

https://github.com/gziolo/wp-block-directory-template

Why?

I noticed some linting errors reported and more importantly the block had usability issues caused by the block wrapper configured incorrectly.

How?

I updated templates for Create Block to import the block name from block.json file to remove the friction. I saw @ryanwelcher missing updating the hardcoded block name in his stream when he copied the block. This change removes the issue completely.

I also updated edit.js implementation in the Create a Block tutorial to use a wrapping div to resolve usability issues in the UI when selecting the block.

Finally, I added a few clarifications in the Create a Block tutorial to make it clear which files are referenced from the project.

Testing Instructions

Create a test plugin:

npx wp-create-block gutenpride --template @wordpress/create-block-tutorial-template --no-wp-scripts
cd gutenpride
../node_modules/.bin/wp-scripts build
../node_modules/.bin/wp-scripts plugin-zip

Upload the block plugin to the WordPress instance and ensure it works correctly. When you click on the block then all block controls should work as intended.

@gziolo gziolo added [Type] Enhancement A suggestion for improvement. [Type] Developer Documentation Documentation for developers [Tool] Create Block /packages/create-block labels May 24, 2022
@gziolo gziolo requested a review from ryanwelcher as a code owner May 24, 2022 07:50
@gziolo gziolo self-assigned this May 24, 2022
Copy link
Copy Markdown
Contributor

@ryanwelcher ryanwelcher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 Thanks for updating this!

@gziolo gziolo merged commit db5a574 into trunk May 24, 2022
@gziolo gziolo deleted the update/create-block-tweaks branch May 24, 2022 18:13
@github-actions github-actions bot added this to the Gutenberg 13.4 milestone May 24, 2022
@bph bph added the Needs Dev Note Requires a developer note for a major WordPress release cycle label Sep 14, 2022
@bph bph mentioned this pull request Sep 14, 2022
89 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Dev Note Requires a developer note for a major WordPress release cycle [Tool] Create Block /packages/create-block [Type] Developer Documentation Documentation for developers [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants