Skip to content

feat(block-theme): add size options to the Overlay Menu#4652

Open
laurelfulford wants to merge 7 commits intotrunkfrom
feat/extend-overlay-menu-options
Open

feat(block-theme): add size options to the Overlay Menu#4652
laurelfulford wants to merge 7 commits intotrunkfrom
feat/extend-overlay-menu-options

Conversation

@laurelfulford
Copy link
Copy Markdown
Contributor

@laurelfulford laurelfulford commented Apr 10, 2026

All Submissions:

Changes proposed in this Pull Request:

This PR adds a couple options to the Overlay Menu block:

  1. It adds a toggle to open the Menu Overlay panel as a full screen size. When this is enabled, the direction (and new size option) is hidden.
  2. It adds an option to change the menu panel's width

Closes NPPD-1362

How to test the changes in this Pull Request:

  1. Edit a post/page/template part, and add the Overlay Menu Block.
  2. Open the panel, and select it. In the right sidebar, confirm you now have an option to switch the menu to 'full width', and to change its widths -- by default, the full-width option should be off, the panel should come from the left, and should use the 'S' size:
CleanShot 2026-04-10 at 08 30 48
  1. Try enabling 'Full screen'; confirm that the other two options go away. This is because the menu will fade in (a left-or-right entry would be a little jarring at that size), and doesn't need a size set.
CleanShot 2026-04-10 at 08 31 42
  1. Publish and test on front-end; ensure it works well.
  2. Edit again, toggle off "Full screen", and test out the size options. Try them in the editor and on the front end; combine them with the different direction options, and test on different screen sizes. Confirm everything looks good.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the Overlay Menu Panel block by adding layout controls that let editors switch the overlay panel between a full-screen presentation and a set of predefined panel widths.

Changes:

  • Added Full screen toggle to render the overlay panel without directional slide behavior.
  • Added Width toggle group (XS–XL) for non-full-screen mode, reflected in both editor preview and frontend render.
  • Updated panel SCSS to support full-screen and width modifier classes.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/blocks/overlay-menu/style.scss Adds full-screen and width modifier styles for the overlay panel.
src/blocks/overlay-menu/panel/edit.js Adds inspector controls for full-screen and width; updates preview class composition.
src/blocks/overlay-menu/panel/class-overlay-menu-panel-block.php Validates new attributes and outputs corresponding modifier classes in rendered markup.
src/blocks/overlay-menu/panel/block.json Defines new block attributes isFullScreen and panelWidth with defaults.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/blocks/overlay-menu/style.scss
@laurelfulford laurelfulford marked this pull request as ready for review April 10, 2026 16:49
@laurelfulford laurelfulford requested a review from a team as a code owner April 10, 2026 16:49
@laurelfulford laurelfulford added [Status] Needs Review The issue or pull request needs to be reviewed [Status] Needs Design Review labels Apr 10, 2026
@laurelfulford
Copy link
Copy Markdown
Contributor Author

Hey @thomasguillot! This could probably use your eyes just to make sure the sizing feels okay 🙂 Thank you!

@thomasguillot
Copy link
Copy Markdown
Contributor

@laurelfulford Added aria-labels to the Width ToggleGroupControlOptions so each size shows a tooltip on hover (XS → Extra small, S → Small, M → Medium, L → Large, XL → Extra large). Also refactored the options into a PANEL_WIDTH_OPTIONS array to cut down on repetition.

@thomasguillot
Copy link
Copy Markdown
Contributor

@laurelfulford Refactored the panel width CSS: extracted a panel-width Sass mixin so the five size rules are one line each, and switched the min-width: 782px media queries to use the shared breakpoints.$tablet_width variable.

@thomasguillot
Copy link
Copy Markdown
Contributor

@laurelfulford Added "supports": { "lock": false } to both the Overlay Button (trigger) and Menu Panel block.json files, so users can't toggle the lock UI on those children. The parent Overlay Menu block already uses templateLock="all" on its InnerBlocks, so combined with this change the trigger and panel can't be removed or moved.

Copy link
Copy Markdown
Member

@adekbadek adekbadek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the new options end-to-end: defaults render as Full Screen off / direction Left / width S; the Full Screen toggle correctly hides direction + width; and the saved page on the frontend opens the panel from the configured side at the configured width. No PR-related PHP warnings showed up in the debug log.

Approving with a few small notes inline.

A couple of broader things that didn't fit on a line:

  • The PR description doesn't mention the lock: false additions on the panel and trigger blocks. The commit message documents the intent, but it would be worth a one-line mention in the description so reviewers don't have to dig through commits.
  • render_block now has enough branching (full-screen vs direction + width allowlist + invalid-value fallback) that a small PHPUnit test covering the class-string output for valid and invalid attribute combos would be a nice way to lock in the contract — especially the allowlist behavior, since that's the bit doing real defense.

'class' => 'overlay-menu__panel is-layout-constrained ' . $position_class,
'data-direction' => $direction,
'class' => $panel_class,
'data-direction' => $is_full_screen ? 'full-screen' : $direction,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data-direction is set to the literal "full-screen" here, but the attribute's enum is left|right and this value isn't consumed by view.js or any CSS selector. Either drop data-direction in the full-screen branch or treat the new value as intentional public API and document it. Right now it's a slightly dead string.

"default": "left"
},
"isFullScreen": {
"type": "boolean",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding "enum": ["x-small", "small", "medium", "large", "x-large"] to panelWidth (and ["left", "right"] to slideDirection). The PHP allowlist already prevents class-name injection, so this is purely defense-in-depth on the schema side, but it makes the contract explicit and gives editor-side validation for free.

@@ -1,3 +1,5 @@
@use "../../newspack-ui/scss/variables/breakpoints";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit / out of scope: this is the only place in src/blocks/ that pulls in newspack-ui/scss/variables/breakpoints. The relative path couples this block's stylesheet to the newspack-ui directory layout. If this dependency starts spreading, a shared _breakpoints.scss in src/shared/scss/ (next to the existing _mixins.scss) would be a more durable home.

&--width--x-small { @include panel-width( --wp--custom--width--x-small, 300px ); }
&--width--small { @include panel-width( --wp--custom--width--small, 410px ); }
&--width--medium { @include panel-width( --wp--style--global--content-size, 632px ); }
&--width--large { @include panel-width( --wp--custom--width--large, 964px ); }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the medium fallback maps to --wp--style--global--content-size, which is a different variable family than the others (--wp--custom--width--*). It's intentional (matches editor content width), but a one-line comment would prevent it reading like a typo.

@github-actions github-actions Bot added [Status] Approved The pull request has been reviewed and is ready to merge and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Status] Approved The pull request has been reviewed and is ready to merge [Status] Design Approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants