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

Codespace siyath123 ubiquitous giggle 7q75j5pv666cr66 #52565

Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
__unstableUseCompositeState as useCompositeState,
__unstableCompositeItem as CompositeItem,
Tooltip,
__experimentalTruncate as Truncate,
} from '@wordpress/components';
import { useInstanceId } from '@wordpress/compose';
import { __ } from '@wordpress/i18n';
Expand All @@ -25,6 +26,17 @@ const WithToolTip = ( { showTooltip, title, children } ) => {
return <>{ children }</>;
};

function BlockPatternItemPlaceholder( { title } ) {
return (
<div className="block-editor-block-patterns-list__empty-item">
<Truncate numberOfLines={ 2 }>{ title }</Truncate>
<span className="block-editor-block-patterns-list__empty-item-text">
{ __( '(Empty pattern)' ) }
</span>
</div>
);
}

function BlockPattern( {
isDraggable,
pattern,
Expand All @@ -37,6 +49,7 @@ function BlockPattern( {
const { blocks, viewportWidth } = pattern;
const instanceId = useInstanceId( BlockPattern );
const descriptionId = `block-editor-block-patterns-list__item-description-${ instanceId }`;
const isEmpty = ! blocks?.length;

return (
<InserterDraggableBlocks
Expand Down Expand Up @@ -87,10 +100,17 @@ function BlockPattern( {
pattern.description ? descriptionId : undefined
}
>
<BlockPreview
blocks={ blocks }
viewportWidth={ viewportWidth }
/>
{ ! isEmpty ? (
<BlockPreview
blocks={ blocks }
viewportWidth={ viewportWidth }
/>
) : (
<BlockPatternItemPlaceholder
title={ pattern.title }
/>
) }

{ ! showTooltip && (
<div className="block-editor-block-patterns-list__item-title">
{ pattern.title }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@
.block-editor-block-patterns-list__item {
height: 100%;

.block-editor-block-patterns-list__empty-item {
min-height: 60px;
display: flex;
flex-flow: column;
align-items: center;
justify-content: center;
color: $gray-600;
border: 1px solid $gray-400;
padding: $grid-unit-10;
border-radius: 4px;
}

.block-editor-block-patterns-list__empty-item-text {
margin-top: $grid-unit-10;
font-size: 11px;
display: inline-block;
}

.block-editor-block-preview__container {
display: flex;
align-items: center;
Expand All @@ -32,10 +50,12 @@
text-align: center;
}

&:hover .block-editor-block-patterns-list__empty-item,
&:hover .block-editor-block-preview__container {
box-shadow: 0 0 0 2px var(--wp-admin-theme-color);
}

&:focus .block-editor-block-patterns-list__empty-item,
&:focus .block-editor-block-preview__container {
@include button-style-outset__focus(var(--wp-admin-theme-color));
}
Expand Down