diff --git a/packages/block-editor/src/components/block-preview/index.js b/packages/block-editor/src/components/block-preview/index.js index b4d0850f3b810..2037bc6a0f2ea 100644 --- a/packages/block-editor/src/components/block-preview/index.js +++ b/packages/block-editor/src/components/block-preview/index.js @@ -2,11 +2,11 @@ * External dependencies */ import { castArray } from 'lodash'; +import classnames from 'classnames'; /** * WordPress dependencies */ -import { __ } from '@wordpress/i18n'; import { Disabled } from '@wordpress/components'; import { withSelect } from '@wordpress/data'; @@ -23,22 +23,24 @@ import BlockList from '../block-list'; * * @return {WPElement} Rendered element. */ -function BlockPreview( props ) { - return ( -
-
{ __( 'Preview' ) }
- -
- ); -} - -export function BlockPreviewContent( { blocks, settings } ) { +function BlockPreview( { blocks, settings, className, isScaled } ) { if ( ! blocks ) { return null; } - return ( - + div { - transform: scale(0.9); - transform-origin: center top; - font-family: $editor-font; - } - - > div section { - height: auto; - } - - > .reusable-block-indicator { - display: none; - } - } -} - -.block-editor-block-preview__content { // Resetting the block editor paddings and margins .block-editor-block-list__layout, .block-editor-block-list__block { @@ -38,9 +12,23 @@ .editor-block-list__block-edit [data-block] { margin-top: 0; } -} -.block-editor-block-preview__title { - margin-bottom: 10px; - color: $dark-gray-300; + > div section { + height: auto; + } + + > .reusable-block-indicator { + display: none; + } + + .block-list-appender { + display: none; + } + + &.is-scaled { + > div { + transform: scale(0.9); + transform-origin: center top; + } + } } diff --git a/packages/block-editor/src/components/block-styles/index.js b/packages/block-editor/src/components/block-styles/index.js index 2485c73e9a0a4..f9270094e4708 100644 --- a/packages/block-editor/src/components/block-styles/index.js +++ b/packages/block-editor/src/components/block-styles/index.js @@ -17,7 +17,7 @@ import { getBlockType, cloneBlock } from '@wordpress/blocks'; /** * Internal dependencies */ -import { BlockPreviewContent } from '../block-preview'; +import BlockPreview from '../block-preview'; /** * Returns the active style from the given className. @@ -122,7 +122,8 @@ function BlockStyles( { aria-label={ style.label || style.name } >
- +
+
{ __( 'Preview' ) }
+ +
} ) } diff --git a/packages/block-editor/src/components/block-switcher/style.scss b/packages/block-editor/src/components/block-switcher/style.scss index b80a586023045..2ef182aca140e 100644 --- a/packages/block-editor/src/components/block-switcher/style.scss +++ b/packages/block-editor/src/components/block-switcher/style.scss @@ -97,18 +97,6 @@ .block-editor-block-switcher__popover .components-popover__content { @include break-medium { position: relative; - - .block-editor-block-preview { - border: $border-width solid $light-gray-500; - box-shadow: $shadow-popover; - background: $white; - position: absolute; - left: 100%; - top: -1px; - bottom: -1px; - width: 300px; - height: auto; - } } // Hide the bottom border on the last panel so it stacks with the popover. @@ -137,3 +125,26 @@ .block-editor-block-switcher__popover .block-editor-block-types-list { margin: 8px -8px -8px; } + +.block-editor-block-switcher__preview { + border: $border-width solid $light-gray-500; + box-shadow: $shadow-popover; + background: $white; + position: absolute; + left: 100%; + top: -1px; + bottom: -1px; + width: 300px; + height: auto; + padding: 10px; + display: none; + + @include break-medium { + display: block; + } +} + +.block-editor-block-switcher__preview-title { + margin-bottom: 10px; + color: $dark-gray-300; +} diff --git a/packages/block-editor/src/components/inserter/menu.js b/packages/block-editor/src/components/inserter/menu.js index 12d119ce4ab51..8fa9a61ea30fd 100644 --- a/packages/block-editor/src/components/inserter/menu.js +++ b/packages/block-editor/src/components/inserter/menu.js @@ -351,7 +351,13 @@ export class InserterMenu extends Component {
{ hoveredItem && isReusableBlock( hoveredItem ) && - +
+
{ __( 'Preview' ) }
+ +
} ); diff --git a/packages/block-editor/src/components/inserter/style.scss b/packages/block-editor/src/components/inserter/style.scss index 87b9a79f12fa4..4cc764ed0861a 100644 --- a/packages/block-editor/src/components/inserter/style.scss +++ b/packages/block-editor/src/components/inserter/style.scss @@ -43,17 +43,6 @@ $block-inserter-search-height: 38px; @include break-medium { width: 400px; position: relative; - - .block-editor-block-preview { - border: $border-width solid $light-gray-500; - box-shadow: $shadow-popover; - background: $white; - position: absolute; - left: 100%; - top: -1px; - bottom: -1px; - width: 300px; - } } } @@ -140,3 +129,26 @@ $block-inserter-search-height: 38px; margin-right: $grid-size; } } + +.block-editor-inserter__preview { + border: $border-width solid $light-gray-500; + box-shadow: $shadow-popover; + background: $white; + position: absolute; + left: 100%; + top: -1px; + bottom: -1px; + width: 300px; + height: auto; + padding: 10px; + display: none; + + @include break-medium { + display: block; + } +} + +.block-editor-inserter__preview-title { + margin-bottom: 10px; + color: $dark-gray-300; +}