import React, { useEffect, useState } from 'react'; import { ComponentMeta, ComponentStory } from '@storybook/react'; import { Tabs } from '.'; import { Box } from '../Layout'; import { Text } from '../Text'; export default { title: 'UI Components/Tabs', component: Tabs.Root, argTypes: { value: { control: { type: 'text' }, defaultValue: 'tab1' }, onValueChange: { action: { type: 'click' } }, orientation: { options: ['horizontal', 'vertical'], defaultValue: 'horizontal', control: { type: 'select' } }, }, } as ComponentMeta; const Template: ComponentStory = ({ value: propValue = '', onValueChange: propOnValueChange, ...rest }) => { const [value, setValue] = useState('tab1'); function handleOnValueChange(value: string) { setValue(value); if (propOnValueChange) { propOnValueChange(value); } } useEffect(() => { handleOnValueChange(propValue); if (propOnValueChange) { propOnValueChange(value); } }, [propValue]); return ( One Two Three Tab one content Tab two content Tab three content ); }; export const Example = Template.bind({}); Example.storyName = 'Tabs';