import { playgroundParameters } from "@charcuterie/storybook-config/story-parameters" import type { Meta, StoryObj } from "@storybook/react" import { useState } from "react" import { intentArgType } from "../argTypes.storyHelpers.ts" import { Button } from "../Button/Button.tsx" import { ContainerBoard, StoryCell, StoryGrid, StoryRow, StorySection, } from "../board.storyHelpers.tsx" import { ProgressBar } from "./ProgressBar.tsx" import type { ProgressThreshold } from "./progressValue.ts" /** Green when finished, amber past 90% — the rip-deck case. */ const DISC_THRESHOLDS: ProgressThreshold[] = [ { from: 90, intent: "warning" }, { from: 100, intent: "success" }, ] const meta = { title: "Components/Feedback/ProgressBar", component: ProgressBar, parameters: { layout: "padded" }, argTypes: { intent: intentArgType }, args: { intent: "accent", isIndeterminate: false, isLabelVisible: false, isValueShown: false, max: 100, size: "md", }, } satisfies Meta export default meta type Story = StoryObj /** * The name comes from a real `aria-labelledby` even though the label * is not printed, and the value sits on the *track* — so an agent's * bounding box is the widget, not the filled 38%. */ export const Playground: Story = { parameters: playgroundParameters, args: { label: "Ripping title 4 of 9", value: 38 }, } export const AllVariants: Story = { args: { label: "Ripping", value: 62 }, render: (progressProps) => ( ), } export const AllStates: Story = { args: { label: "Ripping title 4 of 9" }, render: (progressProps) => ( ), } /** * "Unknown", not "zero" — so no `aria-valuenow` at all. * * rip-deck's AACS/BD+ preamble is ~25 s of a real Blu-ray emitting * nothing: a full bar reads as a finished rip, an empty one as a * wedged drive. */ export const Indeterminate: Story = { args: { isIndeterminate: true, isLabelVisible: true, label: "Working — no measurable progress yet", }, } export const Responsive: Story = { args: { isLabelVisible: true, isValueShown: true, label: "Ripping title 4 of 9 — Blade Runner (1982)", value: 47, }, render: (progressProps) => ( ), } const SteppedProgressBar = () => { const [percent, setPercent] = useState(0) return (
) } /** * A progressbar is not focusable and has no keyboard path — the * contract it owes an agent is that `aria-valuenow` tracks what is * drawn. Advance it to 100% and the threshold flips the fill green. */ export const Interactive: Story = { args: { label: "Ripping title 4 of 9" }, render: () => , }