-
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
Create block interactive template #52612
Conversation
Size Change: +149 B (0%) Total Size: 1.43 MB
ℹ️ View Unchanged
|
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.
Code look good to me!
Flaky tests detected in 764fa77. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5551970401
|
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, 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? |
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is only a single variant, then w can skip this section and remove all checks like {{#isBasicVariant}}
.
What?
Add an
interactive
template for the@wordpress/create-block
package.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.js
from the template we needcreate-block
to allow this file. That's why this PR also contains some changes to thecreate-block
packagecreate-block
package also has theview.js
implemented as part of a basic scaffoldcreate-block
package have been properly adapted to the addition of this new filecreate-block-interactive-template
is a new package a newmanifest.json
has been created so this new package is being taken into account for the Block Editor Handbookconsole.log
are 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-block
package using:cd packages/create-block
node index.js --template ../create-block-interactive-template
block.json
should havesupports.interactivity: true
and aviewScript
field.render.php
file should contain directives.view.js
file with an import of@wordpress/interactivity
and a call tostore()
.If you want to try that the interactivity works, you can use
wp-now
:cd (installation directory) && npm start
npx @wp-now/wp-now start
(in another terminal)