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

Add: Navigation menus to the browse mode sidebar. #46436

Merged
merged 1 commit into from
Jan 23, 2023
Merged
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 @@ -209,6 +209,7 @@ function ListViewBlock( {

const listViewBlockEditClassName = classnames(
'block-editor-list-view-block__menu-cell',
'block-editor-list-view-block__menu-edit',
{ 'is-visible': isHovered || isFirstSelectedBlock }
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,40 @@
border-width: $border-width-tab;

&:hover,
&:focus {
&:focus,
&[aria-current] {
color: $white;
background: $gray-800;
border-width: $border-width-tab;
}

&[aria-current] {
color: $white;
background: var(--wp-admin-theme-color);
border-width: $border-width-tab;
}
}

.edit-site-sidebar-navigation-screen__content .edit-site-navigation-inspector .components-button {
color: $gray-600;
&:hover,
&:focus,
&[aria-current] {
color: $white;
}
}

.edit-site-sidebar-navigation-screen__content .edit-site-navigation-inspector .offcanvas-editor-list-view-leaf {
&:hover,
&:focus,
&[aria-current] {
background: $gray-800;
}
.block-editor-list-view-block__menu {
margin-left: -$grid-unit-10;
}
}

.edit-site-sidebar-navigation-screen__content .block-editor-list-view-block-select-button {
cursor: grab;
width: calc(100% - #{ $border-width-focus });
padding: $grid-unit-10;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import {
__experimentalNavigatorButton as NavigatorButton,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { layout, symbolFilled } from '@wordpress/icons';
import { layout, symbolFilled, navigation } from '@wordpress/icons';
import { useSelect } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';

/**
* Internal dependencies
Expand All @@ -15,12 +17,33 @@ import SidebarNavigationScreen from '../sidebar-navigation-screen';
import SidebarNavigationItem from '../sidebar-navigation-item';

export default function SidebarNavigationScreenMain() {
const { navigationMenus } = useSelect( ( select ) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I've noticed that when I open the site editor, I see two menu items (templates and template parts) and a few milliseconds later, I see the navigation one. I wonder if we should use useSuspenseSelect here and add a Suspense provider around the sidebar to show a loader or something before the navigation menus are loaded. (We've never used suspense before so this might not be ready yet but I think worth a try, could be a follow-up)

const { getEntityRecords } = select( coreStore );
return {
navigationMenus: getEntityRecords( 'postType', 'wp_navigation', {
per_page: -1,
status: 'publish',
} ),
};
} );
return (
<SidebarNavigationScreen
path="/"
title={ __( 'Design' ) }
content={
<ItemGroup>
{ !! window?.__experimentalEnableOffCanvasNavigationEditor &&
!! navigationMenus &&
navigationMenus.length > 0 && (
<NavigatorButton
as={ SidebarNavigationItem }
path="/navigation"
withChevron
icon={ navigation }
>
{ __( 'Navigation' ) }
</NavigatorButton>
) }
<NavigatorButton
as={ SidebarNavigationItem }
path="/templates"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import SidebarNavigationScreen from '../sidebar-navigation-screen';
import NavigationInspector from '../sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector';

export default function SidebarNavigationScreenNavigationMenus() {
return (
<SidebarNavigationScreen
path="/navigation"
parentTitle={ __( 'Design' ) }
title={ __( 'Navigation' ) }
content={
<div className="edit-site-sidebar-navigation-screen-navigation-menus">
<NavigationInspector />
</div>
}
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.edit-site-sidebar-navigation-screen-navigation-menus {
.block-editor-list-view-block__menu-edit,
.edit-site-navigation-inspector__select-menu {
display: none;
}
.offcanvas-editor-list-view-leaf {
max-width: calc(100% - #{ $grid-unit-05 });
}
.block-editor-list-view-leaf .block-editor-list-view-block__contents-cell {
width: 100%;
}
}
2 changes: 2 additions & 0 deletions packages/edit-site/src/components/sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ import { __experimentalNavigatorProvider as NavigatorProvider } from '@wordpress
import SidebarNavigationScreenMain from '../sidebar-navigation-screen-main';
import SidebarNavigationScreenTemplates from '../sidebar-navigation-screen-templates';
import useSyncSidebarPathWithURL from '../sync-state-with-url/use-sync-sidebar-path-with-url';
import SidebarNavigationScreenNavigationMenus from '../sidebar-navigation-screen-navigation-menus';

function SidebarScreens() {
useSyncSidebarPathWithURL();

return (
<>
<SidebarNavigationScreenMain />
<SidebarNavigationScreenNavigationMenus />
<SidebarNavigationScreenTemplates postType="wp_template" />
<SidebarNavigationScreenTemplates postType="wp_template_part" />
</>
Expand Down
1 change: 1 addition & 0 deletions packages/edit-site/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
@import "./components/sidebar-navigation-screen/style.scss";
@import "./components/sidebar-navigation-screen-templates/style.scss";
@import "./components/site-hub/style.scss";
@import "./components/sidebar-navigation-screen-navigation-menus/style.scss";
@import "./components/site-icon/style.scss";
@import "./components/style-book/style.scss";
@import "./hooks/push-changes-to-global-styles/style.scss";
Expand Down