From e813cfcb47db83de3058c01a81d81795d6b03808 Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Thu, 11 Jul 2024 13:49:27 +1000 Subject: [PATCH] Use same markup as existing stacked movers --- .../src/components/grid/grid-item-movers.js | 148 ++++++++++++------ 1 file changed, 100 insertions(+), 48 deletions(-) diff --git a/packages/block-editor/src/components/grid/grid-item-movers.js b/packages/block-editor/src/components/grid/grid-item-movers.js index ed8e35c201f7e0..c6c0baadbf6d16 100644 --- a/packages/block-editor/src/components/grid/grid-item-movers.js +++ b/packages/block-editor/src/components/grid/grid-item-movers.js @@ -1,10 +1,21 @@ +/** + * External dependencies + */ +import clsx from 'clsx'; + /** * WordPress dependencies */ import { __ } from '@wordpress/i18n'; -import { ToolbarButton } from '@wordpress/components'; -import { arrowLeft, arrowUp, arrowDown, arrowRight } from '@wordpress/icons'; +import { Button, VisuallyHidden } from '@wordpress/components'; +import { + chevronLeft, + chevronUp, + chevronDown, + chevronRight, +} from '@wordpress/icons'; import { useDispatch } from '@wordpress/data'; +import { useInstanceId } from '@wordpress/compose'; /** * Internal dependencies @@ -43,50 +54,12 @@ export function GridItemMovers( { return ( - { - onChange( { - rowStart: rowStart - 1, - } ); - __unstableMarkNextChangeAsNotPersistent(); - moveBlocksToPosition( - [ blockClientId ], - gridClientId, - gridClientId, - getNumberOfBlocksBeforeCell( - columnStartNumber, - rowStartNumber - 1 - ) - ); - } } - /> - = rowCount } - onClick={ () => { - onChange( { - rowStart: rowStart + 1, - } ); - __unstableMarkNextChangeAsNotPersistent(); - moveBlocksToPosition( - [ blockClientId ], - gridClientId, - gridClientId, - getNumberOfBlocksBeforeCell( - columnStartNumber, - rowStartNumber + 1 - ) - ); - } } - /> - { onChange( { columnStart: columnStartNumber - 1, @@ -103,10 +76,58 @@ export function GridItemMovers( { ); } } /> - + { + onChange( { + rowStart: rowStart - 1, + } ); + __unstableMarkNextChangeAsNotPersistent(); + moveBlocksToPosition( + [ blockClientId ], + gridClientId, + gridClientId, + getNumberOfBlocksBeforeCell( + columnStartNumber, + rowStartNumber - 1 + ) + ); + } } + /> + = rowCount } + onClick={ () => { + onChange( { + rowStart: rowStart + 1, + } ); + __unstableMarkNextChangeAsNotPersistent(); + moveBlocksToPosition( + [ blockClientId ], + gridClientId, + gridClientId, + getNumberOfBlocksBeforeCell( + columnStartNumber, + rowStartNumber + 1 + ) + ); + } } + /> + + = columnCount } + description={ __( 'Move block right' ) } + isDisabled={ columnCount && columnEnd >= columnCount } onClick={ () => { onChange( { columnStart: columnStartNumber + 1, @@ -126,3 +147,34 @@ export function GridItemMovers( { ); } + +function GridItemMover( { + className, + icon, + label, + isDisabled, + onClick, + description, +} ) { + const instanceId = useInstanceId( GridItemMover ); + const descriptionId = `block-editor-block-mover-button__description-${ instanceId }`; + return ( + <> +