import type { ReactNode } from "react" import type { Meta, StoryObj } from "@storybook/react-vite" import { ScrollArea, ScrollBar } from "@hm-design/ui" import { StateBoard } from "@/components/story-board" import { StoryPage, StoryPageHeader, StorySection } from "@/components/story-page" // Scroll Area is Radix scrolling with a styled scrollbar (type "hover": the bar shows while hovering or scrolling). Sizes below // are Story layout. The representative Story shows vertical, horizontal, both axes and a table-like content. const items = Array.from({ length: 30 }, (_, i) => `항목 ${i + 1}`) function Vertical() { return (
{items.map((t) => (
{t}
))}
) } function Horizontal() { return (
{Array.from({ length: 12 }, (_, i) => (
{`카드 ${i + 1}`}
))}
) } function Both() { return (
{items.map((t) => (
{`${t} — 가로로도 길어지는 내용입니다. 가로 scroll로 끝까지 볼 수 있습니다.`}
))}
) } function TableLike() { return (
{Array.from({ length: 12 }, (_, r) => (
{["번호", "이름", "상태", "금액"].map((c) => ( {`${c} ${r + 1}`} ))}
))}
) } const sections: { id: string; label: string; node: ReactNode }[] = [ { id: "vertical", label: "Vertical", node: }, { id: "horizontal", label: "Horizontal", node: }, { id: "both", label: "Both axes", node: }, { id: "table-like", label: "Table-like content", node: }, ] const meta = { title: "Components/Data & Display/Scroll Area", component: ScrollArea, parameters: { layout: "padded" } } satisfies Meta export default meta type Story = StoryObj // Representative-page layout (Storybook presentation only): equal columns on PC (iframe width 1000px and up), fewer below that // (300px 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({ ids, columns, spans = {} }: { ids: string[]; columns: 2 | 3 | 4; spans?: Record }) { return (
{ids.map((id) => { const s = sections.find((section) => section.id === id)! return (
) })}
) } // Representative Story: the common Story page; the sections group the same specimens. // Representative Story: Overview (Vertical) is merged into Variants (Vertical, Horizontal, Both axes); Table-like stays under Usage. 3 columns on PC. export const All: Story = { name: "Scroll Area", parameters: { layout: "fullscreen", controls: { disable: true } }, render: () => ( ), } export const VerticalScroll: Story = { tags: ["verification"], name: "Vertical", render: () => } export const HorizontalScroll: Story = { tags: ["verification"], name: "Horizontal", render: () => }