Skip to content

Commit

Permalink
added shown by default to toolspanelitem and added dropdownMenuProps
Browse files Browse the repository at this point in the history
  • Loading branch information
NidhiDhandhukiya74 committed Feb 7, 2025
1 parent 021b67c commit 23fc7ff
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/block-library/src/site-logo/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
Button,
DropZone,
FlexItem,
PanelBody,
__experimentalToolsPanel as ToolsPanel,
__experimentalToolsPanelItem as ToolsPanelItem,
__experimentalItemGroup as ItemGroup,
Expand All @@ -48,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/*';
Expand All @@ -71,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(
Expand Down Expand Up @@ -279,11 +282,13 @@ const SiteLogo = ( {
<InspectorControls>
<ToolsPanel label={ __( 'Settings' ) }>
<ToolsPanelItem
isShownByDefault
hasValue={ () => !! width }
label={ __( 'Image width' ) }
onDeselect={ () =>
setAttributes( { width: undefined } )
}
dropdownMenuProps={ dropdownMenuProps }
>
<RangeControl
__nextHasNoMarginBottom
Expand All @@ -304,6 +309,7 @@ const SiteLogo = ( {
</ToolsPanelItem>

<ToolsPanelItem
isShownByDefault
hasValue={ () => !! isLink }
label={ __( 'Link image to home' ) }
onDeselect={ () => setAttributes( { isLink: false } ) }
Expand All @@ -320,6 +326,7 @@ const SiteLogo = ( {

{ isLink && (
<ToolsPanelItem
isShownByDefault
hasValue={ () => linkTarget === '_blank' }
label={ __( 'Open in new tab' ) }
onDeselect={ () =>
Expand All @@ -341,6 +348,7 @@ const SiteLogo = ( {

{ canUserEdit && (
<ToolsPanelItem
isShownByDefault
hasValue={ () => !! shouldSyncIcon }
label={ __( 'Use as Site Icon' ) }
onDeselect={ () => {
Expand Down Expand Up @@ -664,7 +672,7 @@ export default function LogoEdit( {
<DropZone onFilesDrop={ onFilesDrop } />
</>
) }
</div>
</div>
</PanelBody>
</InspectorControls>
);
Expand Down

0 comments on commit 23fc7ff

Please sign in to comment.