Skip to content

Register out-of-the-box block patterns - #15

Merged
roborourke merged 2 commits into
claude/ecstatic-goodall-VAzNUfrom
claude/ecstatic-goodall-VAzNU-patterns
Jul 20, 2026
Merged

roborourke merged 2 commits into
claude/ecstatic-goodall-VAzNUfrom
claude/ecstatic-goodall-VAzNU-patterns

Conversation

@roborourke

@roborourke roborourke commented May 27, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #13

Note: This PR is stacked on top of PR #14 (hover trigger). Please merge #14 first, then update the base of this PR to main before merging.

Summary

Registers a "Popups" block pattern category and six ready-to-use patterns so users can get started without building popup layouts from scratch.

Changes

popup.php

  • Registers the hm-popup pattern category ("Popups") in action_init().
  • Iterates over patterns/*.php files and calls register_block_pattern() for each.

patterns/ (new directory — 6 files)

Pattern Slug Trigger Notes
Exit Intent Popup hm-popup/exit-intent exit Close button; first group has natural WP box shadow
Page Load Popup hm-popup/page-load load Close button; first group has natural WP box shadow
Click-Triggered Popup hm-popup/click-popup click Trigger button + close button; first group has natural WP box shadow
Left Popout Panel hm-popup/left-popout click is-style-side--left; first group: minHeight 100vh, grey right border
Right Popout Panel hm-popup/right-popout click is-style-side--right; first group: minHeight 100vh, grey left border
Anchored Tooltip hm-popup/tooltip hover is-style-anchored, anchorPosition: top; ℹ️ icon trigger; requires PR #14

How to test

  1. Open the block inserter → Patterns tab → Popups category.
  2. Insert each pattern and verify it looks correct in the editor.
  3. Publish and visit the frontend:
    • Exit intent: move cursor out of the window to trigger.
    • Page load: popup opens automatically (clear localStorage first to reset expiry).
    • Click popup / side panels: click the trigger button.
    • Tooltip: hover over the ℹ️ icon — popup appears above it.

https://claude.ai/code/session_01SjvQ7YTxjFF81uSb1WtPAH


Generated by Claude Code

Open WordPress Playground Preview

claude added 2 commits May 27, 2026 12:12
Implements issue #13. Adds a 'Popups' pattern category and six ready-to-use
block patterns so users can get started without building popups from scratch.

Changes:
- popup.php: register 'hm-popup' pattern category in action_init(); load
  and register pattern definitions from the new patterns/ directory using
  register_block_pattern()
- patterns/exit-intent.php: exit intent popup with close button and
  a core/group with the 'natural' WP box shadow
- patterns/page-load.php: page load popup with close button and
  a core/group with the 'natural' WP box shadow
- patterns/click-popup.php: trigger button + click popup with close
  button and a core/group with the 'natural' WP box shadow
- patterns/left-popout.php: left slide-in panel (is-style-side--left),
  click trigger, first inner group has minHeight 100vh and a grey right border
- patterns/right-popout.php: right slide-in panel (is-style-side--right),
  click trigger, first inner group has minHeight 100vh and a grey left border
- patterns/tooltip.php: anchored tooltip (is-style-anchored, anchorPosition top)
  triggered by hovering an info icon; uses the hover trigger from #12

https://claude.ai/code/session_01SjvQ7YTxjFF81uSb1WtPAH
…gger

The beforeEach hook inserts a click-triggered popup, so the hover
frontend test had two .wp-block-hm-popup elements on the page.
Playwright's toHaveAttribute throws on multiple matches, causing CI
to fail.

Fixes:
- Use '#hover-test-popup' selector instead of '.wp-block-hm-popup' to
  target only the hover popup, avoiding ambiguity with the click popup
  inserted by beforeEach
- Replace raw paragraph HTML link with core/buttons + core/button
  (same pattern used in anchoring.spec.js) for a reliable trigger
- Check toHaveAttribute('open', '') after hover to precisely assert
  that dialog.show() was called (sets the open attribute)

https://claude.ai/code/session_01SjvQ7YTxjFF81uSb1WtPAH
@roborourke
roborourke merged commit f06d169 into claude/ecstatic-goodall-VAzNU Jul 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants