Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor site logo media panel. #67972

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions packages/block-library/src/site-logo/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {
Button,
DropZone,
FlexItem,
__experimentalToolsPanel as ToolsPanel,
__experimentalToolsPanelItem as ToolsPanelItem,
__experimentalItemGroup as ItemGroup,
__experimentalHStack as HStack,
__experimentalTruncate as Truncate,
Expand Down Expand Up @@ -597,8 +599,20 @@ export default function LogoEdit( {

const mediaInspectorPanel = ( canUserEdit || logoUrl ) && (
<InspectorControls>
<PanelBody title={ __( 'Media' ) }>
<div className="block-library-site-logo__inspector-media-replace-container">
<ToolsPanel
label={ __( 'Media' ) }
resetAll={ () => {
setAttributes( {
logoUrl: null,
mediaItemData: null,
} );
} }
>
<ToolsPanelItem
hasValue={ () => !! logoUrl && ! canUserEdit }
label={ __( 'Preview Logo (Read-only)' ) }
resetAll={ () => setAttributes( { logoUrl: null } ) }
>
{ ! canUserEdit && !! logoUrl && (
<InspectorLogoPreview
mediaItemData={ mediaItemData }
Expand All @@ -609,6 +623,12 @@ export default function LogoEdit( {
} }
/>
) }
</ToolsPanelItem>
<ToolsPanelItem
hasValue={ () => !! logoUrl && canUserEdit }
label={ __( 'Replace Logo' ) }
resetAll={ () => setAttributes( { logoUrl: null } ) }
>
{ canUserEdit && !! logoUrl && (
<SiteLogoReplaceFlow
{ ...mediaReplaceFlowProps }
Expand All @@ -620,6 +640,12 @@ export default function LogoEdit( {
popoverProps={ {} }
/>
) }
</ToolsPanelItem>
<ToolsPanelItem
hasValue={ () => ! logoUrl && canUserEdit }
label={ __( 'Upload Logo' ) }
resetAll={ () => setAttributes( { logoUrl: null } ) }
>
{ canUserEdit && ! logoUrl && (
<MediaUploadCheck>
<MediaUpload
Expand All @@ -644,8 +670,8 @@ export default function LogoEdit( {
/>
</MediaUploadCheck>
) }
</div>
</PanelBody>
</ToolsPanelItem>
</ToolsPanel>
</InspectorControls>
);

Expand Down
Loading