import { For } from "solid-js" import { iconNames } from "@opencode/ui/icons/catalog" import { Button, type ButtonProps } from "./button" type Args = Pick & { children: string icon: string interaction: "rest" | "hover" | "pressed" | "focus" expanded: boolean } const variants = [ "neutral", "danger", "warning", "outline", "contrast", "submit", "ghost", "ghost-muted", "ghost-faint", "ghost-danger", "loading", ] satisfies ButtonProps["variant"][] const sizes = ["small", "normal", "large"] satisfies ButtonProps["size"][] const interactions = ["rest", "hover", "pressed", "focus"] as const const label = (value: string) => value[0].toUpperCase() + value.slice(1).replaceAll("-", " ") const docs = `### Overview Button v2 with visual variants and three sizes. ### API - \`variant\`: ${variants.join(", ")}. Submit shares the brighter contrast icon-button styling for Composer submission actions. - \`size\`: small, normal or large. - \`icon\`: Optional icon name. - Inherits native button attributes. ### States Default, hover, pressed, focus and disabled. Try the pointer and keyboard, or pin an interaction in the panel. Expanded styles apply to ghost, ghost-muted and ghost-faint buttons.` function Preview(args: Args) { return ( ) } export default { title: "UI/Button", id: "ui-button", component: Button, tags: ["autodocs"], parameters: { frameHeight: "240px", frameBackground: "#fff", docs: { description: { component: docs } }, }, args: { children: "Button", variant: "neutral", size: "normal", icon: "none", interaction: "rest", disabled: false, expanded: false, } satisfies Args, argTypes: { variant: { control: "select", options: variants }, size: { control: "select", options: sizes }, icon: { control: "select", options: ["none", ...iconNames().sort()] }, interaction: { control: "select", options: interactions }, }, render: Preview, } export const Playground = {} export const Variants = { render: (args: Args) => (
{(variant) => ( {label(variant)} )}
), } export const Sizes = { render: (args: Args) => (
{(size) => ( {label(size)} )}
), } export const Icon = { args: { icon: "plus" }, render: (args: Args) => (
Normal Large
), } export const AllStates = { render: (args: Args) => (
{(variant) => (
{variant}
{(interaction) => ( {interaction === "rest" ? "Default" : label(interaction)} )} Disabled
)}
), }