97 lines
3.7 KiB
TypeScript
97 lines
3.7 KiB
TypeScript
import type { Meta, StoryObj } from "@storybook/react-vite"
|
|
import { Separator } from "@hm-design/ui"
|
|
import { StateBoard, type BoardState } from "@/components/story-board"
|
|
import { StoryPage, StoryPageHeader, StorySection } from "@/components/story-page"
|
|
|
|
const meta = {
|
|
title: "Components/Data & Display/Separator",
|
|
component: Separator,
|
|
parameters: {
|
|
layout: "padded",
|
|
docs: {
|
|
description: {
|
|
component:
|
|
"현재 HM 규격: 1px 선, 색은 pale warm neutral(Primitive 참조). Radix Separator의 orientation과 decorative(기본 true) API를 유지합니다. decorative=false이면 role=separator가 노출됩니다.",
|
|
},
|
|
},
|
|
},
|
|
argTypes: { orientation: { control: "inline-radio", options: ["horizontal", "vertical"] }, decorative: { control: "boolean" } },
|
|
} satisfies Meta<typeof Separator>
|
|
export default meta
|
|
type Story = StoryObj<typeof meta>
|
|
|
|
// Representative-page layout (Storybook presentation only): equal columns on PC (iframe width 1000px and up), fewer below that
|
|
// (240px minimum). Each specimen sits in its own single-column StateBoard (min larger than any column), so every subtitle and divider
|
|
// has the width of its column; a section with fewer specimens than columns leaves the remaining columns empty.
|
|
const specimenColumns = {
|
|
2: "min-[1000px]:grid-cols-2",
|
|
3: "min-[1000px]:grid-cols-3",
|
|
4: "min-[1000px]:grid-cols-4",
|
|
} as const
|
|
|
|
function SpecimenGrid({ states, columns }: { states: BoardState[]; columns: 2 | 3 | 4 }) {
|
|
return (
|
|
<div className={`grid items-start gap-6 [grid-template-columns:repeat(auto-fill,minmax(min(100%,240px),1fr))] ${specimenColumns[columns]}`}>
|
|
{states.map((state) => (
|
|
<StateBoard key={state.id} min={10000} states={[state]} />
|
|
))}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
// Representative Story: Overview (Horizontal) and Variants (Vertical, Semantic) are merged into one Variants section. 3 columns on PC.
|
|
export const All: Story = {
|
|
name: "Separator",
|
|
parameters: { layout: "fullscreen", controls: { disable: true } },
|
|
render: () => (
|
|
<StoryPage>
|
|
<StoryPageHeader title="Separator" />
|
|
<StorySection title="Variants">
|
|
<SpecimenGrid
|
|
columns={3}
|
|
states={[
|
|
{
|
|
id: "horizontal",
|
|
label: "Horizontal",
|
|
children: (
|
|
<div className="grid gap-3 text-sm">
|
|
<div><strong>제목</strong><p>제목에 연결된 설명입니다.</p></div>
|
|
<Separator />
|
|
<span>Below</span>
|
|
</div>
|
|
),
|
|
},
|
|
{
|
|
id: "vertical",
|
|
label: "Vertical",
|
|
children: (
|
|
<div className="flex h-6 items-center gap-3 text-sm">
|
|
<span>Left</span>
|
|
<Separator orientation="vertical" />
|
|
<span>Middle</span>
|
|
<Separator orientation="vertical" />
|
|
<span>Right</span>
|
|
</div>
|
|
),
|
|
},
|
|
{
|
|
id: "semantic",
|
|
label: "Semantic",
|
|
children: (
|
|
<div className="grid gap-3 text-sm">
|
|
<span>Section A</span>
|
|
<Separator decorative={false} />
|
|
<span>Section B</span>
|
|
</div>
|
|
),
|
|
},
|
|
]}
|
|
/>
|
|
</StorySection>
|
|
</StoryPage>
|
|
),
|
|
}
|
|
|
|
export const Horizontal: Story = { tags: ["verification"], render: () => <div className="max-w-xs"><Separator /></div> }
|
|
export const Vertical: Story = { tags: ["verification"], render: () => <div className="flex h-8 items-center"><Separator orientation="vertical" /></div> }
|