import { useState } from "react"
import type { Meta, StoryObj } from "@storybook/react-vite"
import { AlignCenterIcon, AlignLeftIcon, AlignRightIcon, BoldIcon, ItalicIcon, UnderlineIcon } from "lucide-react"
import { ToggleGroup, ToggleGroupItem } from "@hm-design/ui"
import { StateBoard } from "@/components/story-board"
import { STORY_KICKER, StoryPage, StoryPageHeader, StorySection } from "@/components/story-page"
// Toggle Group is a group of pressed-state items (toolbar-style), not a content switcher (that is Tabs). The representative Story
// shows single / multiple / icon-only / disabled / vertical / spaced groups with real controls; the same specimens also exist as
// Stories tagged `verification` (hidden from the sidebar). Icon-only items carry an `aria-label`.
function Single() {
const [value, setValue] = useState("left")
return (
v && setValue(v)} aria-label="정렬">
왼쪽
가운데
오른쪽
{`value = ${value}`}
)
}
function Multiple() {
const [value, setValue] = useState(["bold"])
return (
{`value = [${value.join(", ")}]`}
)
}
function Disabled() {
return (
A
B
A
B (비활성)
C
)
}
function Vertical() {
return (
)
}
function Spaced() {
return (
첫째
둘째
셋째
)
}
function Many() {
return (
{Array.from({ length: 10 }, (_, i) => (
{`옵션 ${i + 1}`}
))}
)
}
function Sizes() {
return (
{(["sm", "default", "lg"] as const).map((size) => (
굵게
{size}
))}
)
}
const sections = [
{ id: "single", label: "Single selection", node: },
{ id: "multiple", label: "Multiple selection (icon-only)", node: },
{ id: "sizes", label: "Sizes · Icon-only / Icon + Text / Text-only", node: },
{ id: "disabled", label: "Disabled group / item", node: },
{ id: "vertical", label: "Vertical", node: },
{ id: "spaced", label: "spacing={2} (separated)", node: },
{ id: "many", label: "Many items (spacing + flex-wrap, consumer opts in)", node: },
]
// No `component`: ToggleGroup props are a union (single | multiple), so Stories without args would not type-check.
const meta = { title: "Components/Form/Toggle Group", parameters: { layout: "padded" } } satisfies Meta
export default meta
type Story = StoryObj
const board = (...ids: string[]) => (
ids.includes(s.id)).map((s) => ({ id: s.id, label: s.label, children: s.node }))} />
)
// Representative Story: the common Story page; the sections group the same specimens.
export const All: Story = {
name: "Toggle Group",
parameters: { layout: "fullscreen", controls: { disable: true } },
render: () => (
{board("single")}
{board("multiple", "vertical", "spaced")}
{board("disabled")}
{board("many")}
),
}
export const SingleSelection: Story = { tags: ["verification"], name: "Single", render: () => }
export const MultipleSelection: Story = { tags: ["verification"], name: "Multiple", render: () => }
export const VerticalGroup: Story = { tags: ["verification"], name: "Vertical", render: () => }
export const ContentNodes: Story = {
tags: ["verification"],
render: () => (
{[]}
<>>
<>굵게>
굵게
),
}