mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-05 08:01:20 +08:00
93 lines
2.3 KiB
TypeScript
93 lines
2.3 KiB
TypeScript
import React, { Fragment, FunctionComponent } from 'react';
|
|
|
|
import { WithTooltip, TooltipLinkList, Icons } from '@storybook/components';
|
|
import { styled } from '@storybook/theming';
|
|
import { MenuItemIcon, SidebarMenu, ToolbarMenu, MenuButton, SidebarMenuList } from './Menu';
|
|
import { useMenu } from '../../containers/menu';
|
|
|
|
export default {
|
|
component: MenuItemIcon,
|
|
title: 'UI/Sidebar/Menu',
|
|
decorators: [
|
|
(StoryFn: FunctionComponent) => (
|
|
<Fragment>
|
|
<StoryFn />
|
|
</Fragment>
|
|
),
|
|
],
|
|
};
|
|
|
|
const fakemenu = [
|
|
{ title: 'has icon', left: <MenuItemIcon icon="check" />, id: 'icon' },
|
|
{
|
|
title: 'has imgSrc',
|
|
left: <MenuItemIcon imgSrc="https://storybook.js.org/images/placeholders/20x20.png" />,
|
|
id: 'img',
|
|
},
|
|
{ title: 'has neither', left: <MenuItemIcon />, id: 'non' },
|
|
];
|
|
|
|
export const Items = () => <TooltipLinkList links={fakemenu} />;
|
|
|
|
export const Real = () => <SidebarMenu menu={fakemenu} isHighlighted />;
|
|
|
|
export const Toolbar = () => <ToolbarMenu menu={fakemenu} />;
|
|
|
|
const DoubleThemeRenderingHack = styled.div({
|
|
'#root > [data-side="left"] > &': {
|
|
textAlign: 'right',
|
|
},
|
|
});
|
|
|
|
const ExpandedMenu: FunctionComponent<{ menu: any }> = ({ menu }) => (
|
|
<DoubleThemeRenderingHack>
|
|
<WithTooltip
|
|
placement="bottom"
|
|
trigger="click"
|
|
closeOnClick
|
|
startOpen
|
|
tooltip={({ onHide }) => <SidebarMenuList onHide={onHide} menu={menu} />}
|
|
>
|
|
<MenuButton outline small containsIcon highlighted={false} title="Shortcuts">
|
|
<Icons icon="ellipsis" />
|
|
</MenuButton>
|
|
</WithTooltip>
|
|
</DoubleThemeRenderingHack>
|
|
);
|
|
|
|
export const Expanded = () => {
|
|
const menu = useMenu(
|
|
{
|
|
// @ts-ignore
|
|
getShortcutKeys: () => ({}),
|
|
getAddonsShortcuts: () => ({}),
|
|
versionUpdateAvailable: () => false,
|
|
releaseNotesVersion: () => '6.0.0',
|
|
},
|
|
false,
|
|
false,
|
|
false,
|
|
false,
|
|
false
|
|
);
|
|
return <ExpandedMenu menu={menu} />;
|
|
};
|
|
|
|
export const ExpandedWithoutReleaseNotes = () => {
|
|
const menu = useMenu(
|
|
{
|
|
// @ts-ignore
|
|
getShortcutKeys: () => ({}),
|
|
getAddonsShortcuts: () => ({}),
|
|
versionUpdateAvailable: () => false,
|
|
releaseNotesVersion: () => undefined,
|
|
},
|
|
false,
|
|
false,
|
|
false,
|
|
false,
|
|
false
|
|
);
|
|
return <ExpandedMenu menu={menu} />;
|
|
};
|