diff --git a/packages/block-library/src/search/edit.js b/packages/block-library/src/search/edit.js index 42d5df1c159cb..d00adf23ca391 100644 --- a/packages/block-library/src/search/edit.js +++ b/packages/block-library/src/search/edit.js @@ -9,7 +9,9 @@ import classnames from 'classnames'; import { __experimentalBlock as Block, BlockControls, + InspectorControls, RichText, + __experimentalUnitControl as UnitControl, } from '@wordpress/block-editor'; import { DropdownMenu, @@ -19,7 +21,10 @@ import { Button, ToolbarButton, ResizableBox, + PanelBody, + BaseControl, } from '@wordpress/components'; +import { useInstanceId } from '@wordpress/compose'; import { search } from '@wordpress/icons'; import { __ } from '@wordpress/i18n'; @@ -53,6 +58,8 @@ export default function SearchEdit( { } = attributes; const MIN_WIDTH = 120; + const unitControlInstanceId = useInstanceId( UnitControl ); + const unitControlInputId = `wp-block-search__width-${ unitControlInstanceId }`; const getBlockClassNames = () => { return classnames( @@ -148,89 +155,107 @@ export default function SearchEdit( { }; const controls = ( - - - { - setAttributes( { - showLabel: ! showLabel, - } ); - } } - className={ showLabel ? 'is-pressed' : undefined } - /> - - - - - { ( { onClose } ) => ( - - { - setAttributes( { - buttonPosition: 'no-button', - } ); - onClose(); - } } - > - { __( 'No Button' ) } - - { - setAttributes( { - buttonPosition: 'button-outside', - } ); - onClose(); - } } - > - { __( 'Button Outside' ) } - - { - setAttributes( { - buttonPosition: 'button-inside', - } ); - onClose(); - } } - > - { __( 'Button Inside' ) } - - { - setAttributes( { - buttonPosition: 'button-only', - } ); - onClose(); - } } - > - { __( 'Button Only' ) } - - - ) } - - - { 'no-button' !== buttonPosition && ( + <> + + { setAttributes( { - buttonUseIcon: ! buttonUseIcon, + showLabel: ! showLabel, } ); } } - className={ buttonUseIcon ? 'is-pressed' : undefined } + className={ showLabel ? 'is-pressed' : undefined } /> - ) } - - + + + + + { ( { onClose } ) => ( + + { + setAttributes( { + buttonPosition: 'no-button', + } ); + onClose(); + } } + > + { __( 'No Button' ) } + + { + setAttributes( { + buttonPosition: 'button-outside', + } ); + onClose(); + } } + > + { __( 'Button Outside' ) } + + { + setAttributes( { + buttonPosition: 'button-inside', + } ); + onClose(); + } } + > + { __( 'Button Inside' ) } + + { + setAttributes( { + buttonPosition: 'button-only', + } ); + onClose(); + } } + > + { __( 'Button Only' ) } + + + ) } + + + { 'no-button' !== buttonPosition && ( + { + setAttributes( { + buttonUseIcon: ! buttonUseIcon, + } ); + } } + className={ buttonUseIcon ? 'is-pressed' : undefined } + /> + ) } + + + + + + + + setAttributes( { width: newWidth } ) + } + style={ { maxWidth: 80 } } + value={ width } + /> + + + + ); return (