Skip to content

Commit

Permalink
Site editor: convert device type margin styles into non-shorthand syn…
Browse files Browse the repository at this point in the history
…tax (#50441)

* Split margin styles into individual size

* Apply iframe custom marings only when scale is not 1
  • Loading branch information
ciampo authored May 15, 2023
1 parent efaadb1 commit 541b0dd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
21 changes: 12 additions & 9 deletions packages/block-editor/src/components/iframe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] ) }
Expand Down
10 changes: 9 additions & 1 deletion packages/block-editor/src/components/use-resize-canvas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 541b0dd

Please sign in to comment.