Skip to content

Commit

Permalink
Fix toolbar in device preview (#31600)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix authored May 16, 2021
1 parent 66ee794 commit 449fb8b
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function useResizeCanvas(
width: getCanvasWidth( device ),
margin: marginValue() + 'px auto',
height,
borderRadius: '2px',
borderRadius: '2px 2px 2px 2px',
border: '1px solid #ddd',
overflowY: 'auto',
};
Expand Down
124 changes: 64 additions & 60 deletions packages/edit-post/src/components/visual-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function MaybeIframe( {
<div
ref={ contentRef }
className="editor-styles-wrapper"
style={ { width: '100%', height: '100%', ...style } }
style={ style }
>
{ children }
</div>
Expand Down Expand Up @@ -167,14 +167,10 @@ export default function VisualEditor( { styles } ) {
);

return (
<motion.div
<div
className={ classnames( 'edit-post-visual-editor', {
'is-template-mode': isTemplateMode,
} ) }
animate={
isTemplateMode ? { padding: '48px 48px 0' } : { padding: 0 }
}
ref={ blockSelectionClearerRef }
>
{ themeSupportsLayout && (
<LayoutStyle
Expand All @@ -183,67 +179,75 @@ export default function VisualEditor( { styles } ) {
/>
) }
<VisualEditorGlobalKeyboardShortcuts />
{ isTemplateMode && (
<Button
className="edit-post-visual-editor__exit-template-mode"
icon={ arrowLeft }
onClick={ () => {
clearSelectedBlock();
setIsEditingTemplate( false );
<BlockTools __unstableContentRef={ ref }>
<motion.div
className="edit-post-visual-editor__content-area"
animate={ {
padding: isTemplateMode ? '48px 48px 0' : '0',
} }
ref={ blockSelectionClearerRef }
>
{ __( 'Back' ) }
</Button>
) }
<motion.div
animate={ animatedStyles }
initial={ desktopCanvasStyles }
>
<BlockTools __unstableContentRef={ ref }>
<MaybeIframe
isTemplateMode={ isTemplateMode }
contentRef={ contentRef }
styles={ styles }
style={ { paddingBottom } }
{ isTemplateMode && (
<Button
className="edit-post-visual-editor__exit-template-mode"
icon={ arrowLeft }
onClick={ () => {
clearSelectedBlock();
setIsEditingTemplate( false );
} }
>
{ __( 'Back' ) }
</Button>
) }
<motion.div
animate={ animatedStyles }
initial={ desktopCanvasStyles }
>
<AnimatePresence>
<motion.div
key={ isTemplateMode ? 'template' : 'post' }
initial={ { opacity: 0 } }
animate={ { opacity: 1 } }
>
<WritingFlow>
{ ! isTemplateMode && (
<div className="edit-post-visual-editor__post-title-wrapper">
<PostTitle />
</div>
) }
<RecursionProvider>
<BlockList
__experimentalLayout={
themeSupportsLayout
? {
type: 'default',
// Find a way to inject this in the support flag code (hooks).
alignments: themeSupportsLayout
? alignments
: undefined,
}
: undefined
}
/>
</RecursionProvider>
</WritingFlow>
</motion.div>
</AnimatePresence>
</MaybeIframe>
</BlockTools>
</motion.div>
<MaybeIframe
isTemplateMode={ isTemplateMode }
contentRef={ contentRef }
styles={ styles }
style={ { paddingBottom } }
>
<AnimatePresence>
<motion.div
key={ isTemplateMode ? 'template' : 'post' }
initial={ { opacity: 0 } }
animate={ { opacity: 1 } }
>
<WritingFlow>
{ ! isTemplateMode && (
<div className="edit-post-visual-editor__post-title-wrapper">
<PostTitle />
</div>
) }
<RecursionProvider>
<BlockList
__experimentalLayout={
themeSupportsLayout
? {
type: 'default',
// Find a way to inject this in the support flag code (hooks).
alignments: themeSupportsLayout
? alignments
: undefined,
}
: undefined
}
/>
</RecursionProvider>
</WritingFlow>
</motion.div>
</AnimatePresence>
</MaybeIframe>
</motion.div>
</motion.div>
</BlockTools>
<__unstableBlockSettingsMenuFirstItem>
{ ( { onClose } ) => (
<BlockInspectorButton onClick={ onClose } />
) }
</__unstableBlockSettingsMenuFirstItem>
</motion.div>
</div>
);
}
11 changes: 7 additions & 4 deletions packages/edit-post/src/components/visual-editor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,13 @@
// Default background color so that grey .edit-post-editor-regions__content
// color doesn't show through.
background-color: $white;
flex: 1;

cursor: text;

> * {
cursor: auto;
}

> div {
min-height: 100%;
}
}

// Ideally this wrapper div is not needed but if we want to match the positioning of blocks
Expand Down Expand Up @@ -74,3 +71,9 @@
color: $gray-100;
}
}

.edit-post-visual-editor__content-area {
width: 100%;
height: 100%;
position: relative;
}

0 comments on commit 449fb8b

Please sign in to comment.