Skip to content

Commit

Permalink
Updates to remove scale by default in favour of opt in via prop
Browse files Browse the repository at this point in the history
As discussed here #16113 (comment), there is little point in having thumbnail preview and large popover preview showing the same thing.

Update to introduce a prop to opt in to scaling the preview. By default the preview is no auto-scaled.

Apply `true` value to `BlockPreview` to ensure that Block Styles popover preview is scaled to fit.
  • Loading branch information
getdave authored and retrofox committed Aug 2, 2019
1 parent a55e988 commit 7755b5b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/block-editor/src/components/block-preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { useLayoutEffect, useState, useRef } from '@wordpress/element';
import BlockEditorProvider from '../provider';
import BlockList from '../block-list';

export function BlockPreview( { blocks, settings, srcWidth = 400, srcHeight = 300 } ) {
export function BlockPreview( { blocks, settings, srcWidth = 400, srcHeight = 300, scaleToFit = false } ) {
if ( ! blocks ) {
return null;
}
Expand All @@ -45,6 +45,9 @@ export function BlockPreview( { blocks, settings, srcWidth = 400, srcHeight = 30

// Dynamically calculate the scale factor
useLayoutEffect( () => {
if ( ! scaleToFit ) {
return;
}
// Retrieve the actual width of the element which wraps the preview
// note: this is not the preview itself, but the wrapper element
const destWidth = previewRef.current.offsetWidth;
Expand Down

0 comments on commit 7755b5b

Please sign in to comment.