Skip to content

Commit

Permalink
Extract story
Browse files Browse the repository at this point in the history
  • Loading branch information
david-szabo97 committed Oct 1, 2020
1 parent de1fee1 commit a11e356
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 41 deletions.
55 changes: 55 additions & 0 deletions packages/components/src/navigation/stories/hide-if-empty.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Internal dependencies
*/
import Navigation from '..';
import NavigationItem from '../item';
import NavigationMenu from '../menu';

export function HideIFEmptyStory() {
return (
<>
<Navigation>
<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 }
/>
<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>
</>
);
}
43 changes: 2 additions & 41 deletions packages/components/src/navigation/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import NavigationMenu from '../menu';
import { DefaultStory } from './default';
import { ControlledStateStory } from './controlled-state';
import { MoreExamplesStory } from './more-examples';
import { HideIFEmptyStory } from './hide-if-empty';
import './style.css';

export default {
Expand All @@ -25,44 +26,4 @@ export default {
export const _default = () => <DefaultStory />;
export const controlledState = () => <ControlledStateStory />;
export const moreExamples = () => <MoreExamplesStory />;

export const Test = () => {
return (
<Navigation>
<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"
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 }
/>
<NavigationMenu
menu="root-sub-1-sub-1"
parentMenu="root-sub-1"
isEmpty={ true }
/>
</Navigation>
);
};
export const hideIfEmpty = () => <HideIFEmptyStory />;

0 comments on commit a11e356

Please sign in to comment.