Donations Block: modal display mode with trigger button and icon picker#48539
Donations Block: modal display mode with trigger button and icon picker#48539angelablake wants to merge 11 commits intoupdate/donations-security-settingsfrom
Conversation
…picker Adds `displayMode` (inline/modal), `triggerButtonText`, and `triggerIcon` attributes. In modal mode the block renders as a styled trigger button that opens the full donations form in an accessible overlay modal (focus trap, ESC to close, backdrop click to close, scroll lock, return focus on close). Includes a 3×3 curated icon picker (9 icons + None) in the editor sidebar and a trigger button preview in the editor canvas. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
- Fix block border: reset border/radius on wrapper (!important to override inline block-support styles) and forward them to the modal dialog instead; overflow:hidden on dialog enables border-radius clipping - Add trigger button alignment: contentAlignment now also applies text-align to the block wrapper in modal mode, aligning the trigger button left/center/right - Simplify icon picker to 4 icons (heart, gift, smiley, cup) in a single row; replace the "None" grid button with a Show icon ToggleControl consistent with other settings panels Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Rename display mode labels: Inline → In-page, Button & Modal → Pop-up - Pop-up mode editor now shows just the trigger button (matching the frontend) instead of the full form preview - Remove dead editor styles for the modal form preview and hint text Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… hack - Import and render Controls in edit.js for pop-up mode so all inspector panels (Display, Settings, Security) are available regardless of mode - Remove border:none!important and border forwarding to modal dialog; block-support border now applies to the wrapper (trigger button) as expected — users can style it normally - Remove dead is-modal-display class that existed only to support the reset Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…for In-page mode Remove __experimentalBorder from block.json supports (which auto-serialized border onto the full block wrapper in both modes). Add blockBorder/blockBorderRadius attributes manually via custom BorderBoxControl + BorderRadiusControl in controls.js, rendered only when displayMode !== 'modal'. Border rules emit via the per-instance <style> tag using a compound selector (.wp-block-jetpack-donations.jp-donations-N) for specificity. Pop-up mode suppresses the default gray border via is-display-modal class + common.scss rule. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…y toggle - triggerIcon default: coffee → heart (block.json + PHP fallback) - Trigger button placeholder / PHP fallback text: "Support me" → "Donate" - New triggerSticky boolean attribute; Sticky toggle in Display panel (Pop-up only) - Sticky mode: position:fixed bottom-right (inset-inline-end for RTL), z-index 9999, is-sticky class on wrapper in both editor and PHP render Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use WP's isPressed prop (adds is-pressed class) instead of a custom is-selected class. Core's is-pressed style is dark background (#1e1e1e) + white icon, which is high contrast and consistent with WP idioms. Our CSS was overriding the background to 8% opacity blue while the icon was already white — invisible. Now we only set a matching dark border; WP handles background and icon color. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The 16px top margin was pushing the label away from the input, making the gap look excessive compared to standard WP stacked controls. WP's natural spacing between stacked controls in a PanelBody is sufficient. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Stacked on top of #48492. Reviews can wait until that lands; this PR can be tested on Jetpack Beta in parallel.
Proposed changes
Adds a Pop-up display mode to the Donations Form block, alongside the existing In-page mode.
Display mode toggle
Trigger button
position: fixed) so it stays visible as visitors scroll — useful for footers or sidebars.Modal overlay
Border controls
__experimentalBorderblock support (which applied borders to the full block wrapper in both modes). Replaced with manually-rendered Border and Radius controls under the Styles tab, shown only in In-page mode — so Pop-up mode never shows a confusing block-level border panel.is-display-modalclass).Related product discussion/links
Does this pull request change what data or activity we track or use?
No tracking or data changes. The display mode, trigger button settings, and sticky flag are stored as block attributes only.
Testing instructions
In-page mode (regression)
Switching to Pop-up mode
2. In the Display inspector panel, toggle from In-page to Pop-up. The editor should show only the trigger button preview — no inline form below it. [screenshot]
3. Change the button label in the "Button text" field — the preview updates immediately.
4. Toggle Show icon off — the button renders text only. Toggle back on and cycle through the 4 icon options — each should update the preview. [screenshot]
Frontend behavior
5. Save and view on the frontend — only the trigger button should be visible; the form should not be on the page until the button is clicked. [screenshot]
6. Click the trigger button — the modal opens with the full donations form, backdrop is blurred. [demo]
7. Close via ESC key — modal dismisses, focus returns to the trigger button.
8. Close via backdrop click (outside the dialog) — same result.
9. Close via the X button — same result.
10. While the modal is open, Tab and Shift-Tab should cycle focus only within the modal (focus trap). Body scroll should be locked.
Sticky
11. Enable the Sticky toggle in the Display panel. Save and scroll the frontend page — the trigger button should remain fixed in the bottom-right corner of the viewport. [demo]
Border controls
12. In Pop-up mode, confirm the Styles tab does not show a Border panel — borders don't apply to the full block wrapper in this mode.
13. Switch to In-page mode — the Border panel should reappear under Styles and work normally. [screenshot]
Alignment
14. Use the alignment toolbar to set the trigger button left, center, and right. [screenshot]