Skip to content

Commit

Permalink
Adjust block selection button (#60348)
Browse files Browse the repository at this point in the history
* adds drag button to zoom out, rearranges buttons, removes block name in zoom out

* remove double block mover
  • Loading branch information
draganescu committed Apr 3, 2024
1 parent 7f868d4 commit 68bd62a
Showing 1 changed file with 51 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ function BlockSelectionButton( { clientId, rootClientId } ) {
);

const dragHandleLabel = __( 'Drag' );
const showBlockDraggable =
( canMove && editorMode === 'navigation' ) ||
( editorMode === 'zoom-out' && canMove && ! isBlockTemplatePart );

return (
<div className={ classNames }>
Expand All @@ -291,20 +294,8 @@ function BlockSelectionButton( { clientId, rootClientId } ) {
<FlexItem>
<BlockIcon icon={ icon } showColors />
</FlexItem>
<FlexItem>
{ editorMode === 'zoom-out' && ! isBlockTemplatePart && (
<BlockMover
clientIds={ [ clientId ] }
hideDragHandle
isBlockMoverUpButtonDisabled={
isPrevBlockTemplatePart
}
isBlockMoverDownButtonDisabled={
isNextBlockTemplatePart
}
/>
) }
{ editorMode === 'navigation' && (
{ showBlockDraggable && (
<FlexItem>
<BlockDraggable clientIds={ [ clientId ] }>
{ ( draggableProps ) => (
<Button
Expand All @@ -319,41 +310,59 @@ function BlockSelectionButton( { clientId, rootClientId } ) {
/>
) }
</BlockDraggable>
) }
</FlexItem>
</FlexItem>
) }
{ editorMode === 'zoom-out' && ! isBlockTemplatePart && (
<FlexItem>
<BlockMover
clientIds={ [ clientId ] }
hideDragHandle
isBlockMoverUpButtonDisabled={
isPrevBlockTemplatePart
}
isBlockMoverDownButtonDisabled={
isNextBlockTemplatePart
}
/>
</FlexItem>
) }
{ canMove && canRemove && editorMode === 'zoom-out' && (
<Shuffle clientId={ clientId } as={ Button } />
) }
{ canRemove &&
editorMode === 'zoom-out' &&
! isBlockTemplatePart && (
<ToolbarButton
icon={ trash }
label="Delete"
onClick={ () => {
removeBlock( clientId );
} }
/>
<FlexItem>
<ToolbarButton
icon={ trash }
label="Delete"
onClick={ () => {
removeBlock( clientId );
} }
/>
</FlexItem>
) }
<FlexItem>
<Button
ref={ ref }
onClick={
editorMode === 'navigation'
? () => setNavigationMode( false )
: undefined
}
onKeyDown={ onKeyDown }
label={ label }
showTooltip={ false }
className="block-selection-button_select-button"
>
<BlockTitle
clientId={ clientId }
maximumLength={ 35 }
/>
</Button>
</FlexItem>
{ editorMode === 'navigation' && (
<FlexItem>
<Button
ref={ ref }
onClick={
editorMode === 'navigation'
? () => setNavigationMode( false )
: undefined
}
onKeyDown={ onKeyDown }
label={ label }
showTooltip={ false }
className="block-selection-button_select-button"
>
<BlockTitle
clientId={ clientId }
maximumLength={ 35 }
/>
</Button>
</FlexItem>
) }
</Flex>
</div>
);
Expand Down

0 comments on commit 68bd62a

Please sign in to comment.