From 45356c58b8b0da01a4cc2a67b91123a47393b7a1 Mon Sep 17 00:00:00 2001 From: Sainath Poojary Date: Mon, 16 Dec 2024 13:10:09 +0530 Subject: [PATCH 1/3] Navigation: Refactor display panel to use ToolsPanel --- .../src/navigation/edit/index.js | 165 ++++++++++++------ 1 file changed, 113 insertions(+), 52 deletions(-) diff --git a/packages/block-library/src/navigation/edit/index.js b/packages/block-library/src/navigation/edit/index.js index ae7dd60bd0c5ba..30b852a27ffef1 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,13 +585,34 @@ function Navigation( { `overlay-menu-preview` ); + const dropdownMenuProps = useToolsPanelDropdownMenuProps(); + const stylingInspectorControls = ( <> { hasSubmenuIndicatorSetting && ( - + { + setAttributes( { + overlayMenu: 'mobile', + openSubmenusOnClick: false, + showSubmenuIcon: true, + hasIcon: true, + icon: 'handle', + } ); + } } + dropdownMenuProps={ dropdownMenuProps } + > { isResponsive && ( - <> + overlayMenuPreview } + label={ __( 'Overlay menu controls' ) } + onDeselect={ () => + setOverlayMenuPreview( false ) + } + isShownByDefault + > -
- { overlayMenuPreview && ( + { overlayMenuPreview && ( +
+
+ ) } ) } @@ -683,7 +686,9 @@ function Navigation( { { hasSubmenus && ( <> -

{ __( 'Submenus' ) }

+

+ { __( 'Submenus' ) } +

openSubmenusOnClick } label={ __( 'Open on click' ) } @@ -739,7 +744,7 @@ function Navigation( { { submenuAccessibilityNotice && ( -
+