import type { Meta, StoryObj } from "@storybook/react-vite"; import { pagination } from "../"; import { Button, Pagination } from "../react"; import styles from "../styles.module.css"; const meta = { title: "Designsystem/Pagination", argTypes: { current: { description: "Nåværede side", table: { type: { summary: "number" }, }, }, total: { description: "Totalt antall sider", table: { type: { summary: "number" }, }, }, show: { description: "Maks antall tall/dotter som skal vises i paginasjonen", table: { defaultValue: { summary: "7" }, type: { summary: "number" }, }, }, props: { description: "Funksjon som lager props som skal legges på hver lenke/knapp", table: { type: { summary: `({ page: number, type: "prev" | "next" | "page" }) => ({ ...props })`, detail: `Eksempel: ({ page }) => ({ href: \`?p=\${page}\` })`, }, }, }, }, decorators: [ (Story) => (
), ], } satisfies Meta; export default meta; type Story = StoryObj; export const WithLinks: Story = { render: () => ( ), }; export const React: Story = { render: () => { const { pages, next, prev } = pagination({ current: 1, total: 20, show: 7, }); return ( <> Rendering using separate elements:
Rendering using helper-function:
Rendering buttons using props: ({ onClick: () => alert(page) })} />
Rendering links using props: ({ href: `?p=${page}` })} /> ); }, }; export const WithButtons: Story = { render: () => (
), }; export const Sizes: Story = { render: () => ( <>
), }; export const Variants: Story = { render: () => ( <>
), }; export const WithHelper: Story = { render: () => { const { pages, next, prev } = pagination({ current: 1, total: 20, show: 7, }); return (
  • {pages.map(({ current, key, page }) => (
  • {!!page && ( )}
  • ))}
); }, };