From c4fdeb1bbae02f56701fb199e44a20efb90d2df2 Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Fri, 3 Mar 2023 12:25:04 +0000 Subject: [PATCH] Navigation Sidebar: Change the logic about which navigation gets selected for the sidebar (#48689) * Navigation Sidebar: Change the logic about which navigation gets selected for the sidebar * Move the navigation sidebar appender into the actions area of the sidebar * Further simplification * Fixed allowed blocks and update appender label * Fix inserter issue * Delay the rendering of the navigation menus * Remove useless code * update comment --------- Co-authored-by: Riad Benguella --- .../src/components/inserter/index.js | 19 +- .../components/off-canvas-editor/branch.js | 4 +- .../src/components/off-canvas-editor/index.js | 3 + .../components/navigation-inspector/index.js | 223 ------------------ .../navigation-inspector/navigation-menu.js | 66 ------ .../navigation-inspector/style.scss | 46 ---- .../src/components/sidebar-button/style.scss | 3 +- .../sidebar-navigation-item/style.scss | 20 -- .../index.js | 125 +++++++++- .../loader.js | 9 + .../navigation-menu-content.js | 56 +++++ .../style.scss | 59 ++++- packages/edit-site/src/style.scss | 1 - 13 files changed, 256 insertions(+), 378 deletions(-) delete mode 100644 packages/edit-site/src/components/navigation-inspector/index.js delete mode 100644 packages/edit-site/src/components/navigation-inspector/navigation-menu.js delete mode 100644 packages/edit-site/src/components/navigation-inspector/style.scss create mode 100644 packages/edit-site/src/components/sidebar-navigation-screen-navigation-menus/loader.js create mode 100644 packages/edit-site/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js diff --git a/packages/block-editor/src/components/inserter/index.js b/packages/block-editor/src/components/inserter/index.js index d1613fc1f9d40f..99355b7027136f 100644 --- a/packages/block-editor/src/components/inserter/index.js +++ b/packages/block-editor/src/components/inserter/index.js @@ -31,21 +31,26 @@ const defaultRenderToggle = ( { toggleProps = {}, prioritizePatterns, } ) => { - let label; - if ( hasSingleBlockType ) { + const { + as: Wrapper = Button, + label: labelProp, + onClick, + ...rest + } = toggleProps; + + let label = labelProp; + if ( ! label && hasSingleBlockType ) { label = sprintf( // translators: %s: the name of the block when there is only one _x( 'Add %s', 'directly add the only allowed block' ), blockTitle ); - } else if ( prioritizePatterns ) { + } else if ( ! label && prioritizePatterns ) { label = __( 'Add pattern' ); - } else { + } else if ( ! label ) { label = _x( 'Add block', 'Generic label for block inserter button' ); } - const { onClick, ...rest } = toggleProps; - // Handle both onClick functions from the toggle and the parent component. function handleClick( event ) { if ( onToggle ) { @@ -57,7 +62,7 @@ const defaultRenderToggle = ( { } return ( -