import { useState, type ReactNode } 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 { 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`.
// `showValue={false}` hides the selected-value readout on the representative page; the verification Stories keep it.
function Single({ showValue = true }: { showValue?: boolean }) {
const [value, setValue] = useState("left")
return (
v && setValue(v)} aria-label="정렬">
왼쪽
가운데
오른쪽
{showValue ? {`value = ${value}`} : null}
)
}
function Multiple({ showValue = true }: { showValue?: boolean }) {
const [value, setValue] = useState(["bold"])
return (
{showValue ? {`value = [${value.join(", ")}]`} : null}
)
}
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}
))}
)
}
// 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
// The representative page shows the groups without example titles: the section title names them.
const examples = (...nodes: ReactNode[]) => (
{nodes.map((node, i) => (
{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: () => (
{examples()}
{examples(, , )}
{examples()}
{examples(
)}
),
}
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: () => (
{[]}
<>>
<>굵게>
굵게
),
}