Add an interactive variant to @wordpress/create-block#52508
Add an interactive variant to @wordpress/create-block#52508luisherranz wants to merge 1 commit intotrunkfrom
@wordpress/create-block#52508Conversation
|
Another question: This variant requires Gutenberg (16.2+). Where should we inform the user that Gutenberg needs to be installed in other for this to work? |
|
Size Change: 0 B Total Size: 1.43 MB ℹ️ View Unchanged
|
|
Given the current state of the Interactivity API package (still experimental), I wouldn't create a Also, ideally, this I think having a direct |
ryanwelcher
left a comment
There was a problem hiding this comment.
The code looks good to me. However, I agree with @juanmaguitar that this is probably better as a template until the API is available in core. One benefit of using it's own template is that we can introduce any number of variants to show different and more complex examples
|
Ok, thanks for your feedback. I'll migrate this to a template and we'll merge this variant at a later point 🙂 |
|
@luisherranz to speed up things, I have created this PR #52549 over |
|
Awesome. Thank you, Juanma. |
What?
Add an
interactivevariant to the@wordpress/create-blockpackage.Why?
So people can use this variant to start testing the Interactivity API.
How?
I followed what @ryanwelcher did in this PR and added a new variant for an
interactiveblock.I also added the possibility of adding a
viewScriptfield to theblock.jsonfile.Testing Instructions
@wordpress/create-blockpackage using:cd packages/create-blocknode index.jsinteractivevariant.block.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)Screenshots or screencast
https://www.loom.com/share/3680f3b779e14306b8a7fd5bb484988c
Questions
wp-nowand add npm scripts to run it?