From 8b68c3629b7a6cdc49f321b2c7b085b2d336dc4b Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 8 May 2023 20:01:43 +0200 Subject: [PATCH 1/2] Split margin styles into individual size --- .../src/components/use-resize-canvas/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/use-resize-canvas/index.js b/packages/block-editor/src/components/use-resize-canvas/index.js index d329e20d6106e..fab0b7a15e2af 100644 --- a/packages/block-editor/src/components/use-resize-canvas/index.js +++ b/packages/block-editor/src/components/use-resize-canvas/index.js @@ -47,12 +47,20 @@ export default function useResizeCanvas( deviceType ) { const contentInlineStyles = ( device ) => { const height = device === 'Mobile' ? '768px' : '1024px'; + const marginVertical = marginValue() + 'px'; + const marginHorizontal = 'auto'; + switch ( device ) { case 'Tablet': case 'Mobile': return { width: getCanvasWidth( device ), - margin: marginValue() + 'px auto', + // Keeping margin styles separate to avoid warnings + // when those props get overridden in the iframe component + marginTop: marginVertical, + marginBottom: marginVertical, + marginLeft: marginHorizontal, + marginRight: marginHorizontal, height, borderRadius: '2px 2px 2px 2px', border: '1px solid #ddd', From 457ab32517531c8c7ba93575ab8c2a56839c39e8 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Tue, 9 May 2023 00:53:14 +0200 Subject: [PATCH 2/2] Apply iframe custom marings only when scale is not 1 --- .../src/components/iframe/index.js | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/block-editor/src/components/iframe/index.js b/packages/block-editor/src/components/iframe/index.js index c6639f9e057e1..a61200b4b1f1c 100644 --- a/packages/block-editor/src/components/iframe/index.js +++ b/packages/block-editor/src/components/iframe/index.js @@ -260,15 +260,18 @@ function Iframe( { style={ { ...props.style, height: expand ? contentHeight : props.style?.height, - marginTop: scale - ? -marginFromScaling + frameSize - : props.style?.marginTop, - marginBottom: scale - ? -marginFromScaling + frameSize - : props.style?.marginBottom, - transform: scale - ? `scale( ${ scale } )` - : props.style?.transform, + marginTop: + scale !== 1 + ? -marginFromScaling + frameSize + : props.style?.marginTop, + marginBottom: + scale !== 1 + ? -marginFromScaling + frameSize + : props.style?.marginBottom, + transform: + scale !== 1 + ? `scale( ${ scale } )` + : props.style?.transform, transition: 'all .3s', } } ref={ useMergeRefs( [ ref, setRef ] ) }