diff --git a/packages/block-library/src/site-logo/edit.js b/packages/block-library/src/site-logo/edit.js index d2d2327736fd72..6fefbe3bbc0140 100644 --- a/packages/block-library/src/site-logo/edit.js +++ b/packages/block-library/src/site-logo/edit.js @@ -14,7 +14,6 @@ import { } from '@wordpress/element'; import { __, isRTL } from '@wordpress/i18n'; import { - PanelBody, RangeControl, ResizableBox, Spinner, @@ -24,6 +23,9 @@ import { Button, DropZone, FlexItem, + PanelBody, + __experimentalToolsPanel as ToolsPanel, + __experimentalToolsPanelItem as ToolsPanelItem, __experimentalItemGroup as ItemGroup, __experimentalHStack as HStack, __experimentalTruncate as Truncate, @@ -47,6 +49,7 @@ import { store as noticesStore } from '@wordpress/notices'; * Internal dependencies */ import { MIN_SIZE } from '../image/constants'; +import { useToolsPanelDropdownMenuProps } from '../utils/hooks'; const ALLOWED_MEDIA_TYPES = [ 'image' ]; const ACCEPT_MEDIA_STRING = 'image/*'; @@ -70,6 +73,7 @@ const SiteLogo = ( { const [ { naturalWidth, naturalHeight }, setNaturalSize ] = useState( {} ); const [ isEditingImage, setIsEditingImage ] = useState( false ); const { toggleSelection } = useDispatch( blockEditorStore ); + const dropdownMenuProps = useToolsPanelDropdownMenuProps(); const { imageEditing, maxWidth, title } = useSelect( ( select ) => { const settings = select( blockEditorStore ).getSettings(); const siteEntities = select( coreStore ).getEntityRecord( @@ -276,31 +280,59 @@ const SiteLogo = ( { return ( <> - - + !! width } label={ __( 'Image width' ) } - onChange={ ( newWidth ) => - setAttributes( { width: newWidth } ) + onDeselect={ () => + setAttributes( { width: undefined } ) } - min={ minWidth } - max={ maxWidthBuffer } - initialPosition={ Math.min( - defaultWidth, - maxWidthBuffer - ) } - value={ width || '' } - disabled={ ! isResizable } - /> - + + setAttributes( { width: newWidth } ) + } + min={ minWidth } + max={ maxWidthBuffer } + initialPosition={ Math.min( + defaultWidth, + maxWidthBuffer + ) } + value={ width || '' } + disabled={ ! isResizable } + /> + + + ! isLink } label={ __( 'Link image to home' ) } - onChange={ () => setAttributes( { isLink: ! isLink } ) } - checked={ isLink } - /> + onDeselect={ () => setAttributes( { isLink: true } ) } + > + + setAttributes( { isLink: ! isLink } ) + } + checked={ isLink } + /> + + { isLink && ( - <> + linkTarget === '_blank' } + label={ __( 'Open in new tab' ) } + onDeselect={ () => + setAttributes( { linkTarget: '_self' } ) + } + > - + ) } + { canUserEdit && ( - <> + !! shouldSyncIcon } + label={ __( 'Use as Site Icon' ) } + onDeselect={ () => { + setAttributes( { shouldSyncIcon: false } ); + setIcon( undefined ); + } } + > - + ) } - + { canEditImage && ! isEditingImage && (