diff --git a/packages/block-library/src/navigation/edit/index.js b/packages/block-library/src/navigation/edit/index.js index 51e473fffdd68..a732c4f3824a0 100644 --- a/packages/block-library/src/navigation/edit/index.js +++ b/packages/block-library/src/navigation/edit/index.js @@ -32,6 +32,8 @@ import { __experimentalToggleGroupControlOption as ToggleGroupControlOption, Button, Spinner, + __experimentalHStack as HStack, + __experimentalHeading as Heading, } from '@wordpress/components'; import { __, sprintf } from '@wordpress/i18n'; import { speak } from '@wordpress/a11y'; @@ -650,56 +652,82 @@ function Navigation( { // Consider this state as 'unsaved' and offer an uncontrolled version of inner blocks, // that automatically saves the menu as an entity when changes are made to the inner blocks. const hasUnsavedBlocks = hasUncontrolledInnerBlocks && ! isEntityAvailable; + + const WrappedNavigationMenuSelector = ( { currentMenuId } ) => ( + { + handleUpdateMenu( menuId ); + } } + onSelectClassicMenu={ async ( classicMenu ) => { + const navMenu = await convertClassicMenu( + classicMenu.id, + classicMenu.name, + 'draft' + ); + if ( navMenu ) { + handleUpdateMenu( navMenu.id, { + focusNavigationBlock: true, + } ); + } + } } + onCreateNew={ createUntitledEmptyNavigationMenu } + createNavigationMenuIsSuccess={ createNavigationMenuIsSuccess } + createNavigationMenuIsError={ createNavigationMenuIsError } + /* translators: %s: The name of a menu. */ + actionLabel={ __( "Switch to '%s'" ) } + /> + ); + if ( hasUnsavedBlocks ) { return ( - - { - handleUpdateMenu( menuId ); - } } - onSelectClassicMenu={ async ( classicMenu ) => { - const navMenu = await convertClassicMenu( - classicMenu.id, - classicMenu.name, - 'draft' - ); - if ( navMenu ) { - handleUpdateMenu( navMenu.id, { - focusNavigationBlock: true, - } ); - } - } } - onCreateNew={ createUntitledEmptyNavigationMenu } - createNavigationMenuIsSuccess={ - createNavigationMenuIsSuccess - } - /* translators: %s: The name of a menu. */ - actionLabel={ __( "Switch to '%s'" ) } - /> - { isOffCanvasNavigationEditorEnabled && ( - - ) } - { ! isOffCanvasNavigationEditorEnabled && ( - + + { isOffCanvasNavigationEditorEnabled ? ( + <> + + + { __( 'Menu' ) } + + + + + + ) : ( + <> + + + ) } @@ -746,45 +774,46 @@ function Navigation( { return ( - - { - handleUpdateMenu( menuId ); - } } - onSelectClassicMenu={ async ( classicMenu ) => { - const navMenu = await convertClassicMenu( - classicMenu.id, - classicMenu.name, - 'draft' - ); - if ( navMenu ) { - handleUpdateMenu( navMenu.id, { - focusNavigationBlock: true, - } ); - } - } } - onCreateNew={ createUntitledEmptyNavigationMenu } - createNavigationMenuIsSuccess={ - createNavigationMenuIsSuccess - } - /* translators: %s: The name of a menu. */ - actionLabel={ __( "Switch to '%s'" ) } - /> - { ! isOffCanvasNavigationEditorEnabled && ( - + + { isOffCanvasNavigationEditorEnabled ? ( + <> + + + { __( 'Menu' ) } + + + +

Select or create a menu

+ + ) : ( + <> + + + ) }
@@ -863,55 +892,50 @@ function Navigation( { - - { - handleUpdateMenu( menuId ); - } } - onSelectClassicMenu={ async ( classicMenu ) => { - const navMenu = await convertClassicMenu( - classicMenu.id, - classicMenu.name, - 'draft' - ); - if ( navMenu ) { - handleUpdateMenu( navMenu.id, { - focusNavigationBlock: true, - } ); - } - } } - onCreateNew={ createUntitledEmptyNavigationMenu } - createNavigationMenuIsSuccess={ - createNavigationMenuIsSuccess - } - createNavigationMenuIsError={ - createNavigationMenuIsError - } - /* translators: %s: The name of a menu. */ - actionLabel={ __( "Switch to '%s'" ) } - /> - { isOffCanvasNavigationEditorEnabled && ( - - ) } - { ! isOffCanvasNavigationEditorEnabled && ( - + + { isOffCanvasNavigationEditorEnabled ? ( + <> + + + { __( 'Menu' ) } + + + + + + ) : ( + <> + + + ) } diff --git a/packages/block-library/src/navigation/edit/navigation-menu-selector.js b/packages/block-library/src/navigation/edit/navigation-menu-selector.js index 036d86f06f215..8103dfeef3d1b 100644 --- a/packages/block-library/src/navigation/edit/navigation-menu-selector.js +++ b/packages/block-library/src/navigation/edit/navigation-menu-selector.js @@ -10,7 +10,7 @@ import { VisuallyHidden, } from '@wordpress/components'; import { useEntityProp } from '@wordpress/core-data'; -import { Icon, chevronUp, chevronDown } from '@wordpress/icons'; +import { Icon, chevronUp, chevronDown, moreVertical } from '@wordpress/icons'; import { __, sprintf } from '@wordpress/i18n'; import { decodeEntities } from '@wordpress/html-entities'; import { useEffect, useMemo, useState } from '@wordpress/element'; @@ -31,6 +31,9 @@ function NavigationMenuSelector( { createNavigationMenuIsError, toggleProps = {}, } ) { + const isOffCanvasNavigationEditorEnabled = + window?.__experimentalEnableOffCanvasNavigationEditor === true; + /* translators: %s: The name of a menu. */ const createActionLabel = __( "Create from '%s'" ); @@ -161,11 +164,19 @@ function NavigationMenuSelector( { return ( { ( { onClose } ) => ( <> diff --git a/packages/block-library/src/navigation/editor.scss b/packages/block-library/src/navigation/editor.scss index 9e7b9ff91e943..68802b67adf81 100644 --- a/packages/block-library/src/navigation/editor.scss +++ b/packages/block-library/src/navigation/editor.scss @@ -540,6 +540,13 @@ body.editor-styles-wrapper color: inherit; } +.components-heading.wp-block-navigation-off-canvas-editor__title { + margin: 0; +} +.wp-block-navigation-off-canvas-editor__header { + margin-bottom: $grid-unit-10; +} + // Customize the mobile editing. // This can be revisited in the future, but for now, inherit design from the parent. .is-menu-open .wp-block-navigation__responsive-container-content * {