import type { Meta, StoryObj } from '@storybook/nextjs-vite' import type { Item } from '.' import { useState } from 'react' import Chip from '.' const ITEMS: Item[] = [ { value: 'all', name: 'All items' }, { value: 'active', name: 'Active' }, { value: 'archived', name: 'Archived' }, { value: 'draft', name: 'Drafts' }, ] const meta = { title: 'Base/Data Entry/Chip', component: Chip, parameters: { docs: { description: { component: 'Filter chip with dropdown panel and optional left icon. Commonly used for status pickers in toolbars.', }, }, }, tags: ['autodocs'], args: { items: ITEMS, value: 'all', onSelect: () => {}, onClear: () => {}, }, } satisfies Meta export default meta type Story = StoryObj const ChipDemo = (props: React.ComponentProps) => { const [selection, setSelection] = useState(props.value) return (
setSelection(item.value)} onClear={() => setSelection('all')} />
Current value: {' '} {selection}
) } export const Playground: Story = { render: args => , parameters: { docs: { source: { language: 'tsx', code: ` const [selection, setSelection] = useState('all') setSelection(item.value)} onClear={() => setSelection('all')} /> `.trim(), }, }, }, } export const WithoutLeftIcon: Story = { args: { showLeftIcon: false, onSelect: () => {}, onClear: () => {}, }, render: args => ( ), parameters: { docs: { source: { language: 'tsx', code: ` `.trim(), }, }, }, }