diff --git a/packages/edit-site/src/components/layout/index.js b/packages/edit-site/src/components/layout/index.js index 443ca04ebd03e..a609f616471db 100644 --- a/packages/edit-site/src/components/layout/index.js +++ b/packages/edit-site/src/components/layout/index.js @@ -34,7 +34,7 @@ import { privateApis as coreCommandsPrivateApis } from '@wordpress/core-commands */ import ErrorBoundary from '../error-boundary'; import { store as editSiteStore } from '../../store'; -import SiteHub from '../site-hub'; +import { default as SiteHub, SiteHubMobile } from '../site-hub'; import ResizableFrame from '../resizable-frame'; import { unlock } from '../../lock-unlock'; import KeyboardShortcutsRegister from '../keyboard-shortcuts/register'; @@ -174,6 +174,16 @@ export default function Layout( { route } ) { { isMobileViewport && areas.mobile && (
+ { canvasMode !== 'edit' && ( + + + + ) } { areas.mobile }
) } diff --git a/packages/edit-site/src/components/layout/style.scss b/packages/edit-site/src/components/layout/style.scss index 01c31de0d65d6..a7539ccdca79b 100644 --- a/packages/edit-site/src/components/layout/style.scss +++ b/packages/edit-site/src/components/layout/style.scss @@ -56,6 +56,18 @@ position: relative; width: 100%; z-index: z-index(".edit-site-layout__canvas-container"); + + /* + * The SiteHubMobile component is displayed + * for pages that do not have a sidebar, + * yet it needs the Sidebar component for the React context. + * + * This removes the padding in this scenario. + * See https://github.com/WordPress/gutenberg/pull/63118 + */ + .edit-site-sidebar__screen-wrapper { + padding: 0; + } } .edit-site-layout__canvas-container { diff --git a/packages/edit-site/src/components/site-hub/index.js b/packages/edit-site/src/components/site-hub/index.js index b53fed2d7a94f..301f7165d5935 100644 --- a/packages/edit-site/src/components/site-hub/index.js +++ b/packages/edit-site/src/components/site-hub/index.js @@ -11,11 +11,12 @@ import { Button, __experimentalHStack as HStack } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; import { store as coreStore } from '@wordpress/core-data'; import { decodeEntities } from '@wordpress/html-entities'; -import { memo, forwardRef } from '@wordpress/element'; +import { memo, forwardRef, useContext } from '@wordpress/element'; import { search } from '@wordpress/icons'; import { store as commandsStore } from '@wordpress/commands'; import { displayShortcut } from '@wordpress/keycodes'; import { filterURLForDisplay } from '@wordpress/url'; +import { privateApis as routerPrivateApis } from '@wordpress/router'; /** * Internal dependencies @@ -23,6 +24,8 @@ import { filterURLForDisplay } from '@wordpress/url'; import { store as editSiteStore } from '../../store'; import SiteIcon from '../site-icon'; import { unlock } from '../../lock-unlock'; +const { useHistory } = unlock( routerPrivateApis ); +import { SidebarNavigationContext } from '../sidebar'; const SiteHub = memo( forwardRef( ( { isTransparent }, ref ) => { @@ -103,3 +106,83 @@ const SiteHub = memo( ); export default SiteHub; + +export const SiteHubMobile = memo( + forwardRef( ( { isTransparent }, ref ) => { + const history = useHistory(); + const { navigate } = useContext( SidebarNavigationContext ); + + const { homeUrl, siteTitle } = useSelect( ( select ) => { + const { + getSite, + getUnstableBase, // Site index. + } = select( coreStore ); + const _site = getSite(); + return { + homeUrl: getUnstableBase()?.home, + siteTitle: + ! _site?.title && !! _site?.url + ? filterURLForDisplay( _site?.url ) + : _site?.title, + }; + }, [] ); + const { open: openCommandCenter } = useDispatch( commandsStore ); + + return ( +
+ +
+ +
+ + +
+ +
+ +
+ ); + } ) +);