From d031006bfd4c3e406964f8736c08548fd04f2d6c Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Tue, 1 Sep 2020 15:31:06 +0800 Subject: [PATCH] Make draggable chip use same icon as toolbar --- .../block-draggable/draggable-chip.js | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/block-editor/src/components/block-draggable/draggable-chip.js b/packages/block-editor/src/components/block-draggable/draggable-chip.js index 4cce7db9d08028..4c513fdc7acdfd 100644 --- a/packages/block-editor/src/components/block-draggable/draggable-chip.js +++ b/packages/block-editor/src/components/block-draggable/draggable-chip.js @@ -1,11 +1,15 @@ +/** + * External dependencies + */ +import { uniq } from 'lodash'; + /** * WordPress dependencies */ -import { _n, sprintf } from '@wordpress/i18n'; import { getBlockType } from '@wordpress/blocks'; import { useSelect } from '@wordpress/data'; import { Flex, FlexItem } from '@wordpress/components'; -import { dragHandle } from '@wordpress/icons'; +import { dragHandle, stack } from '@wordpress/icons'; /** * Internal dependencies @@ -15,11 +19,17 @@ import BlockIcon from '../block-icon'; export default function BlockDraggableChip( { clientIds } ) { const icon = useSelect( ( select ) => { + const { getBlockName } = select( 'core/block-editor' ); + if ( clientIds.length !== 1 ) { - return; + const blockNames = clientIds.map( getBlockName ); + const isSameType = uniq( blockNames ).length === 1; + + if ( ! isSameType ) { + return stack; + } } - const { getBlockName } = select( 'core/block-editor' ); const [ firstId ] = clientIds; const blockName = getBlockName( firstId ); @@ -36,15 +46,7 @@ export default function BlockDraggableChip( { clientIds } ) { className="block-editor-block-draggable-chip__content" > - { icon ? ( - - ) : ( - sprintf( - /* translators: %d: Number of blocks. */ - _n( '%d block', '%d blocks', clientIds.length ), - clientIds.length - ) - ) } +