/* * (c) Copyright 2026 Palantir Technologies Inc. All rights reserved. */ import type { Meta, StoryObj } from "@storybook/react-vite"; import { storybookLayoutDecorator, StoryLabel } from "@storybook-common"; import { type ComponentProps } from "react"; import { Flex } from "@blueprintjs/labs"; import { Switch } from "./controls"; const disabledArgs = ["large", "tagName", "labelElement", "inputRef"] as const satisfies ReadonlyArray< keyof ComponentProps >; const meta: Meta = { title: "Core/Form/Controls/Switch", component: Switch, decorators: [storybookLayoutDecorator], tags: ["autodocs"], args: { label: "Switch", disabled: false, inline: false, size: "medium", }, argTypes: { size: { control: "select", options: ["medium", "large"], }, disabled: { control: "boolean", }, inline: { control: "boolean", }, innerLabel: { control: "text", }, innerLabelChecked: { control: "text", }, defaultChecked: { control: "boolean", }, onChange: { action: "changed" }, ...disabledArgs.reduce( (acc, argName) => { acc[argName] = { table: { disable: true } }; return acc; }, {} as Record<(typeof disabledArgs)[number], { table: { disable: boolean } }>, ), }, } satisfies Meta; export default meta; type Story = StoryObj; /** * A basic switch with default styling. */ export const Default: Story = { args: { label: "Enable dark mode", }, }; /** * Use the `size` prop to adjust the switch dimensions. */ export const SizeExample: Story = { name: "Size", argTypes: { size: { table: { disable: true } }, }, render: args => ( ), }; /** * Switches support `disabled`, `checked`, and `inline` states. */ export const StateExample: Story = { name: "State", argTypes: { disabled: { table: { disable: true } }, inline: { table: { disable: true } }, defaultChecked: { table: { disable: true } }, }, render: args => (
), }; /** * All states across all sizes. */ export const AllStates: Story = { name: "All States", render: args => ( {(["medium", "large"] as const).map(size => (
))}
), }; /** * Interactive playground with all props toggleable via Storybook controls. */ export const Playground: Story = { args: { label: "Enable feature", innerLabel: "Off", innerLabelChecked: "On", defaultChecked: false, }, };