Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SiteHub available in mobile viewports #63060

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
10 changes: 10 additions & 0 deletions packages/edit-site/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ export default function Layout( { route } ) {

{ isMobileViewport && areas.mobile && (
<div className="edit-site-layout__mobile">
{ canvasMode !== 'edit' && (
<SidebarContent routeKey={ routeKey }>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsnajdr if you have any thoughts here.

Copy link
Contributor

@andrewserong andrewserong Jul 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another side effect of wrapping in SidebarContent is that the site hub receives extra padding, so there's a jump horizontally when we dig into the lower levels of the hierarchy:

2024-07-04.12.04.19.mp4

Edit: After re-checking out this branch I can't reproduce the above 🤔

<SiteHub
ref={ toggleRef }
isTransparent={
isResizableFrameOversized
}
/>
</SidebarContent>
) }
{ areas.mobile }
</div>
) }
Expand Down
53 changes: 40 additions & 13 deletions packages/edit-site/src/components/site-hub/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,32 @@ import clsx from 'clsx';
*/
import { useSelect, useDispatch } from '@wordpress/data';
import { Button, __experimentalHStack as HStack } from '@wordpress/components';
import { useViewportMatch } from '@wordpress/compose';
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
*/
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 ) => {
const isMobileViewport = useViewportMatch( 'medium', '<' );
const history = useHistory();
const { navigate } = useContext( SidebarNavigationContext );

const { dashboardLink, homeUrl, siteTitle } = useSelect( ( select ) => {
const { getSettings } = unlock( select( editSiteStore ) );

Expand Down Expand Up @@ -57,18 +65,37 @@ const SiteHub = memo(
}
) }
>
<Button
ref={ ref }
href={ dashboardLink }
label={ __( 'Go to the Dashboard' ) }
className="edit-site-layout__view-mode-toggle"
style={ {
transform: 'scale(0.5)',
borderRadius: 4,
} }
>
<SiteIcon className="edit-site-layout__view-mode-toggle-icon" />
</Button>
{ ! isMobileViewport && (
<Button
ref={ ref }
href={ dashboardLink }
label={ __( 'Go to the Dashboard' ) }
className="edit-site-layout__view-mode-toggle"
style={ {
transform: 'scale(0.5)',
borderRadius: 4,
} }
>
<SiteIcon className="edit-site-layout__view-mode-toggle-icon" />
</Button>
) }
{ isMobileViewport && (
<Button
ref={ ref }
label={ __( 'Go to Site Editor' ) }
className="edit-site-layout__view-mode-toggle"
style={ {
transform: 'scale(0.5)',
borderRadius: 4,
} }
onClick={ () => {
history.push( {} );
navigate( 'back' );
} }
>
<SiteIcon className="edit-site-layout__view-mode-toggle-icon" />
</Button>
) }
</div>

<HStack>
Expand Down
Loading