import type { Meta, StoryObj } from '@storybook/react-vite' import { IconPlus } from '@tabler/icons-react' import { Button } from './Button' const meta = { title: 'Primitives/Button', component: Button, args: { children: 'Button', variant: 'muted', size: 'default', disabled: false }, argTypes: { variant: { control: 'inline-radio', options: ['primary', 'outlined', 'muted', 'destructive', 'resolve'] }, size: { control: 'inline-radio', options: ['default', 'small'] }, leadingIcon: { control: false }, }, } satisfies Meta export default meta type Story = StoryObj export const Primary: Story = { args: { variant: 'primary' } } export const Outlined: Story = { args: { variant: 'outlined' } } export const Muted: Story = { args: { variant: 'muted' } } /** The muted button in the error colour — for "Delete …" and its kind. Ship's addition. */ export const Destructive: Story = { args: { variant: 'destructive', children: 'Delete project' } } export const Small: Story = { args: { variant: 'primary', size: 'small' } } export const WithLeadingIcon: Story = { args: { variant: 'primary', leadingIcon: } } /** Disabled is for a control that is momentarily unavailable — say why, with `disabledReason`. A control someone may never use is absent, not disabled. */ export const Disabled: Story = { args: { variant: 'primary', disabled: true } } /** Disabled with its reason: hover to read it; Tab still reaches the button. */ export const WithAReason: Story = { args: { variant: 'primary', disabledReason: 'Sign in to add items' } } /** Every variant × size × icon × disabled combination on one canvas. */ /* The box it is dropped into cannot change its height: a Button states `h-8` (or `h-6` when small), and a stretching parent only stretches a child whose height is `auto`. The row below says no `items-*` at all, which is the box that drew an IconButton 228px tall — this stays 32. */ export const InATallRow: Story = { parameters: { controls: { disable: true } }, render: () => (
), } /* And the caller says where it sits. This column asks for the left; a Button carries no `align-self` of its own, so the left is what it gets. */ export const InAColumnThatAsksForTheLeft: Story = { parameters: { controls: { disable: true } }, render: () => (
), } export const AllVariants: Story = { parameters: { controls: { disable: true } }, render: () => (
{(['primary', 'outlined', 'muted', 'destructive'] as const).map((variant) => (
{(['default', 'small'] as const).map((size) => (
))}
))}
), } /** `resolve`: primary, and in Signal outlined at rest and green when pointed at — Resolve. */ export const Resolve: Story = { args: { variant: 'resolve', children: 'Resolve' } }