From 883fc3d207bef0bb032bc03ae7fa3f7ea100743a Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Thu, 24 Oct 2024 18:48:52 +0900 Subject: [PATCH] Search: Replace ButtonGroup usage with ToggleGroupControl (#65340) Co-authored-by: Mamaduka Co-authored-by: ciampo Co-authored-by: tyxla Co-authored-by: t-hamano Co-authored-by: mirka <0mirka00@git.wordpress.org> --- packages/block-library/src/search/edit.js | 51 ++++++++++++----------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/packages/block-library/src/search/edit.js b/packages/block-library/src/search/edit.js index d4ed5b7e3a405..b68914893c0e8 100644 --- a/packages/block-library/src/search/edit.js +++ b/packages/block-library/src/search/edit.js @@ -23,14 +23,14 @@ import { useEffect, useRef } from '@wordpress/element'; import { ToolbarDropdownMenu, ToolbarGroup, - Button, - ButtonGroup, ToolbarButton, ResizableBox, PanelBody, __experimentalVStack as VStack, __experimentalUseCustomUnits as useCustomUnits, __experimentalUnitControl as UnitControl, + __experimentalToggleGroupControl as ToggleGroupControl, + __experimentalToggleGroupControlOption as ToggleGroupControlOption, } from '@wordpress/components'; import { useInstanceId } from '@wordpress/compose'; import { Icon, search } from '@wordpress/icons'; @@ -58,6 +58,7 @@ import { // Used to calculate border radius adjustment to avoid "fat" corners when // button is placed inside wrapper. const DEFAULT_INNER_PADDING = '4px'; +const PERCENTAGE_WIDTHS = [ 25, 50, 75, 100 ]; export default function SearchEdit( { className, @@ -445,33 +446,35 @@ export default function SearchEdit( { value={ `${ width }${ widthUnit }` } units={ units } /> - { + setAttributes( { + width: newWidth, + widthUnit: '%', + } ); + } } + isBlock + __next40pxDefaultSize + __nextHasNoMarginBottom > - { [ 25, 50, 75, 100 ].map( ( widthValue ) => { + { PERCENTAGE_WIDTHS.map( ( widthValue ) => { return ( - + value={ widthValue } + label={ `${ widthValue }%` } + /> ); } ) } - +