diff --git a/packages/block-library/src/navigation/edit/index.js b/packages/block-library/src/navigation/edit/index.js index ae7dd60bd0c5b..b1918ff201805 100644 --- a/packages/block-library/src/navigation/edit/index.js +++ b/packages/block-library/src/navigation/edit/index.js @@ -31,7 +31,8 @@ import { EntityProvider, store as coreStore } from '@wordpress/core-data'; import { useDispatch, useSelect } from '@wordpress/data'; import { - PanelBody, + __experimentalToolsPanel as ToolsPanel, + __experimentalToolsPanelItem as ToolsPanelItem, ToggleControl, __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, @@ -72,6 +73,7 @@ import DeletedNavigationWarning from './deleted-navigation-warning'; import AccessibleDescription from './accessible-description'; import AccessibleMenuDescription from './accessible-menu-description'; import { unlock } from '../../lock-unlock'; +import { useToolsPanelDropdownMenuProps } from '../../utils/hooks'; function ColorTools( { textColor, @@ -583,11 +585,25 @@ function Navigation( { `overlay-menu-preview` ); + const dropdownMenuProps = useToolsPanelDropdownMenuProps(); + const stylingInspectorControls = ( <> { hasSubmenuIndicatorSetting && ( - + { + setAttributes( { + showSubmenuIcon: true, + openSubmenusOnClick: false, + overlayMenu: 'mobile', + hasIcon: true, + icon: 'handle', + } ); + } } + dropdownMenuProps={ dropdownMenuProps } + > { isResponsive && ( <> -
- { overlayMenuPreview && ( + { overlayMenuPreview && ( +
+
+ ) } ) } - overlayMenu !== 'mobile' } label={ __( 'Overlay Menu' ) } - aria-label={ __( 'Configure overlay menu' ) } - value={ overlayMenu } - help={ __( - 'Collapses the navigation options in a menu icon opening an overlay.' - ) } - onChange={ ( value ) => - setAttributes( { overlayMenu: value } ) + onDeselect={ () => + setAttributes( { overlayMenu: 'mobile' } ) } - isBlock + isShownByDefault > - - - - + + setAttributes( { overlayMenu: value } ) + } + isBlock + > + + + + + + { hasSubmenus && ( <> -

{ __( 'Submenus' ) }

- { - setAttributes( { - openSubmenusOnClick: value, - ...( value && { - showSubmenuIcon: true, - } ), // Make sure arrows are shown when we toggle this on. - } ); - } } +

+ { __( 'Submenus' ) } +

+ openSubmenusOnClick } label={ __( 'Open on click' ) } - /> - - { + onDeselect={ () => setAttributes( { - showSubmenuIcon: value, - } ); - } } - disabled={ attributes.openSubmenusOnClick } + openSubmenusOnClick: false, + showSubmenuIcon: true, + } ) + } + isShownByDefault + > + { + setAttributes( { + openSubmenusOnClick: value, + ...( value && { + showSubmenuIcon: true, + } ), // Make sure arrows are shown when we toggle this on. + } ); + } } + label={ __( 'Open on click' ) } + /> + + + ! showSubmenuIcon } label={ __( 'Show arrow' ) } - /> + onDeselect={ () => + setAttributes( { + showSubmenuIcon: true, + } ) + } + isDisabled={ + attributes.openSubmenusOnClick + } + isShownByDefault + > + { + setAttributes( { + showSubmenuIcon: value, + } ); + } } + disabled={ + attributes.openSubmenusOnClick + } + label={ __( 'Show arrow' ) } + /> + { submenuAccessibilityNotice && ( -
+
) } - + ) } diff --git a/packages/block-library/src/navigation/edit/overlay-menu-preview.js b/packages/block-library/src/navigation/edit/overlay-menu-preview.js index cdd4d6e3263c9..c73ba71c1afcb 100644 --- a/packages/block-library/src/navigation/edit/overlay-menu-preview.js +++ b/packages/block-library/src/navigation/edit/overlay-menu-preview.js @@ -5,6 +5,7 @@ import { ToggleControl, __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, + __experimentalToolsPanelItem as ToolsPanelItem, } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; @@ -16,36 +17,52 @@ import OverlayMenuIcon from './overlay-menu-icon'; export default function OverlayMenuPreview( { setAttributes, hasIcon, icon } ) { return ( <> - setAttributes( { hasIcon: value } ) } - checked={ hasIcon } - /> + isShownByDefault + hasValue={ () => ! hasIcon } + onDeselect={ () => setAttributes( { hasIcon: true } ) } + > + + setAttributes( { hasIcon: value } ) + } + checked={ hasIcon } + /> + - setAttributes( { icon: value } ) } - isBlock + isShownByDefault + hasValue={ () => icon !== 'handle' } + onDeselect={ () => setAttributes( { icon: 'handle' } ) } > - } - /> - } - /> - + setAttributes( { icon: value } ) } + isBlock + > + } + /> + } + /> + + ); } diff --git a/packages/block-library/src/navigation/editor.scss b/packages/block-library/src/navigation/editor.scss index 2f61a19be2b79..f547169101e95 100644 --- a/packages/block-library/src/navigation/editor.scss +++ b/packages/block-library/src/navigation/editor.scss @@ -569,7 +569,7 @@ body.editor-styles-wrapper .wp-block-navigation__responsive-container.is-menu-op // Ref - https://github.com/WordPress/gutenberg/pull/65075#discussion_r1746282734 height: $grid-unit-40 * 2 !important; - margin-bottom: $grid-unit-15; + grid-column: span 2; &.open { box-shadow: inset 0 0 0 $border-width $gray-200; @@ -637,7 +637,19 @@ body.editor-styles-wrapper .wp-block-navigation__responsive-container.is-menu-op margin-left: 24px; } -.wp-block-navigation__overlay-menu-icon-toggle-group { - // Counteract the margin added by the block inspector. - margin-bottom: $grid-unit-20; +.editor-sidebar__panel .wp-block-navigation__submenu-header { + margin-top: 0; + margin-bottom: 0; +} + +.wp-block-navigation__overlay-menu-preview-controls { + grid-column: span 2; + + .components-tools-panel-item:first-child { + margin-bottom: 16px; + } +} + +.wp-block-navigation__submenu-accessibility-notice { + grid-column: span 2; }