import type { Meta, StoryObj } from '@storybook/react-vite'; import { ArrowRight, Plus, Trash2 } from 'lucide-react'; import { Button } from './button'; const meta = { title: 'Components/Button', component: Button, parameters: { layout: 'centered', docs: { description: { component: "The kit's primary interactive control. Following CBAR's design system, colour and treatment are separate axes: `variant` says how filled in the button is, `colorPalette` says which hue it wears. Any of the five treatments combines with any of the seven palettes.", }, }, }, tags: ['autodocs'], argTypes: { variant: { control: 'select', options: [ 'solid', 'subtle', 'surface', 'outline', 'ghost', 'link', 'default', 'destructive', 'secondary', ], }, colorPalette: { control: 'select', options: ['primary', 'secondary', 'tertiary', 'black', 'red', 'green', 'yellow'], }, size: { control: 'select', options: ['xs', 'sm', 'md', 'lg', 'xl', 'icon-xs', 'icon-sm', 'icon', 'icon-lg'], }, disabled: { control: 'boolean' }, }, args: { children: 'Button' }, } satisfies Meta; export default meta; type Story = StoryObj; export const Default: Story = {}; const VARIANTS = ['solid', 'subtle', 'surface', 'outline', 'ghost', 'link'] as const; const PALETTES = ['primary', 'secondary', 'tertiary', 'black', 'red', 'green', 'yellow'] as const; export const Variants: Story = { render: () => (
{VARIANTS.map((variant) => ( ))}
), }; /** The other axis: every treatment above renders in any of these seven hues. */ export const Palettes: Story = { render: () => (
{VARIANTS.filter((v) => v !== 'link').map((variant) => (
{PALETTES.map((colorPalette) => ( ))}
))}
), }; /** * One-word shorthands for the combinations used most often. Each pins its own * colour, so `colorPalette` has no effect alongside them — reach for * `variant="solid"` plus a palette when you want the two axes to compose. */ export const Shorthands: Story = { render: () => (
), }; export const Sizes: Story = { render: () => (
), }; /** Square buttons for a lone icon. Each one needs an `aria-label`. */ export const IconOnly: Story = { render: () => (
{(['icon-xs', 'icon-sm', 'icon', 'icon-lg'] as const).map((size) => ( ))}
), }; export const WithIcons: Story = { render: () => (
), }; export const Disabled: Story = { args: { disabled: true }, render: (args) => (
), }; /** * `asChild` hands the button's styling to whatever element you nest, so a * router link can look like a button without an invalid `` inside ` ), };