Create block interactive template#52612
Conversation
|
Size Change: +149 B (0%) Total Size: 1.43 MB
ℹ️ View Unchanged
|
ryanwelcher
left a comment
There was a problem hiding this comment.
Code look good to me!
|
Flaky tests detected in 764fa77. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5551970401
|
luisherranz
left a comment
There was a problem hiding this comment.
Thanks, Juanma. It's clearer now 🙂
I like the code but I've added a few comments below with things that could be improved.
packages/create-block-interactive-template/block-templates/view.js.mustache
Show resolved
Hide resolved
packages/create-block-interactive-template/block-templates/edit.js.mustache
Outdated
Show resolved
Hide resolved
|
@luisherranz I have improved the code based on your feedback and answered some of your questions above. If everything is OK with this PR and we merge it, as this is a new package prepared to be published in NPM, do you know how this NPM publication process works? When will this package be published in NPM after the merge? |
luisherranz
left a comment
There was a problem hiding this comment.
I have improved the code based on your feedback and answered some of your questions above.
Thanks 🙂
I still don't understand the double line breaks, but if you're sure that those are needed go ahead with the merge.
do you know how this NPM publication process works? When will this package be published in NPM after the merge?
Unless we publish it ourselves manually, I think it'll be published next Wednesday as part of the 16.3 RC.
@luisherranz they had no sense I have fixed this in this commit |
| viewScript: 'file:./view.js', | ||
| }, | ||
| variants: { | ||
| basic: {}, |
There was a problem hiding this comment.
If there is only a single variant, then w can skip this section and remove all checks like {{#isBasicVariant}}.
What?
Add an
interactivetemplate for the@wordpress/create-blockpackage.Why?
So people can use this template to start testing the Interactivity API.
How?
This PR is the consequence of these previous PR's: #52508 and #52549
Some notes on this code:
view.jsfrom the template we needcreate-blockto allow this file. That's why this PR also contains some changes to thecreate-blockpackagecreate-blockpackage also has theview.jsimplemented as part of a basic scaffoldcreate-blockpackage have been properly adapted to the addition of this new filecreate-block-interactive-templateis a new package a newmanifest.jsonhas been created so this new package is being taken into account for the Block Editor Handbookconsole.logare not allowed with the default rules of the linter there's a directive added to packages/create-block/lib/templates/block/view.js.mustache to skip this rule and allow this command (when comitting the code)Testing Instructions
@wordpress/create-blockpackage using:cd packages/create-blocknode index.js --template ../create-block-interactive-templateblock.jsonshould havesupports.interactivity: trueand aviewScriptfield.render.phpfile should contain directives.view.jsfile with an import of@wordpress/interactivityand a call tostore().If you want to try that the interactivity works, you can use
wp-now:cd (installation directory) && npm startnpx @wp-now/wp-now start(in another terminal)