import { Fragment, type ReactNode } from "react"
import type { Meta, StoryObj } from "@storybook/react-vite"
import {
Breadcrumb,
BreadcrumbEllipsis,
BreadcrumbItem,
BreadcrumbLink,
BreadcrumbList,
BreadcrumbPage,
BreadcrumbSeparator,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "@hm-design/ui"
import { StateBoard, type BoardState } from "@/components/story-board"
import { StoryPage, StoryPageHeader, StorySection } from "@/components/story-page"
// The representative "Breadcrumb" Story shows each case on one page (real links with sample hrefs); the same specimens also exist
// as Stories tagged `verification` (hidden from the sidebar). BreadcrumbEllipsis is presentational: the Dropdown Menu example is
// a consumer composition, not part of Breadcrumb.
const narrow = (children: ReactNode) =>
{children}
function Basic() {
return (
홈
사용자
상세
)
}
function Ellipsis() {
return (
홈
문서
설정
프로젝트
상세
)
}
function Long() {
const labels = ["홈", "프로젝트", "한맥 프로젝트 관리 시스템", "노선 정보", "시설물 목록", "교량", "상세 정보 및 점검 이력"]
return (
{labels.map((label, i) => (
{i === labels.length - 1 ? {label} : {label}}
{i < labels.length - 1 ? : null}
))}
)
}
// asChild: the link is any element (here a plain standing in for a router Link) and keeps the Breadcrumb look.
function CustomLink() {
return (
홈 (custom link)
/
현재 페이지
)
}
const sections = [
{ id: "basic", label: "Basic", node: },
{ id: "ellipsis", label: "Ellipsis", node: },
{ id: "long", label: "Long path", node: },
{ id: "custom", label: "Custom link · separator", node: },
]
const meta = { title: "Components/Navigation/Breadcrumb", component: Breadcrumb, parameters: { layout: "padded" } } satisfies Meta
export default meta
type Story = StoryObj
// Representative-page layout (Storybook presentation only): Variants use 3 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
// StateBoard's auto-fill grid cannot leave an empty or stretched track.
const specimen = (id: string, children?: ReactNode): BoardState => {
const s = sections.find((section) => section.id === id)!
return { id: s.id, label: s.label, children: children ?? narrow(s.node) }
}
// Representative Story: the common Story page; the sections group the same specimens.
// Overview is merged into Variants (Basic is its first item). The Long path example gets up to 900px so it fits on one line on
// PC; BreadcrumbList is `flex-wrap`, so it wraps naturally (never clipped or forced nowrap) when the space is narrower.
export const All: Story = {
name: "Breadcrumb",
parameters: { layout: "fullscreen", controls: { disable: true } },
render: () => (
{["basic", "ellipsis", "custom"].map((id) => (
))}
{sections.find((s) => s.id === "long")!.node})]} />
),
}
export const Basic3: Story = { tags: ["verification"], name: "Basic", render: () => }
export const WithEllipsis: Story = { tags: ["verification"], name: "Ellipsis", render: () => }
export const LongPath: Story = { tags: ["verification"], name: "Long Path", render: () => narrow() }