forked from storybookjs/storybook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request storybookjs#15369 from apapadopoulou/ap/sidebar-to…
…ggle UI: Display menu icon on the toolbar when the sidebar is collapsed
- Loading branch information
Showing
4 changed files
with
66 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
import { IconButton, Icons, Separator } from '@storybook/components'; | ||
import { Consumer, Combo } from '@storybook/api'; | ||
import { Addon } from '@storybook/addons'; | ||
|
||
const menuMapper = ({ api, state }: Combo) => ({ | ||
isVisible: state.layout.showNav, | ||
toggle: api.toggleNav, | ||
}); | ||
|
||
export const menuTool: Addon = { | ||
title: 'menu', | ||
id: 'menu', | ||
match: ({ viewMode }) => viewMode === 'story', | ||
render: () => ( | ||
<> | ||
<Consumer filter={menuMapper}> | ||
{({ isVisible, toggle }) => | ||
!isVisible && ( | ||
<> | ||
<IconButton | ||
aria-label="Show sidebar" | ||
key="menu" | ||
onClick={toggle as any} | ||
title="Show sidebar" | ||
> | ||
<Icons icon="menu" /> | ||
</IconButton> | ||
<Separator /> | ||
</> | ||
) | ||
} | ||
</Consumer> | ||
</> | ||
), | ||
}; |
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