File tree Expand file tree Collapse file tree 4 files changed +25
-4
lines changed
components/src/navigation Expand file tree Collapse file tree 4 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ import { isRTL } from '@wordpress/i18n';
1515 */
1616import Button from '../../button' ;
1717import { useNavigationContext } from '../context' ;
18- import { ItemUI } from '../styles/navigation-styles' ;
18+ import { ItemUI , ItemIconUI } from '../styles/navigation-styles' ;
1919import NavigationItemBaseContent from './base-content' ;
2020import NavigationItemBase from './base' ;
2121
@@ -29,6 +29,7 @@ export default function NavigationItem( props ) {
2929 navigateToMenu,
3030 onClick = noop ,
3131 title,
32+ icon,
3233 hideIfTargetMenuEmpty,
3334 isText,
3435 ...restProps
@@ -62,7 +63,7 @@ export default function NavigationItem( props ) {
6263
6364 onClick ( event ) ;
6465 } ;
65- const icon = isRTL ( ) ? chevronLeft : chevronRight ;
66+ const navigationIcon = isRTL ( ) ? chevronLeft : chevronRight ;
6667 const baseProps = children ? props : { ...props , onClick : undefined } ;
6768 const itemProps = isText
6869 ? restProps
@@ -72,12 +73,18 @@ export default function NavigationItem( props ) {
7273 < NavigationItemBase { ...baseProps } className = { classes } >
7374 { children || (
7475 < ItemUI { ...itemProps } >
76+ { icon && (
77+ < ItemIconUI >
78+ < Icon icon = { icon } />
79+ </ ItemIconUI >
80+ ) }
81+
7582 < NavigationItemBaseContent
7683 title = { title }
7784 badge = { badge }
7885 />
7986
80- { navigateToMenu && < Icon icon = { icon } /> }
87+ { navigateToMenu && < Icon icon = { navigationIcon } /> }
8188 </ ItemUI >
8289 ) }
8390 </ NavigationItemBase >
Original file line number Diff line number Diff line change 22 * WordPress dependencies
33 */
44import { useEffect , useState } from '@wordpress/element' ;
5- import { Icon , wordpress } from '@wordpress/icons' ;
5+ import { Icon , wordpress , home } from '@wordpress/icons' ;
66
77/**
88 * Internal dependencies
@@ -33,6 +33,7 @@ export function MoreExamplesStory() {
3333 </ NavigationGroup >
3434 < NavigationGroup title = "Items with Unusual Features" >
3535 < NavigationItem
36+ icon = { home }
3637 item = "item-sub-menu"
3738 navigateToMenu = "sub-menu"
3839 title = "Sub-Menu with Custom Back Label"
Original file line number Diff line number Diff line change @@ -184,6 +184,11 @@ export const ItemUI = styled.div`
184184 opacity: 0.7;
185185` ;
186186
187+ export const ItemIconUI = styled . span `
188+ display: flex;
189+ margin-right: ${ space ( 2 ) } ;
190+ ` ;
191+
187192export const ItemBadgeUI = styled . span `
188193 margin-left: ${ ( ) => ( isRTL ( ) ? '0' : space ( 2 ) ) } ;
189194 margin-right: ${ ( ) => ( isRTL ( ) ? space ( 2 ) : '0' ) } ;
Original file line number Diff line number Diff line change @@ -20,6 +20,11 @@ import { __ } from '@wordpress/i18n';
2020import { ESCAPE } from '@wordpress/keycodes' ;
2121import { decodeEntities } from '@wordpress/html-entities' ;
2222import { addQueryArgs } from '@wordpress/url' ;
23+ import {
24+ home as siteIcon ,
25+ layout as templateIcon ,
26+ symbolFilled as templatePartIcon ,
27+ } from '@wordpress/icons' ;
2328
2429/**
2530 * Internal dependencies
@@ -88,6 +93,7 @@ const NavigationPanel = ( { activeItem = SITE_EDITOR_KEY } ) => {
8893 < NavigationMenu >
8994 < NavigationGroup title = { __ ( 'Editor' ) } >
9095 < NavigationItem
96+ icon = { siteIcon }
9197 title = { __ ( 'Site' ) }
9298 item = { SITE_EDITOR_KEY }
9399 href = { addQueryArgs ( window . location . href , {
@@ -96,6 +102,7 @@ const NavigationPanel = ( { activeItem = SITE_EDITOR_KEY } ) => {
96102 } ) }
97103 />
98104 < NavigationItem
105+ icon = { templateIcon }
99106 title = { __ ( 'Templates' ) }
100107 item = "wp_template"
101108 href = { addQueryArgs ( window . location . href , {
@@ -104,6 +111,7 @@ const NavigationPanel = ( { activeItem = SITE_EDITOR_KEY } ) => {
104111 } ) }
105112 />
106113 < NavigationItem
114+ icon = { templatePartIcon }
107115 title = { __ ( 'Template Parts' ) }
108116 item = "wp_template_part"
109117 href = { addQueryArgs ( window . location . href , {
You can’t perform that action at this time.
0 commit comments