import { useState, type ReactNode } from "react" import type { Meta, StoryObj } from "@storybook/react-vite" import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, } from "@hm-design/ui" import { StateBoard } from "@/components/story-board" import { STORY_KICKER, StoryPage, StoryPageHeader, StorySection } from "@/components/story-page" // Pagination is presentational: the consumer owns the page and the hrefs. The Story keeps the page in local state and uses // `#page-N` hrefs with preventDefault. The representative Story shows each case on one page; the same specimens also exist as // Stories tagged `verification` (hidden from the sidebar). // Page list with ellipses: 1 … (p-1 p p+1) … total. function pageRange(page: number, total: number): (number | "start" | "end")[] { if (total <= 7) return Array.from({ length: total }, (_, i) => i + 1) const out: (number | "start" | "end")[] = [1] const from = Math.max(2, Math.min(page - 1, total - 4)) const to = Math.min(total - 1, Math.max(page + 1, 5)) if (from > 2) out.push("start") for (let p = from; p <= to; p++) out.push(p) if (to < total - 1) out.push("end") out.push(total) return out } function Specimen({ total, initial }: { total: number; initial: number }) { const [page, setPage] = useState(initial) const go = (p: number) => (event: React.MouseEvent) => { event.preventDefault() setPage(p) } return (
{`현재 ${page} / ${total}`}