-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
181 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/edit-site/src/components/sidebar-navigation-screen-template-part/style.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.edit-site-sidebar-navigation-screen-template-part-navigation-menu__title.components-heading { | ||
margin-bottom: $grid-unit-10; | ||
} |
26 changes: 26 additions & 0 deletions
26
...onents/sidebar-navigation-screen-template-part/template-part-navigation-menu-list-item.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useEntityProp } from '@wordpress/core-data'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import SidebarNavigationItem from '../sidebar-navigation-item'; | ||
import { useLink } from '../routes/link'; | ||
|
||
export default function TemplatePartNavigationMenuListItem( { id } ) { | ||
const [ title ] = useEntityProp( 'postType', 'wp_navigation', 'title', id ); | ||
|
||
const linkInfo = useLink( { | ||
postId: id, | ||
postType: 'wp_navigation', | ||
} ); | ||
|
||
if ( ! id ) return null; | ||
|
||
return ( | ||
<SidebarNavigationItem withChevron { ...linkInfo }> | ||
{ title } | ||
</SidebarNavigationItem> | ||
); | ||
} |
21 changes: 21 additions & 0 deletions
21
.../components/sidebar-navigation-screen-template-part/template-part-navigation-menu-list.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __experimentalItemGroup as ItemGroup } from '@wordpress/components'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import TemplatePartNavigationMenuListItem from './template-part-navigation-menu-list-item'; | ||
|
||
export default function TemplatePartNavigationMenuList( { menus } ) { | ||
return ( | ||
<ItemGroup className="edit-site-sidebar-navigation-screen-template-part-navigation-menu-list"> | ||
{ menus.map( ( menuId ) => ( | ||
<TemplatePartNavigationMenuListItem | ||
key={ menuId } | ||
id={ menuId } | ||
/> | ||
) ) } | ||
</ItemGroup> | ||
); | ||
} |
29 changes: 29 additions & 0 deletions
29
...e/src/components/sidebar-navigation-screen-template-part/template-part-navigation-menu.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { __experimentalHeading as Heading } from '@wordpress/components'; | ||
import { useEntityProp } from '@wordpress/core-data'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import NavigationMenuEditor from '../sidebar-navigation-screen-navigation-menu/navigation-menu-editor'; | ||
|
||
export default function TemplatePartNavigationMenu( { id } ) { | ||
const [ title ] = useEntityProp( 'postType', 'wp_navigation', 'title', id ); | ||
|
||
if ( ! id ) return null; | ||
|
||
return ( | ||
<> | ||
<Heading | ||
className="edit-site-sidebar-navigation-screen-template-part-navigation-menu__title" | ||
size="12" | ||
upperCase={ true } | ||
> | ||
{ title || __( 'Navigation Menu' ) } | ||
</Heading> | ||
<NavigationMenuEditor navigationMenuId={ id } /> | ||
</> | ||
); | ||
} |
33 changes: 33 additions & 0 deletions
33
.../src/components/sidebar-navigation-screen-template-part/template-part-navigation-menus.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { __experimentalHeading as Heading } from '@wordpress/components'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import TemplatePartNavigationMenu from './template-part-navigation-menu'; | ||
import TemplatePartNavigationMenuList from './template-part-navigation-menu-list'; | ||
|
||
export default function TemplatePartNavigationMenus( { menus } ) { | ||
if ( ! menus.length ) return null; | ||
|
||
// if there is a single menu then render TemplatePartNavigationMenu | ||
if ( menus.length === 1 ) { | ||
return <TemplatePartNavigationMenu id={ menus[ 0 ] } />; | ||
} | ||
|
||
// if there are multiple menus then render TemplatePartNavigationMenuList | ||
return ( | ||
<> | ||
<Heading | ||
className="edit-site-sidebar-navigation-screen-template-part-navigation-menu__title" | ||
size="12" | ||
upperCase={ true } | ||
> | ||
{ __( 'Navigation Menus' ) } | ||
</Heading> | ||
<TemplatePartNavigationMenuList menus={ menus } /> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters