-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Add an interactive variant to @wordpress/create-block
#52508
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
Conversation
|
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?