From 9c048483d2fcfbd011f50d40d570cd343a05cea1 Mon Sep 17 00:00:00 2001 From: NidhiDhandhukiya74 Date: Fri, 13 Dec 2024 16:20:06 +0530 Subject: [PATCH 1/2] refactor site logo media panel --- packages/block-library/src/site-logo/edit.js | 34 +++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/packages/block-library/src/site-logo/edit.js b/packages/block-library/src/site-logo/edit.js index 36c217c1bf0c79..813a71cc30ab5e 100644 --- a/packages/block-library/src/site-logo/edit.js +++ b/packages/block-library/src/site-logo/edit.js @@ -24,6 +24,8 @@ import { Button, DropZone, FlexItem, + __experimentalToolsPanel as ToolsPanel, + __experimentalToolsPanelItem as ToolsPanelItem, __experimentalItemGroup as ItemGroup, __experimentalHStack as HStack, __experimentalTruncate as Truncate, @@ -597,8 +599,20 @@ export default function LogoEdit( { const mediaInspectorPanel = ( canUserEdit || logoUrl ) && ( - -
+ { + setAttributes( { + logoUrl: null, + mediaItemData: null, + } ); + } } + > + !! logoUrl && ! canUserEdit } + label={ __( 'Preview Logo (Read-only)' ) } + resetAll={ () => setAttributes( { logoUrl: null } ) } + > { ! canUserEdit && !! logoUrl && ( ) } + + !! logoUrl && canUserEdit } + label={ __( 'Replace Logo' ) } + resetAll={ () => setAttributes( { logoUrl: null } ) } + > { canUserEdit && !! logoUrl && ( ) } + + ! logoUrl && canUserEdit } + label={ __( 'Upload Logo' ) } + resetAll={ () => setAttributes( { logoUrl: null } ) } + > { canUserEdit && ! logoUrl && ( ) } -
-
+ +
); From 2db9acadc435a9ca53842ffca6de34c6ed9d5e2d Mon Sep 17 00:00:00 2001 From: NidhiDhandhukiya74 Date: Fri, 20 Dec 2024 15:27:46 +0530 Subject: [PATCH 2/2] refractor site settings of site logo --- packages/block-library/src/site-logo/edit.js | 83 ++++++++++++++------ 1 file changed, 57 insertions(+), 26 deletions(-) diff --git a/packages/block-library/src/site-logo/edit.js b/packages/block-library/src/site-logo/edit.js index 813a71cc30ab5e..074235b5f5d64b 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, @@ -280,31 +279,55 @@ 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: false } ) } + > + + 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 && (