Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site editor: convert device type margin styles into non-shorthand syntax #50441

Merged
merged 2 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be the correct intention, since scale has a default value of 1 even when it's not passed as a prop.

? -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
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