|
| 1 | +import React from 'react'; |
| 2 | +import { VStack } from '@chakra-ui/react'; |
| 3 | +import { Meta, Story } from '@storybook/react'; |
| 4 | +import StoryRouter from 'storybook-react-router'; |
| 5 | + |
| 6 | +import { |
| 7 | + OutlinedCalendarIcon, |
| 8 | + OutlinedDashboardIcon, |
| 9 | + OutlinedRocketIcon, |
| 10 | + SolidCalendarIcon, |
| 11 | + SolidDashboardIcon, |
| 12 | + SolidRocketIcon, |
| 13 | +} from '../../icons'; |
| 14 | +import { HStack } from '../Stack'; |
| 15 | +import { SidebarItem, SidebarItemProps } from './SidebarItem'; |
| 16 | + |
| 17 | +const icons = { |
| 18 | + Dashboard: <OutlinedDashboardIcon />, |
| 19 | + Rocket: <OutlinedRocketIcon />, |
| 20 | + Calendar: <OutlinedCalendarIcon />, |
| 21 | + None: undefined, |
| 22 | +}; |
| 23 | + |
| 24 | +const iconsSelected = { |
| 25 | + Dashboard: <SolidDashboardIcon />, |
| 26 | + Rocket: <SolidRocketIcon />, |
| 27 | + Calendar: <SolidCalendarIcon />, |
| 28 | + None: undefined, |
| 29 | +}; |
| 30 | + |
| 31 | +const meta: Meta = { |
| 32 | + title: 'Components / SidebarItem', |
| 33 | + component: SidebarItem, |
| 34 | + argTypes: { |
| 35 | + icon: { |
| 36 | + options: Object.keys(icons), |
| 37 | + mapping: icons, |
| 38 | + control: { |
| 39 | + type: 'select', |
| 40 | + }, |
| 41 | + }, |
| 42 | + iconSelected: { |
| 43 | + options: Object.keys(iconsSelected), |
| 44 | + mapping: iconsSelected, |
| 45 | + control: { |
| 46 | + type: 'select', |
| 47 | + }, |
| 48 | + }, |
| 49 | + }, |
| 50 | + decorators: [StoryRouter()], |
| 51 | +}; |
| 52 | + |
| 53 | +export default meta; |
| 54 | + |
| 55 | +const Template: Story<SidebarItemProps> = (args) => <SidebarItem {...args} />; |
| 56 | + |
| 57 | +export const Playground = Template.bind({}); |
| 58 | + |
| 59 | +Playground.args = { |
| 60 | + children: 'Dashboard', |
| 61 | + count: undefined, |
| 62 | + path: '/panel', |
| 63 | +}; |
| 64 | + |
| 65 | +export const Other = () => ( |
| 66 | + <VStack> |
| 67 | + <HStack w="788px" spacing="10px"> |
| 68 | + <SidebarItem path="/k">Dashboard</SidebarItem> |
| 69 | + <SidebarItem path="/">Active</SidebarItem> |
| 70 | + <SidebarItem path="/a" disabled> |
| 71 | + Disabled |
| 72 | + </SidebarItem> |
| 73 | + </HStack> |
| 74 | + <HStack w="788px" spacing="10px"> |
| 75 | + <SidebarItem icon={<OutlinedDashboardIcon />} iconSelected={<SolidDashboardIcon />} path="/m"> |
| 76 | + Dashboard |
| 77 | + </SidebarItem> |
| 78 | + <SidebarItem icon={<OutlinedDashboardIcon />} iconSelected={<SolidDashboardIcon />} path="/"> |
| 79 | + Active |
| 80 | + </SidebarItem> |
| 81 | + <SidebarItem icon={<OutlinedDashboardIcon />} iconSelected={<SolidDashboardIcon />} path="/i" disabled> |
| 82 | + Disabled |
| 83 | + </SidebarItem> |
| 84 | + </HStack> |
| 85 | + <HStack w="788px" spacing="10px"> |
| 86 | + <SidebarItem count={1} path="/l"> |
| 87 | + Dashboard |
| 88 | + </SidebarItem> |
| 89 | + <SidebarItem count={2} path=""> |
| 90 | + Active |
| 91 | + </SidebarItem> |
| 92 | + <SidebarItem count={3} path="/t" disabled> |
| 93 | + Disabled |
| 94 | + </SidebarItem> |
| 95 | + </HStack> |
| 96 | + <HStack w="788px" spacing="10px"> |
| 97 | + <SidebarItem icon={<OutlinedDashboardIcon />} iconSelected={<SolidDashboardIcon />} count={314} path="/u"> |
| 98 | + Dashboard |
| 99 | + </SidebarItem> |
| 100 | + <SidebarItem icon={<OutlinedDashboardIcon />} iconSelected={<SolidDashboardIcon />} count={314} path=""> |
| 101 | + Active |
| 102 | + </SidebarItem> |
| 103 | + <SidebarItem |
| 104 | + icon={<OutlinedDashboardIcon />} |
| 105 | + iconSelected={<SolidDashboardIcon />} |
| 106 | + count={314} |
| 107 | + path="/byl" |
| 108 | + disabled |
| 109 | + > |
| 110 | + Disabled |
| 111 | + </SidebarItem> |
| 112 | + </HStack> |
| 113 | + </VStack> |
| 114 | +); |
0 commit comments