Skip to content

Commit

Permalink
Trying to fix site editor side bar navigation: putting the mobile sid…
Browse files Browse the repository at this point in the history
…ebar in sitecontent to get the context, also rendering edit mode.
  • Loading branch information
ramonjd committed Dec 4, 2024
1 parent f32a49e commit 990a1c9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
3 changes: 2 additions & 1 deletion packages/edit-site/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,10 @@ function Layout() {
isResizableFrameOversized
}
/>
{ areas.mobile }
</SidebarContent>
) }
{ areas.mobile }
{ canvas === 'edit' ? areas.mobile : null }
</div>
) }

Expand Down
26 changes: 25 additions & 1 deletion packages/edit-site/src/components/site-editor-routes/patterns.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,39 @@
/**
* WordPress dependencies
*/
import { privateApis as routerPrivateApis } from '@wordpress/router';

/**
* Internal dependencies
*/
import Editor from '../editor';
import { unlock } from '../../lock-unlock';
import SidebarNavigationScreenPatterns from '../sidebar-navigation-screen-patterns';
import PagePatterns from '../page-patterns';

const { useLocation } = unlock( routerPrivateApis );

function MobilePatternsView() {
const { query = {} } = useLocation();
const { canvas = 'view', postType, categoryId } = query;

if ( canvas === 'edit' ) {
return <Editor />;
}

if ( postType === 'wp_block' && !! categoryId ) {
return <PagePatterns />;
}

return <SidebarNavigationScreenPatterns backPath="/" />;
}

export const patternsRoute = {
name: 'patterns',
path: '/pattern',
areas: {
sidebar: <SidebarNavigationScreenPatterns backPath="/" />,
content: <PagePatterns />,
mobile: <PagePatterns />,
mobile: <MobilePatternsView />,
},
};
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
/**
* WordPress dependencies
*/
import { privateApis as routerPrivateApis } from '@wordpress/router';

/**
* Internal dependencies
*/
import Editor from '../editor';
import SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse';
import { unlock } from '../../lock-unlock';
import PageTemplates from '../page-templates';

const { useLocation } = unlock( routerPrivateApis );

function MobileTemplatesView() {
const { query = {} } = useLocation();
const { canvas = 'view' } = query;

return canvas === 'edit' ? (
<Editor />
) : (
<SidebarNavigationScreenTemplatesBrowse backPath="/" />
);
}

export const templatesRoute = {
name: 'templates',
path: '/template',
Expand All @@ -34,7 +15,7 @@ export const templatesRoute = {
const isListView = query.layout === 'list';
return isListView ? <Editor /> : undefined;
},
mobile: <MobileTemplatesView />,
mobile: <PageTemplates />,
},
widths: {
content( { query } ) {
Expand Down

0 comments on commit 990a1c9

Please sign in to comment.