|
1 |
| -import { Stack, Tabs } from '@mui/material' |
| 1 | +/* eslint-disable react-hooks/rules-of-hooks */ |
| 2 | +import { useState } from 'storybook/internal/preview-api' // Intentionally, can't use React's useState: https://github.com/storybookjs/storybook/issues/29189 |
| 3 | +import { Tabs } from '@mui/material' |
2 | 4 | import type { Meta, StoryObj } from '@storybook/react'
|
3 |
| -import { TabsSwitcher, TabsSwitcherProps } from '../../shared/ui/TabsSwitcher' |
4 |
| -import { TabSwitcherVariants } from '../tabs' |
5 |
| -import { useState } from 'react' |
| 5 | +import { TabsSwitcher } from '../../shared/ui/TabsSwitcher' |
6 | 6 |
|
7 | 7 | type Story = StoryObj<typeof Tabs>
|
8 | 8 |
|
9 |
| -type TabsDisplayProps = Pick<TabsSwitcherProps<number>, 'variant' | 'size' | 'options'> & { |
10 |
| - defaultValue: number |
11 |
| -} |
12 |
| - |
13 |
| -const TabsDisplay = ({ defaultValue, ...props }: TabsDisplayProps) => { |
14 |
| - const [value, setValue] = useState<number>(defaultValue) |
15 |
| - return <TabsSwitcher {...props} value={value} onChange={setValue} /> |
| 9 | +const meta: Meta<typeof TabsSwitcher> = { |
| 10 | + title: 'UI Kit/Primitives/Tabs', |
| 11 | + component: TabsSwitcher, |
| 12 | + argTypes: { |
| 13 | + variant: { |
| 14 | + control: 'select', |
| 15 | + options: ['contained', 'underlined', 'overlined'], |
| 16 | + description: 'The variant of the component', |
| 17 | + }, |
| 18 | + size: { |
| 19 | + control: 'select', |
| 20 | + options: ['small', 'medium', 'large'], |
| 21 | + description: 'The size of the component', |
| 22 | + }, |
| 23 | + }, |
| 24 | + args: { |
| 25 | + variant: 'contained', |
| 26 | + size: 'small', |
| 27 | + }, |
16 | 28 | }
|
17 | 29 |
|
18 |
| -const createStory = (variant: TabSwitcherVariants): Story => ({ |
19 |
| - decorators: [ |
20 |
| - (Story, { args }) => ( |
21 |
| - <Stack spacing={5}> |
22 |
| - <TabsDisplay variant={variant} {...args} /> |
23 |
| - </Stack> |
24 |
| - ), |
25 |
| - ], |
26 |
| -}) |
27 |
| - |
28 |
| -export const Contained = createStory('contained') |
29 |
| -export const Underlined = createStory('underlined') |
30 |
| -export const Overlined = createStory('overlined') |
| 30 | +export const Contained: Story = { |
| 31 | + render: (args) => { |
| 32 | + const [value, setValue] = useState<number>(1) |
31 | 33 |
|
32 |
| -const meta: Meta<typeof TabsDisplay> = { |
33 |
| - title: 'UI Kit/Primitives/Tabs', |
34 |
| - component: TabsDisplay, |
35 |
| - argTypes: {}, |
36 |
| - args: { |
37 |
| - options: [1, 2, 3, 4].map((value) => ({ label: `Tab ${value}`, value })), |
38 |
| - defaultValue: 1, |
| 34 | + return ( |
| 35 | + <TabsSwitcher |
| 36 | + options={[1, 2, 3, 4].map((value) => ({ label: `Tab ${value}`, value }))} |
| 37 | + value={value} |
| 38 | + onChange={setValue} |
| 39 | + {...args} |
| 40 | + /> |
| 41 | + ) |
39 | 42 | },
|
40 | 43 | }
|
| 44 | + |
41 | 45 | export default meta
|
0 commit comments