import type { Meta, StoryObj } from '@storybook/react-vite'; import { CheckIcon } from 'lucide-react'; import { Badge } from './badge'; const meta = { title: 'Components/Badge', component: Badge, parameters: { layout: 'centered', docs: { description: { component: 'Compact status or category marker. A badge is not a button — if it needs to be clickable, use `asChild` with an anchor so it is announced and focused as a link.', }, }, }, tags: ['autodocs'], argTypes: { variant: { control: 'select', options: [ 'solid', 'subtle', 'surface', 'outline', 'default', 'secondary', 'destructive', 'success', 'warning', 'ghost', ], }, colorPalette: { control: 'select', options: ['primary', 'secondary', 'tertiary', 'black', 'red', 'green', 'yellow'], }, size: { control: 'inline-radio', options: ['xs', 'sm', 'md', 'lg'] }, }, args: { children: 'Badge' }, } satisfies Meta; export default meta; type Story = StoryObj; export const Default: Story = {}; export const Variants: Story = { render: () => (
{(['solid', 'subtle', 'surface', 'outline'] as const).map((variant) => ( {variant} ))}
), }; /** Every treatment renders in any of the seven palettes. */ export const Palettes: Story = { render: () => (
{(['solid', 'subtle', 'outline'] as const).map((variant) => (
{(['primary', 'secondary', 'tertiary', 'black', 'red', 'green', 'yellow'] as const).map( (colorPalette) => ( {colorPalette} ) )}
))}
), }; /** Status shorthands. Each pins its own colour and ignores `colorPalette`. */ export const Shorthands: Story = { render: () => (
Default Secondary Destructive Success Warning Ghost
), }; export const Sizes: Story = { render: () => (
{(['xs', 'sm', 'md', 'lg'] as const).map((size) => ( {size} ))}
), }; export const WithIcon: Story = { render: () => ( Verified ), }; export const AsLink: Story = { render: () => ( v2.4.0 ), };