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 { STORY_KICKER, 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 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: "Scroll Area", parameters: { layout: "fullscreen", controls: { disable: true } }, render: () => ( {board("vertical")} {board("horizontal", "both")} {board("table-like")} ), } export const VerticalScroll: Story = { tags: ["verification"], name: "Vertical", render: () => } export const HorizontalScroll: Story = { tags: ["verification"], name: "Horizontal", render: () => }