From 9b3e07f0ac02ad9fd4ea42450591070abef6122c Mon Sep 17 00:00:00 2001 From: Prasad Karmalkar Date: Thu, 19 Dec 2024 21:49:29 +0530 Subject: [PATCH] Refactor "Settings" panel of Spacer block to use ToolsPanel instead of PanelBody (#67981) Co-authored-by: prasadkarmalkar Co-authored-by: fabiankaegy --- packages/block-library/src/spacer/controls.js | 57 ++++++++++++++----- 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/packages/block-library/src/spacer/controls.js b/packages/block-library/src/spacer/controls.js index 1e899e15aff0de..fde06d3ee8c339 100644 --- a/packages/block-library/src/spacer/controls.js +++ b/packages/block-library/src/spacer/controls.js @@ -10,10 +10,11 @@ import { privateApis as blockEditorPrivateApis, } from '@wordpress/block-editor'; import { - PanelBody, __experimentalUseCustomUnits as useCustomUnits, __experimentalUnitControl as UnitControl, __experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue, + __experimentalToolsPanel as ToolsPanel, + __experimentalToolsPanelItem as ToolsPanelItem, } from '@wordpress/components'; import { useInstanceId } from '@wordpress/compose'; import { View } from '@wordpress/primitives'; @@ -94,28 +95,54 @@ export default function SpacerControls( { } ) { return ( - + { + setAttributes( { + width: undefined, + height: '100px', + } ); + } } + > { orientation === 'horizontal' && ( - - setAttributes( { width: nextWidth } ) + isShownByDefault + hasValue={ () => width !== undefined } + onDeselect={ () => + setAttributes( { width: undefined } ) } - isResizing={ isResizing } - /> + > + + setAttributes( { width: nextWidth } ) + } + isResizing={ isResizing } + /> + ) } { orientation !== 'horizontal' && ( - - setAttributes( { height: nextHeight } ) + isShownByDefault + hasValue={ () => height !== '100px' } + onDeselect={ () => + setAttributes( { height: '100px' } ) } - isResizing={ isResizing } - /> + > + + setAttributes( { height: nextHeight } ) + } + isResizing={ isResizing } + /> + ) } - + ); }