Skip to content

Commit

Permalink
Add drag icon and remove from quick inserter
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Dec 15, 2020
1 parent 78d8ca0 commit 7722a7f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function BlockTypesList( {
onHover = () => {},
children,
label,
isDraggable = true,
} ) {
const composite = useCompositeState();
const orderId = items.reduce( ( acc, item ) => acc + '--' + item.id, '' );
Expand Down Expand Up @@ -50,6 +51,7 @@ function BlockTypesList( {
onSelect={ onSelect }
onHover={ onHover }
composite={ composite }
isDraggable={ isDraggable }
/>
);
} ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function InserterListItem( {
item,
onSelect,
onHover,
isDraggable,
...props
} ) {
const isDragging = useRef( false );
Expand All @@ -47,7 +48,7 @@ function InserterListItem( {

return (
<InserterListItemDraggable
isEnabled={ ! item.disabled }
isEnabled={ isDraggable && ! item.disabled }
blocks={ blocks }
icon={ item.icon }
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
transition: all 0.15s ease-out;
@include reduce-motion("transition");
}

.block-editor-block-types-list__list-item[draggable="true"] & {
cursor: grab;
}
}

.block-editor-block-types-list__item-title {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export default function QuickInserter( {
selectBlockOnInsert={ selectBlockOnInsert }
maxBlockPatterns={ showPatterns ? SHOWN_BLOCK_PATTERNS : 0 }
maxBlockTypes={ SHOWN_BLOCK_TYPES }
isDraggable={ false }
/>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function InserterSearchResults( {
maxBlockPatterns,
maxBlockTypes,
showBlockDirectory = false,
isDraggable = true,
} ) {
const debouncedSpeak = useDebounce( speak, 500 );

Expand Down Expand Up @@ -116,6 +117,7 @@ function InserterSearchResults( {
onSelect={ onSelectBlockType }
onHover={ onHover }
label={ __( 'Blocks' ) }
isDraggable={ isDraggable }
/>
</InserterPanel>
) }
Expand Down

0 comments on commit 7722a7f

Please sign in to comment.