import { useState } from 'react'; import { PiChartLineLight, PiGearLight, PiUserLight } from 'react-icons/pi'; import type { Meta, StoryObj } from '@storybook/react-vite'; import { Tabs } from './Tabs'; const meta: Meta = { title: 'Components/Tabs', component: Tabs.Composite, tags: ['autodocs'], parameters: { layout: 'centered', }, }; export default meta; type Story = StoryObj; export const Basic: Story = { args: { tabs: [ { label: 'Overview', content:
Overview content
, }, { label: 'Details', content:
Details content
, }, { label: 'Settings', content:
Settings content
, }, ], }, }; export const WithIcons: Story = { args: { tabs: [ { label: 'User', icon: , content: (

User Information

Name: John Doe

Email: john@example.com

), }, { label: 'Analytics', icon: , content: (

Analytics Data

Views: 1,234

Clicks: 567

), }, { label: 'Settings', icon: , content: (

Settings Panel

), }, ], }, }; export const Controlled: Story = { render: () => { const [activeTab, setActiveTab] = useState('1'); return (
Active tab: {activeTab}
Content 1
, }, { key: '2', label: 'Tab 2', content:
Content 2
, }, { key: '3', label: 'Tab 3', content:
Content 3
, }, ]} /> ); }, }; export const Variants: Story = { render: () => (

Lifted (default)

Lifted content
}, { label: 'Tab 2', content:
Content 2
}, { label: 'Tab 3', content:
Content 3
}, ]} />

Bordered

Bordered content
}, { label: 'Tab 2', content:
Content 2
}, { label: 'Tab 3', content:
Content 3
}, ]} />

Boxed

Boxed content
}, { label: 'Tab 2', content:
Content 2
}, { label: 'Tab 3', content:
Content 3
}, ]} /> ), }; export const WithDisabled: Story = { args: { tabs: [ { label: 'Active Tab', content:
This tab is active
, }, { label: 'Disabled Tab', disabled: true, content:
This content is not accessible
, }, { label: 'Another Tab', content:
Another active tab
, }, ], }, }; export const InSummaryPanel: Story = { render: () => (

Order Details

已支付 已发货
, content: (

#12345

John Doe

¥1,234.56

), }, { label: 'Items', content: (

Product A

Qty: 2 × ¥500.00

Product B

Qty: 1 × ¥234.56

), }, ]} />
), }; export const AutoKeys: Story = { render: () => { const [activeTab, setActiveTab] = useState('0'); return (
Active tab (auto key): {activeTab}
Auto key = 0
}, { label: 'Second (key: 1)', content:
Auto key = 1
}, { label: 'Third (key: 2)', content:
Auto key = 2
}, ]} /> ); }, }; export const WithTitle: Story = { render: () => (
, content:
Overview content with title
, }, { label: 'Analytics', icon: , content:
Analytics data
, }, { label: 'Settings', icon: , content:
Settings panel
, }, ]} />
), }; export const WithAction: Story = { render: () => (
+ New Order} tabs={[ { label: 'All', content:
All orders
, }, { label: 'Pending', content:
Pending orders
, }, { label: 'Completed', content:
Completed orders
, }, ]} />
), }; export const TitleAndAction: Story = { render: () => (
} tabs={[ { label: 'Active', content:
Active projects
, }, { label: 'Archived', content:
Archived projects
, }, ]} /> ), }; export const LiftedWithWrap: Story = { render: () => (
} tabs={[ { label: 'Overview', icon: , content: (
Overview with many tabs to demonstrate wrapping behavior
), }, { label: 'Analytics', icon: , content:
Analytics content
, }, { label: 'Settings', icon: , content:
Settings content
, }, { label: 'Reports', content:
Reports content
, }, { label: 'Users', content:
Users content
, }, { label: 'Permissions', content:
Permissions content
, }, ]} /> ), parameters: { docs: { description: { story: 'Demonstrates how tabs wrap gracefully when there are many tabs. The title stays in place and does not shift when tabs wrap to a new line.', }, }, }, }; export const LiftedNoTitle: Story = { render: () => (
} tabs={[ { label: 'All Items', content:
All items view
, }, { label: 'Favorites', content:
Favorites view
, }, { label: 'Recent', content:
Recent items
, }, ]} /> ), parameters: { docs: { description: { story: 'Lifted variant without title, showing the 4px spacer for a smoother visual appearance.', }, }, }, };