Drop page / section descriptions, state notes and repeated captions from the representative Stories of 44 components, the Patterns, Center Graphic and OrgChart pages. Value readouts, spec lists and captions hide only on the representative page; hidden verification Stories keep them. Tabs Default API and the Filter Bar draft / applied counts move to the hidden DefaultApi and DraftApplied Stories; Center Overview is hidden with its direct URL kept. Story IDs are unchanged. Align the component, pattern and OrgChart docs with the pages, point the quality reference check at the DraftApplied Story, and make the P8 styles check expect no section header on the preview-only Expanded page.
119 lines
4.5 KiB
TypeScript
119 lines
4.5 KiB
TypeScript
import type { Meta, StoryObj } from "@storybook/react-vite"
|
|
import { BoldIcon, ItalicIcon, StarIcon } from "lucide-react"
|
|
import { Toggle, ToggleGroup, ToggleGroupItem } from "@hm-design/ui"
|
|
import { StateBoard } from "@/components/story-board"
|
|
import { StoryPage, StoryPageHeader, StorySection } from "@/components/story-page"
|
|
|
|
// Toggle is a persistent pressed-state control. The representative Story shows each state with real, clickable toggles; the same
|
|
// specimens also exist as Stories tagged `verification` (hidden from the sidebar). Icon-only toggles carry an `aria-label`.
|
|
|
|
function OffOn() {
|
|
return (
|
|
<div className="flex flex-wrap items-center gap-3">
|
|
<Toggle>Off</Toggle>
|
|
<Toggle defaultPressed>On</Toggle>
|
|
<Toggle variant="outline">Outline off</Toggle>
|
|
<Toggle variant="outline" defaultPressed>
|
|
Outline on
|
|
</Toggle>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function WithIcon() {
|
|
return (
|
|
<div className="flex flex-wrap items-center gap-3">
|
|
<Toggle aria-label="굵게">
|
|
<BoldIcon />
|
|
</Toggle>
|
|
<Toggle aria-label="기울임" defaultPressed>
|
|
<ItalicIcon />
|
|
</Toggle>
|
|
<Toggle variant="outline">
|
|
<StarIcon />
|
|
즐겨찾기
|
|
</Toggle>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function Sizes() {
|
|
return (
|
|
<div className="grid gap-3">
|
|
{(["sm", "default", "lg"] as const).map((size) => (
|
|
<div key={size} data-toggle-size={size} className="flex flex-wrap items-center gap-3">
|
|
<Toggle size={size} variant="outline" aria-label={`${size} icon-only`}><StarIcon /></Toggle>
|
|
<Toggle size={size} variant="outline"><StarIcon />즐겨찾기</Toggle>
|
|
<Toggle size={size} variant="outline">{size}</Toggle>
|
|
</div>
|
|
))}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function Disabled() {
|
|
return (
|
|
<div className="flex flex-wrap items-center gap-3">
|
|
<Toggle disabled>Disabled off</Toggle>
|
|
<Toggle disabled defaultPressed>
|
|
Disabled on
|
|
</Toggle>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
const sections = [
|
|
{ id: "offon", label: "Off / On", node: <OffOn /> },
|
|
{ id: "disabled", label: "Disabled", node: <Disabled /> },
|
|
]
|
|
|
|
const meta = { title: "Components/Form/Toggle", component: Toggle, parameters: { layout: "padded" } } satisfies Meta<typeof Toggle>
|
|
export default meta
|
|
type Story = StoryObj<typeof meta>
|
|
|
|
const board = (...ids: string[]) => (
|
|
<StateBoard min={360} states={sections.filter((s) => 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",
|
|
parameters: { layout: "fullscreen", controls: { disable: true } },
|
|
render: () => (
|
|
<StoryPage>
|
|
<StoryPageHeader title="Toggle" />
|
|
<StorySection title="Overview">{board("offon")}</StorySection>
|
|
<StorySection title="단독 · 연결 그룹">
|
|
<StateBoard
|
|
min={360}
|
|
states={[
|
|
{ id: "single-toggle", label: "단독", children: <Toggle variant="outline">알림</Toggle> },
|
|
{ id: "group-single", label: "연결 그룹 · 단일 선택", children: <ToggleGroup type="single" variant="outline" defaultValue="left" aria-label="정렬"><ToggleGroupItem value="left">왼쪽</ToggleGroupItem><ToggleGroupItem value="center">가운데</ToggleGroupItem><ToggleGroupItem value="right">오른쪽</ToggleGroupItem></ToggleGroup> },
|
|
{ id: "group-multiple", label: "연결 그룹 · 다중 선택", children: <ToggleGroup type="multiple" variant="outline" defaultValue={["bold"]} aria-label="글자 스타일"><ToggleGroupItem value="bold">굵게</ToggleGroupItem><ToggleGroupItem value="italic">기울임</ToggleGroupItem></ToggleGroup> },
|
|
]}
|
|
/>
|
|
</StorySection>
|
|
<StorySection title="Sizes">
|
|
<Sizes />
|
|
</StorySection>
|
|
<StorySection title="States">{board("disabled")}</StorySection>
|
|
</StoryPage>
|
|
),
|
|
}
|
|
|
|
export const States: Story = { tags: ["verification"], render: () => <OffOn /> }
|
|
export const IconOnly: Story = { tags: ["verification"], name: "Icon Only", render: () => <WithIcon /> }
|
|
export const DisabledToggle: Story = { tags: ["verification"], name: "Disabled", render: () => <Disabled /> }
|
|
|
|
export const ContentNodes: Story = {
|
|
tags: ["verification"],
|
|
render: () => (
|
|
<div className="flex flex-wrap gap-3">
|
|
<Toggle aria-label="Array icon">{[<StarIcon key="icon" />]}</Toggle>
|
|
<Toggle aria-label="Fragment icon"><><StarIcon /></></Toggle>
|
|
<Toggle><><StarIcon />즐겨찾기</></Toggle>
|
|
<Toggle><StarIcon /><span>즐겨찾기</span></Toggle>
|
|
</div>
|
|
),
|
|
}
|