-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Navigation Component: Hide navigation item if target menu is empty (#…
- Loading branch information
1 parent
1673ed6
commit fc67e52
Showing
6 changed files
with
157 additions
and
2 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
57 changes: 57 additions & 0 deletions
57
packages/components/src/navigation/stories/hide-if-empty.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,57 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import Navigation from '..'; | ||
import NavigationItem from '../item'; | ||
import NavigationMenu from '../menu'; | ||
|
||
export function HideIfEmptyStory() { | ||
return ( | ||
<> | ||
<Navigation className="navigation-story"> | ||
<NavigationMenu title="Home" menu="root" isEmpty={ false }> | ||
<NavigationItem | ||
navigateToMenu="root-sub-1" | ||
title="To sub 1 (hidden)" | ||
hideIfTargetMenuEmpty | ||
/> | ||
|
||
<NavigationItem | ||
navigateToMenu="root-sub-2" | ||
title="To sub 2 (visible)" | ||
hideIfTargetMenuEmpty | ||
/> | ||
|
||
<NavigationItem | ||
navigateToMenu="root-sub-1-sub-1" | ||
title="To sub 1-1 (hidden)" | ||
hideIfTargetMenuEmpty | ||
/> | ||
</NavigationMenu> | ||
|
||
<NavigationMenu | ||
menu="root-sub-1" | ||
parentMenu="root" | ||
isEmpty={ true } | ||
/> | ||
<NavigationMenu | ||
menu="root-sub-2" | ||
parentMenu="root" | ||
isEmpty={ false } | ||
> | ||
<NavigationItem title="This menu is visible" /> | ||
</NavigationMenu> | ||
<NavigationMenu | ||
menu="root-sub-1-sub-1" | ||
parentMenu="root-sub-1" | ||
isEmpty={ true } | ||
/> | ||
</Navigation> | ||
|
||
<p> | ||
This story contains 3 navigation items and 4 menus. You should | ||
only see one item: <strong>To sub 2 (visible)</strong> | ||
</p> | ||
</> | ||
); | ||
} |
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