diff --git a/packages/block-editor/src/components/block-switcher/pattern-transformations-menu.js b/packages/block-editor/src/components/block-switcher/pattern-transformations-menu.js index 792f6d0bb20121..46fd83c92d91f6 100644 --- a/packages/block-editor/src/components/block-switcher/pattern-transformations-menu.js +++ b/packages/block-editor/src/components/block-switcher/pattern-transformations-menu.js @@ -3,7 +3,7 @@ */ import { __ } from '@wordpress/i18n'; import { useState } from '@wordpress/element'; -import { useInstanceId } from '@wordpress/compose'; +import { useInstanceId, useViewportMatch } from '@wordpress/compose'; import { chevronRight } from '@wordpress/icons'; import { @@ -34,6 +34,7 @@ function PatternTransformationsMenu( { } ) { const [ showTransforms, setShowTransforms ] = useState( false ); const patterns = useTransformedPatterns( statePatterns, blocks ); + if ( ! patterns.length ) { return null; } @@ -60,21 +61,22 @@ function PatternTransformationsMenu( { } function PreviewPatternsPopover( { patterns, onSelect } ) { + const isMobile = useViewportMatch( 'medium', '<' ); + return ( -
-
- -
- -
-
-
+
+ +
+ +
+
); } diff --git a/packages/block-editor/src/components/block-switcher/preview-block-popover.js b/packages/block-editor/src/components/block-switcher/preview-block-popover.js index 78e29f4ad09fba..f978ed43af1da9 100644 --- a/packages/block-editor/src/components/block-switcher/preview-block-popover.js +++ b/packages/block-editor/src/components/block-switcher/preview-block-popover.js @@ -3,6 +3,7 @@ */ import { __ } from '@wordpress/i18n'; import { Popover } from '@wordpress/components'; +import { useViewportMatch } from '@wordpress/compose'; /** * Internal dependencies @@ -10,22 +11,27 @@ import { Popover } from '@wordpress/components'; import BlockPreview from '../block-preview'; export default function PreviewBlockPopover( { blocks } ) { + const isMobile = useViewportMatch( 'medium', '<' ); + + if ( isMobile ) { + return null; + } + return ( -
-
- -
-
- { __( 'Preview' ) } -
- +
+ +
+
+ { __( 'Preview' ) }
- -
+ +
+
); } diff --git a/packages/block-editor/src/components/block-switcher/style.scss b/packages/block-editor/src/components/block-switcher/style.scss index 5eaba08bf94ae2..afcb576bd8db49 100644 --- a/packages/block-editor/src/components/block-switcher/style.scss +++ b/packages/block-editor/src/components/block-switcher/style.scss @@ -84,27 +84,18 @@ min-width: 300px; } -.block-editor-block-switcher__popover__preview__parent { - .block-editor-block-switcher__popover__preview__container { - position: absolute; - top: -$grid-unit-15; - left: calc(100% + #{$grid-unit-20}); - } +.block-editor-block-switcher__popover-preview-container { + left: 0; + position: absolute; + top: -$border-width; + width: 100%; + bottom: 0; + pointer-events: none; } -.block-editor-block-switcher__preview__popover { - display: none; +.block-editor-block-switcher__popover-preview { overflow: hidden; - // Position correctly. Needs specificity. - &.components-popover { - margin-top: $grid-unit-15 - $border-width; - } - - @include break-medium() { - display: block; - } - .components-popover__content { width: 300px; border: $border-width solid $gray-900;