From 7f8c1059a912d75c3c58eb5049ee8ccd33fa2ce5 Mon Sep 17 00:00:00 2001 From: Vicente Canales Date: Tue, 12 Oct 2021 16:39:45 -0300 Subject: [PATCH 01/16] Enable always-on burger menu in the editor --- .../block-library/src/navigation/block.json | 17 +++++++++-- packages/block-library/src/navigation/edit.js | 12 ++++++++ .../block-library/src/navigation/editor.scss | 6 ---- .../src/navigation/responsive-wrapper.js | 8 +++++- .../block-library/src/navigation/style.scss | 28 +++++++++++-------- 5 files changed, 49 insertions(+), 22 deletions(-) diff --git a/packages/block-library/src/navigation/block.json b/packages/block-library/src/navigation/block.json index 273ac75dd65f3e..c50e34f167b6bc 100644 --- a/packages/block-library/src/navigation/block.json +++ b/packages/block-library/src/navigation/block.json @@ -4,7 +4,11 @@ "title": "Navigation", "category": "theme", "description": "A collection of blocks that allow visitors to get around your site.", - "keywords": [ "menu", "navigation", "links" ], + "keywords": [ + "menu", + "navigation", + "links" + ], "textdomain": "default", "attributes": { "orientation": { @@ -36,7 +40,7 @@ "type": "boolean", "default": true }, - "openSubmenusOnClick":{ + "openSubmenusOnClick": { "type": "boolean", "default": false }, @@ -44,6 +48,10 @@ "type": "boolean", "default": false }, + "isHiddenByDefault": { + "type": "boolean", + "default": false + }, "__unstableLocation": { "type": "string" }, @@ -77,7 +85,10 @@ "orientation": "orientation" }, "supports": { - "align": [ "wide", "full" ], + "align": [ + "wide", + "full" + ], "anchor": true, "html": false, "inserter": true, diff --git a/packages/block-library/src/navigation/edit.js b/packages/block-library/src/navigation/edit.js index d5ef92a4c894f2..8acb240ae9c860 100644 --- a/packages/block-library/src/navigation/edit.js +++ b/packages/block-library/src/navigation/edit.js @@ -281,6 +281,17 @@ function Navigation( { } } label={ __( 'Enable responsive menu' ) } /> + { + setAttributes( { + isHiddenByDefault: value, + } ); + } } + label={ __( + 'Always hide Navigation Menu behind toggle' + ) } + /> { @@ -353,6 +364,7 @@ function Navigation( { onToggle={ setResponsiveMenuVisibility } isOpen={ isResponsiveMenuOpen } isResponsive={ attributes.isResponsive } + isHiddenByDefault={ attributes.isHiddenByDefault } >
diff --git a/packages/block-library/src/navigation/editor.scss b/packages/block-library/src/navigation/editor.scss index 07afc4ceb4394e..5906cbe7993226 100644 --- a/packages/block-library/src/navigation/editor.scss +++ b/packages/block-library/src/navigation/editor.scss @@ -397,12 +397,6 @@ $color-control-label-height: 20px; } } } -.components-button.wp-block-navigation__responsive-container-open { - @include break-small { - display: none; - } -} - // Emulate the fullscreen editing inside the editor. // Most of this can be removed when the iframe lands. diff --git a/packages/block-library/src/navigation/responsive-wrapper.js b/packages/block-library/src/navigation/responsive-wrapper.js index b29cdbdef7c902..1786ba974b75f8 100644 --- a/packages/block-library/src/navigation/responsive-wrapper.js +++ b/packages/block-library/src/navigation/responsive-wrapper.js @@ -17,6 +17,7 @@ export default function ResponsiveWrapper( { isOpen, isResponsive, onToggle, + isHiddenByDefault, } ) { if ( ! isResponsive ) { return children; @@ -25,8 +26,13 @@ export default function ResponsiveWrapper( { 'wp-block-navigation__responsive-container', { 'is-menu-open': isOpen, + 'hidden-by-default': isHiddenByDefault, } ); + const openButtonClasses = classnames( + 'wp-block-navigation__responsive-container-open', + { 'always-on': isHiddenByDefault } + ); const modalId = `${ id }-modal`; @@ -37,7 +43,7 @@ export default function ResponsiveWrapper( { aria-haspopup="true" aria-expanded={ isOpen } aria-label={ __( 'Open menu' ) } - className="wp-block-navigation__responsive-container-open" + className={ openButtonClasses } onClick={ () => onToggle( true ) } > Date: Tue, 12 Oct 2021 16:52:04 -0300 Subject: [PATCH 02/16] enable always hidden responsive menu --- .../block-library/src/navigation/index.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index 5b4b03f3a420d9..d134e1d6585e43 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -296,9 +296,20 @@ function render_block_core_navigation( $attributes, $content, $block ) { ); } + $is_hidden_by_default = isset( $attributes['isHiddenByDefault'] ) && true === $attributes['isHiddenByDefault']; + + $responsive_container_classes = array( + 'wp-block-navigation__responsive-container', + $is_hidden_by_default ? 'hidden-by-default' : '', + ); + $open_button_classes = array( + 'wp-block-navigation__responsive-container-open', + $is_hidden_by_default ? 'always-on' : '', + ); + $responsive_container_markup = sprintf( - ' -