-
Notifications
You must be signed in to change notification settings - Fork 384
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
Add support for responsive navigation block in Gutenberg #6319
Comments
Note: Instead of a |
If it ends up as being that |
After digging a bit into this I think we could use The original markup of <nav class="wp-container-619eab71221c9 is-responsive wp-block-navigation">
<button aria-expanded="false" aria-haspopup="true" aria-label="Open menu" class="wp-block-navigation__responsive-container-open" data-micromodal-trigger="modal-619eab7121f8f">
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-hidden="true" focusable="false">
<rect x="4" y="7.5" width="16" height="1.5" />
<rect x="4" y="15" width="16" height="1.5" />
</svg>
</button>
<div class="wp-block-navigation__responsive-container" id="modal-619eab7121f8f">
<div class="wp-block-navigation__responsive-close" tabindex="-1" data-micromodal-close>
<div class="wp-block-navigation__responsive-dialog" role="dialog" aria-modal="true" aria-labelledby="modal-619eab7121f8f-title">
<button aria-label="Close menu" data-micromodal-close class="wp-block-navigation__responsive-container-close">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" role="img" aria-hidden="true" focusable="false">
<path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path>
</svg>
</button>
<div class="wp-block-navigation__responsive-container-content" id="modal-619eab7121f8f-content">
<ul class="wp-block-page-list">
<li class="wp-block-pages-list__item wp-block-navigation-item open-on-hover-click">
<a class="wp-block-pages-list__item__link wp-block-navigation-item__content" href="http://localhost.develop/sample-page/">Sample Page</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</nav> We could do following changes to ampify it:
so the final markup will look similar to this: <nav class="wp-container-619e2a8d594e4 is-responsive wp-block-navigation">
<button on="tap:menu1.open" aria-haspopup="true" aria-label="Open menu" class="wp-block-navigation__responsive-container-open">
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-hidden="true" focusable="false">
<rect x="4" y="7.5" width="16" height="1.5"></rect>
<rect x="4" y="15" width="16" height="1.5"></rect>
</svg>
</button>
<amp-lightbox id="menu1" layout="nodisplay">
<div class="wp-block-navigation__responsive-container is-menu-open has-modal-open" id="modal-619e2a8d5925c">
<div class="wp-block-navigation__responsive-close" tabindex="-1">
<div class="wp-block-navigation__responsive-dialog" role="dialog" aria-labelledby="modal-619e2a8d5925c-title">
<button on="tap:menu1.close" aria-label="Close menu" class="wp-block-navigation__responsive-container-close">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" role="img" aria-hidden="true" focusable="false">
<path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path>
</svg>
</button>
<div class="wp-block-navigation__responsive-container-content" id="modal-619e2a8d5925c-content">
<ul class="wp-block-page-list">
<li class="wp-block-pages-list__item wp-block-navigation-item open-on-hover-click">
<a class="wp-block-pages-list__item__link wp-block-navigation-item__content" href="http://localhost.develop/sample-page/">Sample Page</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</amp-lightbox>
<div class="wp-block-navigation__responsive-container">
<div class="wp-block-navigation__responsive-container-content">
<ul class="wp-block-page-list">
<li class="wp-block-pages-list__item wp-block-navigation-item open-on-hover-click">
<a class="wp-block-pages-list__item__link wp-block-navigation-item__content" href="http://localhost.develop/sample-page/">Sample Page</a>
</li>
</ul>
</div>
</div>
</nav> Thanks to this, we could use the same navigation menu styles as were used in original, non-amp version of the page, while getting rid of the original JS scripts. |
Since WordPress 5.9 has been delayed until January, I'm going to bump this to the 2.3 milestone. |
During further investigation I've found that one more thing needs to be addressed: user can choose to open submenu items "on click". When To ampify it, I used the |
Hi @westonruter, I have tested on the developer Branch and I was QA passed |
Feature description
As shown in What’s new in Gutenberg 10.7? (26 May), there is a new Responsive Navigation block:
This opens a sidebar on a narrow viewport:
We can implement support for this via
amp-sidebar
.When the block has responsive menus enabled, it enqueues the
frontend.js
script which achieves the sidebar modal via the Micromodal library.Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation brief
render_block
filter for thenavigation
block. SeeAMP_Core_Block_Handler
.isResponsive
is set, and if not, short-circuit.wp-block-navigation-view
.amp-sidebar
and amend thebutton
with the necessary action to toggle whether the menu is sidebar is opened.QA testing instructions
Demo
Changelog entry
The text was updated successfully, but these errors were encountered: