diff --git a/lib/ui/src/components/preview/toolbar.tsx b/lib/ui/src/components/preview/toolbar.tsx index da3a681a43e9..bdf60c1fe2b9 100644 --- a/lib/ui/src/components/preview/toolbar.tsx +++ b/lib/ui/src/components/preview/toolbar.tsx @@ -15,6 +15,7 @@ import * as S from './utils/components'; import { PreviewProps } from './utils/types'; import { copyTool } from './tools/copy'; import { ejectTool } from './tools/eject'; +import { menuTool } from './tools/menu'; export const getTools = (getFn: API['getElements']) => Object.values(getFn(types.TOOL)); @@ -193,7 +194,11 @@ export function filterTools( path: State['path']; } ) { - const toolsLeft = [tabs.filter((p) => !p.hidden).length >= 1 && createTabsTool(tabs), ...tools]; + const toolsLeft = [ + menuTool, + tabs.filter((p) => !p.hidden).length >= 1 && createTabsTool(tabs), + ...tools, + ]; const toolsRight = [...toolsExtra]; const filter = (item: Partial) => diff --git a/lib/ui/src/components/preview/tools/menu.tsx b/lib/ui/src/components/preview/tools/menu.tsx new file mode 100644 index 000000000000..a2b91d8c0f0c --- /dev/null +++ b/lib/ui/src/components/preview/tools/menu.tsx @@ -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: () => ( + <> + + {({ isVisible, toggle }) => + !isVisible && ( + <> + + + + + + ) + } + + + ), +}; diff --git a/lib/ui/src/components/sidebar/Menu.stories.tsx b/lib/ui/src/components/sidebar/Menu.stories.tsx index b41469c4cae4..196ee39566d3 100644 --- a/lib/ui/src/components/sidebar/Menu.stories.tsx +++ b/lib/ui/src/components/sidebar/Menu.stories.tsx @@ -2,7 +2,7 @@ import React, { Fragment, FunctionComponent } from 'react'; import { WithTooltip, TooltipLinkList, Icons } from '@storybook/components'; import { styled } from '@storybook/theming'; -import { MenuItemIcon, SidebarMenu, MenuButton, SidebarMenuList } from './Menu'; +import { MenuItemIcon, SidebarMenu, ToolbarMenu, MenuButton, SidebarMenuList } from './Menu'; import { useMenu } from '../../containers/menu'; export default { @@ -31,6 +31,8 @@ export const Items = () => ; export const Real = () => ; +export const Toolbar = () => ; + const DoubleThemeRenderingHack = styled.div({ '#root > [data-side="left"] > &': { textAlign: 'right', @@ -40,7 +42,7 @@ const DoubleThemeRenderingHack = styled.div({ const ExpandedMenu: FunctionComponent<{ menu: any }> = ({ menu }) => ( { false, false, false, + false, false ); return ; @@ -82,6 +85,7 @@ export const ExpandedWithoutReleaseNotes = () => { false, false, false, + false, false ); return ; diff --git a/lib/ui/src/components/sidebar/Menu.tsx b/lib/ui/src/components/sidebar/Menu.tsx index b1d20f9748aa..4325d1559110 100644 --- a/lib/ui/src/components/sidebar/Menu.tsx +++ b/lib/ui/src/components/sidebar/Menu.tsx @@ -1,7 +1,7 @@ import React, { FunctionComponent, useMemo, ComponentProps } from 'react'; import { styled } from '@storybook/theming'; -import { WithTooltip, TooltipLinkList, Button, Icons } from '@storybook/components'; +import { WithTooltip, TooltipLinkList, Button, Icons, IconButton } from '@storybook/components'; export type MenuList = ComponentProps['links']; @@ -113,3 +113,20 @@ export const SidebarMenu: FunctionComponent<{ ); }; + +export const ToolbarMenu: FunctionComponent<{ + menu: MenuList; +}> = ({ menu }) => { + return ( + } + > + + + + + ); +};