Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
* @this {import('.').SiteEditor}
*/
export async function enterEditMode() {
await this.page.click( '.edit-site-layout__edit-button' );
await this.page.click( '.edit-site-layout__edit-button-canvas-header' );
}
6 changes: 4 additions & 2 deletions packages/e2e-test-utils/src/site-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,13 @@ export async function openPreviousGlobalStylesPanel() {
* Enters edit mode.
*/
export async function enterEditMode() {
const editSiteToggle = await page.$( '.edit-site-layout__edit-button' );
const editSiteToggle = await page.$(
'.edit-site-layout__edit-button-canvas-header'
);
// This check is necessary for the performance tests in old branches
// where the site editor toggle was not implemented yet.
if ( ! editSiteToggle ) {
return;
}
await page.click( '.edit-site-layout__edit-button' );
await page.click( '.edit-site-layout__edit-button-canvas-header' );
}
28 changes: 21 additions & 7 deletions packages/edit-site/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export default function Layout( { onError } ) {
canvasMode === 'edit' &&
! isMobileViewport ) ||
isMobileCanvasVisible,
'is-editor-page': isEditorPage,
} ) }
>
<div className="edit-site-layout__header">
Expand Down Expand Up @@ -217,14 +218,27 @@ export default function Layout( { onError } ) {
</AnimatePresence>

{ showCanvas && (
<div
className="edit-site-layout__canvas-container"
style={ {
paddingTop: showFrame ? canvasPadding : 0,
paddingBottom: showFrame ? canvasPadding : 0,
} }
>
<div className="edit-site-layout__canvas-container">
{ canvasResizer }
{ isEditorPage &&
canvasMode === 'view' &&
! isMobileViewport && (
<HStack
className="edit-site-layout__canvas-header"
alignment="right"
>
<Button
className="edit-site-layout__edit-button-canvas-header"
isPrimary
label={ __( 'Open the editor' ) }
onClick={ () => {
__unstableSetCanvasMode( 'edit' );
} }
>
{ __( 'Edit' ) }
</Button>
</HStack>
) }
{ !! canvasSize.width && (
<motion.div
initial={ false }
Expand Down
15 changes: 15 additions & 0 deletions packages/edit-site/src/components/layout/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,21 @@
width: 100%;
border-radius: 0;
}

.edit-site-layout.is-editor-page:not(.is-full-canvas) & {
@include break-small {
top: $header-height;
}
}
}

.edit-site-layout__canvas-header {
padding-right: $canvas-padding;
height: $header-height;
}

.edit-site-layout__edit-button-canvas-header {
height: 32px;
}

// This shouldn't be necessary (we should have a way to say that a skeletton is relative
Expand Down
20 changes: 0 additions & 20 deletions packages/edit-site/src/components/sidebar-navigation-root/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ import {
__experimentalItemGroup as ItemGroup,
__experimentalVStack as VStack,
__experimentalHStack as HStack,
Button,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { layout, symbolFilled } from '@wordpress/icons';
import { useDispatch } from '@wordpress/data';
import { useViewportMatch } from '@wordpress/compose';

/**
* Internal dependencies
Expand All @@ -19,13 +16,9 @@ import SidebarNavigationTitle from '../sidebar-navigation-title';
import { useLink } from '../routes/link';
import SidebarNavigationItem from '../sidebar-navigation-item';
import { useLocation } from '../routes';
import { store as editSiteStore } from '../../store';
import getIsListPage from '../../utils/get-is-list-page';

export default function SidebarNavigationRoot() {
const { params } = useLocation();
const isListPage = getIsListPage( params );
const isEditorPage = ! isListPage;
const templatesLink = useLink( {
postType: 'wp_template',
postId: undefined,
Expand All @@ -34,8 +27,6 @@ export default function SidebarNavigationRoot() {
postType: 'wp_template_part',
postId: undefined,
} );
const { __unstableSetCanvasMode } = useDispatch( editSiteStore );
const isMobileViewport = useViewportMatch( 'medium', '<' );
const isTemplatesPage =
params.postType === 'wp_template' && ! params.postId;
const isTemplatePartsPage =
Expand All @@ -47,17 +38,6 @@ export default function SidebarNavigationRoot() {
title={
<HStack style={ { minHeight: 36 } }>
<div>{ __( 'Design' ) }</div>
{ ! isMobileViewport && isEditorPage && (
<Button
className="edit-site-layout__edit-button"
label={ __( 'Open the editor' ) }
onClick={ () => {
__unstableSetCanvasMode( 'edit' );
} }
>
{ __( 'Edit' ) }
</Button>
) }
</HStack>
}
/>
Expand Down