diff --git a/packages/block-library/src/query/edit/index.js b/packages/block-library/src/query/edit/index.js index 60fc2ebd6170b3..3c91cdc7e3d712 100644 --- a/packages/block-library/src/query/edit/index.js +++ b/packages/block-library/src/query/edit/index.js @@ -22,6 +22,7 @@ const QueryEdit = ( props ) => { [ clientId ] ); const Component = hasInnerBlocks ? QueryContent : QueryPlaceholder; + return ( <> + + + - - - { + setContainerWidth( entry.contentRect.width ); + } ); + + const SMALL_CONTAINER_BREAKPOINT = 160; + + const isSmallContainer = + containerWidth > 0 && containerWidth < SMALL_CONTAINER_BREAKPOINT; + const { blockType, activeBlockVariation } = useSelect( ( select ) => { const { getActiveBlockVariation, getBlockType } = @@ -49,6 +63,10 @@ export default function QueryPlaceholder( { activeBlockVariation?.icon || blockType?.icon?.src; const label = activeBlockVariation?.title || blockType?.title; + const blockProps = useBlockProps( { + ref: resizeObserverRef, + } ); + if ( isStartingBlank ) { return ( + + + - { !! hasPatterns && ( + { !! hasPatterns && ! isSmallContainer && ( + { ! isSmallContainer && ( + + ) } ); diff --git a/packages/block-library/src/query/edit/query-toolbar.js b/packages/block-library/src/query/edit/query-toolbar.js index 25e087ebe1559c..9eafc5aa760709 100644 --- a/packages/block-library/src/query/edit/query-toolbar.js +++ b/packages/block-library/src/query/edit/query-toolbar.js @@ -14,12 +14,20 @@ import { __ } from '@wordpress/i18n'; */ import PatternSelection, { useBlockPatterns } from './pattern-selection'; -export default function QueryToolbar( { clientId, attributes } ) { +export default function QueryToolbar( { + clientId, + attributes, + hasInnerBlocks, +} ) { const hasPatterns = useBlockPatterns( clientId, attributes ).length; if ( ! hasPatterns ) { return null; } + const buttonLabel = hasInnerBlocks + ? __( 'Change design' ) + : __( 'Choose pattern' ); + return ( @@ -33,7 +41,7 @@ export default function QueryToolbar( { clientId, attributes } ) { aria-expanded={ isOpen } onClick={ onToggle } > - { __( 'Change design' ) } + { buttonLabel } ) } renderContent={ () => ( diff --git a/packages/block-library/src/query/editor.scss b/packages/block-library/src/query/editor.scss index ab6b361ed9e98e..4c67489cbb5fcc 100644 --- a/packages/block-library/src/query/editor.scss +++ b/packages/block-library/src/query/editor.scss @@ -1,5 +1,4 @@ .block-library-query-pattern__selection-modal { - .block-editor-block-patterns-list { column-count: 2; column-gap: $grid-unit-30; @@ -53,3 +52,9 @@ margin-bottom: 0; } } + +// Provide special styling for the placeholder. +// @todo this particular minimal style of placeholder could be componentized further. +.wp-block-query > .block-editor-media-placeholder.is-small { + min-height: 60px; +}