Skip to content

Commit

Permalink
Site Editor: Unify layout with posts dataviews (WordPress#67162)
Browse files Browse the repository at this point in the history
Co-authored-by: youknowriad <[email protected]>
Co-authored-by: ntsekouras <[email protected]>
  • Loading branch information
3 people authored and karthick-murugan committed Nov 27, 2024
1 parent 0c34d4e commit dad8215
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 28 deletions.
19 changes: 4 additions & 15 deletions packages/edit-site/src/components/app/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
/**
* WordPress dependencies
*/
import { SlotFillProvider } from '@wordpress/components';
import {
UnsavedChangesWarning,
privateApis as editorPrivateApis,
} from '@wordpress/editor';
import { store as noticesStore } from '@wordpress/notices';
import { useDispatch } from '@wordpress/data';
import { __, sprintf } from '@wordpress/i18n';
Expand All @@ -23,7 +18,6 @@ import useSetCommandContext from '../../hooks/commands/use-set-command-context';
import { useRegisterSiteEditorRoutes } from '../site-editor-routes';

const { RouterProvider } = unlock( routerPrivateApis );
const { GlobalStylesProvider } = unlock( editorPrivateApis );

function AppLayout() {
useCommonCommands();
Expand All @@ -50,14 +44,9 @@ export default function App() {
}

return (
<SlotFillProvider>
<GlobalStylesProvider>
<UnsavedChangesWarning />
<RouterProvider>
<AppLayout />
<PluginArea onError={ onPluginAreaError } />
</RouterProvider>
</GlobalStylesProvider>
</SlotFillProvider>
<RouterProvider>
<AppLayout />
<PluginArea onError={ onPluginAreaError } />
</RouterProvider>
);
}
17 changes: 15 additions & 2 deletions packages/edit-site/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
__unstableMotion as motion,
__unstableAnimatePresence as AnimatePresence,
__unstableUseNavigateRegions as useNavigateRegions,
SlotFillProvider,
} from '@wordpress/components';
import {
useReducedMotion,
Expand All @@ -23,6 +24,7 @@ import { CommandMenu } from '@wordpress/commands';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
import {
EditorSnackbars,
UnsavedChangesWarning,
privateApis as editorPrivateApis,
} from '@wordpress/editor';
import { privateApis as coreCommandsPrivateApis } from '@wordpress/core-commands';
Expand All @@ -44,12 +46,12 @@ import SavePanel from '../save-panel';

const { useCommands } = unlock( coreCommandsPrivateApis );
const { useGlobalStyle } = unlock( blockEditorPrivateApis );
const { NavigableRegion } = unlock( editorPrivateApis );
const { NavigableRegion, GlobalStylesProvider } = unlock( editorPrivateApis );
const { useLocation } = unlock( routerPrivateApis );

const ANIMATION_DURATION = 0.3;

export default function Layout( { route } ) {
function Layout( { route } ) {
const { params } = useLocation();
const { canvas = 'view' } = params;
useCommands();
Expand Down Expand Up @@ -78,6 +80,7 @@ export default function Layout( { route } ) {

return (
<>
<UnsavedChangesWarning />
<CommandMenu />
{ canvas === 'view' && <SaveKeyboardShortcut /> }
<div
Expand Down Expand Up @@ -231,3 +234,13 @@ export default function Layout( { route } ) {
</>
);
}

export default function LayoutWithGlobalStylesProvider( props ) {
return (
<SlotFillProvider>
<GlobalStylesProvider>
<Layout { ...props } />
</GlobalStylesProvider>
</SlotFillProvider>
);
}
14 changes: 3 additions & 11 deletions packages/edit-site/src/components/posts-app/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/**
* WordPress dependencies
*/
import {
UnsavedChangesWarning,
privateApis as editorPrivateApis,
} from '@wordpress/editor';
import { privateApis as routerPrivateApis } from '@wordpress/router';

/**
Expand All @@ -16,7 +12,6 @@ import { unlock } from '../../lock-unlock';
import useActiveRoute from '../layout/router';

const { RouterProvider } = unlock( routerPrivateApis );
const { GlobalStylesProvider } = unlock( editorPrivateApis );

function PostsLayout() {
useRegisterPostsAppRoutes();
Expand All @@ -26,11 +21,8 @@ function PostsLayout() {

export default function PostsApp() {
return (
<GlobalStylesProvider>
<UnsavedChangesWarning />
<RouterProvider>
<PostsLayout />
</RouterProvider>
</GlobalStylesProvider>
<RouterProvider>
<PostsLayout />
</RouterProvider>
);
}

0 comments on commit dad8215

Please sign in to comment.