import { playgroundParameters } from "@charcuterie/storybook-config/story-parameters" import type { Meta, StoryObj } from "@storybook/react" import { StoryCell, StoryGrid, StoryRow, StorySection, } from "../board.storyHelpers.tsx" import { Card } from "../Card/Card.tsx" import { Swatch } from "./Swatch.tsx" /** * Colours that are **data**, not tokens — the whole reason the * component exists. These stand in for stickers on a controller, and * a design system re-theming them would be re-theming the hardware. */ const STICKERS = [ { color: "#E5484D", label: "Red" }, { color: "#3B82F6", label: "Blue" }, { color: "#35D07F", label: "Green" }, { color: "#F5C518", label: "Yellow" }, ] as const const meta = { title: "Components/Controls/Swatch", component: Swatch, parameters: { layout: "padded" }, argTypes: { color: { control: "color" } }, args: { appearance: "solid", color: "#E5484D", isLabelVisible: true, label: "Red", size: "md", }, } satisfies Meta export default meta type Story = StoryObj /** * A named graphic — `getByRole("img", { name: "Red" })` resolves, * because a colour a screen reader cannot see needs a name it can * read. */ export const Playground: Story = { parameters: playgroundParameters, } /** * `solid` fills; `outline` keeps the hue and drops the fill. The * second is the one state a status colour cannot borrow from * `intent` — "this thing is present but inactive" — which is what a * powered-off controller looks like beside its live siblings. */ export const AllVariants: Story = { render: (swatchProps) => ( {STICKERS.map((sticker) => ( ))} {STICKERS.map((sticker) => ( ))} ), } export const AllStates: Story = { render: (swatchProps) => ( ), } /** * The real placement: a row per item, the swatch answering "which * one" before the words do. This is castkit's album accent and * plex-channels' channel colours as much as it is a controller * sticker. */ export const InAList: Story = { render: () => (
    {STICKERS.map((sticker) => (
  • {sticker.label} controller
  • ))}
), }