-
Notifications
You must be signed in to change notification settings - Fork 32
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
New block: Modal block using the Interactivity API #675
Conversation
I expected the ability to style the button while using the editor but wasn't able to. Other than that, looks good to me. |
The frontend style is loaded in the editor iframe, so this is not used
d65472f
to
4cf587e
Compare
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.
Great work, this resolves the issue I created way back when the original modal was built!
I still really want to do something with the Interactivity API, need to find a use...
Works for me
If anything comes up I'll try to pass it your way :) Maybe WordPress/wporg-theme-directory#101 ? It would be nice to make something that could be used across both themes and plugins… but totally not a high priority request. |
See WordPress/wporg-main-2022#521 — The current modal on w.org/download is using React, and the content inside is hardcoded in JS. This is harder to iterate on (see WordPress/wporg-main-2022#515).
This PR creates a new block which adds a button with a hidden
InnerBlocks
container. When the "Show modal" toggle is enabled, a modal appears in the editor, showing the editableInnerBlocks
area. The background color, text color, close button color, and overlay color are all configurable. On the front end, this uses the interactivity API to handle the open state and related attributes/classes.The markup can also be used in templates and patterns, it works like a group block where the child content is rendered in the modal. The
label
attribute is the button text. It also works to add any of the button style classes to the modal, and they'll apply to the modal toggle.Screenshots
The modal on the download page — if a URL is set, this uses a link tag with the
download
attribute set, so that it will trigger the page download, and then open the modal.To test