Skip to content

Commit

Permalink
Iframe tablet and mobile device previews (#33342)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix authored Aug 19, 2021
1 parent 9d143b1 commit 82c953c
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 210 deletions.
1 change: 0 additions & 1 deletion packages/block-editor/src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,4 @@ export { default as __experimentalUseNoRecursiveRenders } from './use-no-recursi
*/

export { default as BlockEditorProvider } from './provider';
export { default as __experimentalUseSimulatedMediaQuery } from './use-simulated-media-query';
export { default as useSetting } from './use-setting';
19 changes: 2 additions & 17 deletions packages/block-editor/src/components/use-resize-canvas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,14 @@
*/
import { useEffect, useState } from '@wordpress/element';

/**
* Internal dependencies
*/
import { default as useSimulatedMediaQuery } from '../../components/use-simulated-media-query';

/**
* Function to resize the editor window.
*
* @param {string} deviceType Used for determining the size of the container (e.g. Desktop, Tablet, Mobile)
* @param {boolean} __unstableDisableSimulation Whether to disable media query simulation.
* @param {string} deviceType Used for determining the size of the container (e.g. Desktop, Tablet, Mobile)
*
* @return {Object} Inline styles to be added to resizable container.
*/
export default function useResizeCanvas(
deviceType,
__unstableDisableSimulation
) {
export default function useResizeCanvas( deviceType ) {
const [ actualWidth, updateActualWidth ] = useState( window.innerWidth );

useEffect( () => {
Expand Down Expand Up @@ -72,11 +63,5 @@ export default function useResizeCanvas(
}
};

const width = __unstableDisableSimulation
? null
: getCanvasWidth( deviceType );

useSimulatedMediaQuery( 'resizable-editor-section', width );

return contentInlineStyles( deviceType );
}

This file was deleted.

14 changes: 0 additions & 14 deletions packages/block-editor/src/style.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
// This tag marks the start of the styles that apply to editing canvas contents and need to be manipulated when we resize the editor.
#start-resizable-editor-section {
display: none;
}

// Only add styles for components that are used inside the editing canvas here:

@import "./autocompleters/style.scss";
@import "./components/block-alignment-matrix-control/style.scss";
@import "./components/block-icon/style.scss";
Expand Down Expand Up @@ -63,13 +56,6 @@
@import "./hooks/layout.scss";
@import "./hooks/border.scss";

// This tag marks the end of the styles that apply to editing canvas contents and need to be manipulated when we resize the editor.
#end-resizable-editor-section {
display: none;
}

// Styles for components that are used outside of the editing canvas go here:

@import "./components/block-toolbar/style.scss";
@import "./components/inserter/style.scss";
@import "./components/preview-options/style.scss";
Expand Down
10 changes: 0 additions & 10 deletions packages/block-library/src/editor.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// This tag marks the start of the styles that apply to editing canvas contents and need to be manipulated when we resize the editor.
#start-resizable-editor-section {
display: none;
}

@import "./archives/editor.scss";
@import "./audio/editor.scss";
@import "./block/editor.scss";
Expand Down Expand Up @@ -95,8 +90,3 @@
* These are only output in the editor, but styles here are NOT prefixed .editor-styles-wrapper.
* This allows us to create normalization styles that are easily overridden by editor styles.
*/

// This tag marks the end of the styles that apply to editing canvas contents and need to be manipulated when we resize the editor.
#end-resizable-editor-section {
display: none;
}
5 changes: 0 additions & 5 deletions packages/block-library/src/style.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// This tag marks the start of the styles that apply to editing canvas contents and need to be manipulated when we resize the editor.
#start-resizable-editor-section {
display: none;
}

@import "./archives/style.scss";
@import "./audio/style.scss";
@import "./button/style.scss";
Expand Down
10 changes: 0 additions & 10 deletions packages/block-library/src/theme.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// This tag marks the start of the styles that apply to editing canvas contents and need to be manipulated when we resize the editor.
#start-resizable-editor-section {
display: none;
}

@import "./audio/theme.scss";
@import "./code/theme.scss";
@import "./embed/theme.scss";
Expand All @@ -16,8 +11,3 @@
@import "./table/theme.scss";
@import "./video/theme.scss";
@import "./template-part/theme.scss";

// This tag marks the end of the styles that apply to editing canvas contents and need to be manipulated when we resize the editor.
#end-resizable-editor-section {
display: none;
}
16 changes: 7 additions & 9 deletions packages/edit-post/src/components/visual-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,10 @@ import { __ } from '@wordpress/i18n';
import BlockInspectorButton from './block-inspector-button';
import { store as editPostStore } from '../../store';

function MaybeIframe( {
children,
contentRef,
isTemplateMode,
styles,
style,
} ) {
function MaybeIframe( { children, contentRef, shouldIframe, styles, style } ) {
const ref = useMouseMoveTypingReset();

if ( ! isTemplateMode ) {
if ( ! shouldIframe ) {
return (
<>
<EditorStyles styles={ styles } />
Expand Down Expand Up @@ -217,7 +211,11 @@ export default function VisualEditor( { styles } ) {
className={ previewMode }
>
<MaybeIframe
isTemplateMode={ isTemplateMode }
shouldIframe={
isTemplateMode ||
deviceType === 'Tablet' ||
deviceType === 'Mobile'
}
contentRef={ contentRef }
styles={ styles }
style={ { paddingBottom } }
Expand Down

0 comments on commit 82c953c

Please sign in to comment.