Skip to content

Commit a7807a3

Browse files
author
Alunara
committed
chore: update tabs storybook
1 parent 81881b8 commit a7807a3

File tree

1 file changed

+35
-31
lines changed

1 file changed

+35
-31
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,45 @@
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'
24
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'
66

77
type Story = StoryObj<typeof Tabs>
88

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+
},
1628
}
1729

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)
3133

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+
)
3942
},
4043
}
44+
4145
export default meta

0 commit comments

Comments
 (0)