import { playgroundParameters } from "@charcuterie/storybook-config/story-parameters" import type { Meta, StoryObj } from "@storybook/react" import { controlSizeArgType, intentArgType, } from "../argTypes.storyHelpers.ts" import { ContainerBoard, StoryCell, StoryGrid, StoryRow, StorySection, } from "../board.storyHelpers.tsx" import type { IntentAppearance } from "../intentStyles.ts" import { Button } from "./Button.tsx" const INTENTS = [ "neutral", "accent", "success", "warning", "danger", "info", ] as const const APPEARANCES: IntentAppearance[] = [ "solid", "soft", "outline", "ghost", ] const meta = { title: "Components/Actions/Button", component: Button, parameters: { layout: "padded" }, argTypes: { intent: intentArgType, size: controlSizeArgType, }, // The component's own defaults, restated. Storybook has not // seeded `args` from a docgen `defaultValue` since v7, so without // this the props table prints `"solid"` in the Default column // while the radio beside it has nothing selected. args: { appearance: "solid", intent: "accent", isDisabled: false, isFullWidth: false, isLoading: false, size: "md", sizing: "control", }, } satisfies Meta export default meta type Story = StoryObj export const Playground: Story = { parameters: playgroundParameters, args: { children: "Start rip" }, } export const AllVariants: Story = { args: { children: "Start rip" }, render: (buttonProps) => ( {APPEARANCES.flatMap((appearance) => INTENTS.map((intent) => ( )), )} ), } export const AllSizes: Story = { args: { children: "Start rip" }, render: (buttonProps) => ( ), } /** * Hover, active, and focus are real here, not simulated: the * pseudo-states addon forces them, which is the only way to review * a hover colour in a static board. * * `focusVisible` is forced the same way rather than tabbed to. A * board that has to be *driven* to show its states is a test * wearing a demo's clothes — and the tab count silently depended on * how many focusable cells sat above it. */ export const AllStates: Story = { args: { children: "Start rip" }, parameters: { pseudo: { active: ["#active"], focusVisible: ["#focus-target"], hover: ["#hover"], }, }, render: (buttonProps) => (