Skip to content

Commit

Permalink
Reduce divs
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed May 28, 2021
1 parent ccaea25 commit 4c1f6c5
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 61 deletions.
8 changes: 6 additions & 2 deletions packages/block-editor/src/components/block-tools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ import { usePopoverScroll } from './use-popover-scroll';
* @param {Object} $0.children The block content and style container.
* @param {Object} $0.__unstableContentRef Ref holding the content scroll container.
*/
export default function BlockTools( { children, __unstableContentRef } ) {
export default function BlockTools( {
children,
__unstableContentRef,
...props
} ) {
const isLargeViewport = useViewportMatch( 'medium' );
const hasFixedToolbar = useSelect(
( select ) => select( blockEditorStore ).getSettings().hasFixedToolbar,
Expand Down Expand Up @@ -110,7 +114,7 @@ export default function BlockTools( { children, __unstableContentRef } ) {

return (
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
<div onKeyDown={ onKeyDown }>
<div { ...props } onKeyDown={ onKeyDown }>
<InsertionPoint __unstableContentRef={ __unstableContentRef }>
{ ( hasFixedToolbar || ! isLargeViewport ) && (
<BlockContextualToolbar isFixed />
Expand Down
117 changes: 58 additions & 59 deletions packages/edit-post/src/components/visual-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,79 +175,78 @@ export default function VisualEditor( { styles } ) {
);

return (
<div
<BlockTools
__unstableContentRef={ ref }
className={ classnames( 'edit-post-visual-editor', {
'is-template-mode': isTemplateMode,
} ) }
>
<VisualEditorGlobalKeyboardShortcuts />
<BlockTools __unstableContentRef={ ref }>
<motion.div
className="edit-post-visual-editor__content-area"
animate={ {
padding: isTemplateMode ? '48px 48px 0' : '0',
} }
ref={ blockSelectionClearerRef }
>
{ isTemplateMode && (
<Button
className="edit-post-visual-editor__exit-template-mode"
icon={ arrowLeft }
onClick={ () => {
clearSelectedBlock();
setIsEditingTemplate( false );
} }
>
{ __( 'Back' ) }
</Button>
) }
<motion.div
className="edit-post-visual-editor__content-area"
animate={ {
padding: isTemplateMode ? '48px 48px 0' : '0',
} }
ref={ blockSelectionClearerRef }
animate={ animatedStyles }
initial={ desktopCanvasStyles }
>
{ isTemplateMode && (
<Button
className="edit-post-visual-editor__exit-template-mode"
icon={ arrowLeft }
onClick={ () => {
clearSelectedBlock();
setIsEditingTemplate( false );
} }
>
{ __( 'Back' ) }
</Button>
) }
<motion.div
animate={ animatedStyles }
initial={ desktopCanvasStyles }
<MaybeIframe
isTemplateMode={ isTemplateMode }
contentRef={ contentRef }
styles={ styles }
style={ { paddingBottom } }
>
<MaybeIframe
isTemplateMode={ isTemplateMode }
contentRef={ contentRef }
styles={ styles }
style={ { paddingBottom } }
>
{ themeSupportsLayout && (
<LayoutStyle
selector=".edit-post-visual-editor__post-title-wrapper, .block-editor-block-list__layout.is-root-container"
layout={ defaultLayout }
/>
{ themeSupportsLayout && (
<LayoutStyle
selector=".edit-post-visual-editor__post-title-wrapper, .block-editor-block-list__layout.is-root-container"
layout={ defaultLayout }
/>
) }
<WritingFlow>
{ ! isTemplateMode && (
<div className="edit-post-visual-editor__post-title-wrapper">
<PostTitle />
</div>
) }
<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>
</MaybeIframe>
</motion.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>
</MaybeIframe>
</motion.div>
</BlockTools>
</motion.div>
<__unstableBlockSettingsMenuFirstItem>
{ ( { onClose } ) => (
<BlockInspectorButton onClick={ onClose } />
) }
</__unstableBlockSettingsMenuFirstItem>
</div>
</BlockTools>
);
}

0 comments on commit 4c1f6c5

Please sign in to comment.