Skip to content

Commit

Permalink
Add prompt for drag and drop in Patterns tab in Zoom Out mode (#65115)
Browse files Browse the repository at this point in the history
* Add prompt for drag and drop

* Remove icon and update styles

* Use components and tweak

* Avoid muted variant
  • Loading branch information
getdave authored Sep 9, 2024
1 parent 7376a63 commit 2f92b59
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
__experimentalText as Text,
FlexBlock,
} from '@wordpress/components';
import { useSelect } from '@wordpress/data';

/**
* Internal dependencies
Expand All @@ -32,6 +33,7 @@ import {
myPatternsCategory,
INSERTER_PATTERN_TYPES,
} from './utils';
import { store as blockEditorStore } from '../../../store';

const noop = () => {};

Expand All @@ -42,6 +44,11 @@ export function PatternCategoryPreviews( {
category,
showTitlesAsTooltip,
} ) {
const isZoomOutMode = useSelect(
( select ) =>
select( blockEditorStore ).__unstableGetEditorMode() === 'zoom-out',
[]
);
const [ allPatterns, , onClickPattern ] = usePatternsState(
onInsert,
rootClientId,
Expand Down Expand Up @@ -163,23 +170,39 @@ export function PatternCategoryPreviews( {
</Text>
) }
</VStack>

{ currentCategoryPatterns.length > 0 && (
<BlockPatternsList
ref={ scrollContainerRef }
shownPatterns={ pagingProps.categoryPatternsAsyncList }
blockPatterns={ pagingProps.categoryPatterns }
onClickPattern={ onClickPattern }
onHover={ onHover }
label={ category.label }
orientation="vertical"
category={ category.name }
isDraggable
showTitlesAsTooltip={ showTitlesAsTooltip }
patternFilter={ patternSourceFilter }
pagingProps={ pagingProps }
/>
) }
<VStack spacing={ 4 }>
{ currentCategoryPatterns.length > 0 && (
<>
{ isZoomOutMode && (
<Text
size="12"
as="p"
className="block-editor-inserter__help-text"
>
{ __(
'Drag and drop patterns into the canvas.'
) }
</Text>
) }
<BlockPatternsList
ref={ scrollContainerRef }
shownPatterns={
pagingProps.categoryPatternsAsyncList
}
blockPatterns={ pagingProps.categoryPatterns }
onClickPattern={ onClickPattern }
onHover={ onHover }
label={ category.label }
orientation="vertical"
category={ category.name }
isDraggable
showTitlesAsTooltip={ showTitlesAsTooltip }
patternFilter={ patternSourceFilter }
pagingProps={ pagingProps }
/>
</>
) }
</VStack>
</>
);
}
4 changes: 4 additions & 0 deletions packages/block-editor/src/components/inserter/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -709,3 +709,7 @@ $block-inserter-tabs-height: 44px;
}
}
}

.block-editor-tabbed-sidebar__tabpanel .block-editor-inserter__help-text {
padding: 0 $grid-unit-30;
}

0 comments on commit 2f92b59

Please sign in to comment.