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: Set min-width for styles preview #41198

Merged
merged 3 commits into from
May 20, 2022
Merged
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
19 changes: 17 additions & 2 deletions packages/edit-site/src/components/global-styles/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
__experimentalVStack as VStack,
} from '@wordpress/components';
import { useReducedMotion, useResizeObserver } from '@wordpress/compose';
import { useState } from '@wordpress/element';
import { useState, useMemo } from '@wordpress/element';

/**
* Internal dependencies
Expand Down Expand Up @@ -79,10 +79,25 @@ const StylesPreview = ( { label, isFocused } ) => {
)
.slice( 0, 2 );

// Reset leaked styles from WP common.css.
const editorStyles = useMemo( () => {
if ( styles ) {
return [
...styles,
{
css: 'body{min-width: 0;}',
isGlobalStyles: true,
},
];
}

return styles;
}, [ styles ] );

return (
<Iframe
className="edit-site-global-styles-preview__iframe"
head={ <EditorStyles styles={ styles } /> }
head={ <EditorStyles styles={ editorStyles } /> }
style={ {
height: normalizedHeight * ratio,
visibility: ! width ? 'hidden' : 'visible',
Expand Down