diff --git a/src/components/ui/Pagination.stories.tsx b/src/components/ui/Pagination.stories.tsx new file mode 100644 index 0000000..b04183d --- /dev/null +++ b/src/components/ui/Pagination.stories.tsx @@ -0,0 +1,166 @@ +import type { Meta, StoryObj } from "@storybook/react"; +import { + Pagination, + PaginationContent, + PaginationEllipsis, + PaginationItem, + PaginationLink, + PaginationNext, + PaginationPrevious, +} from "./pagination"; + +const meta = { + title: "UI/Pagination", + component: Pagination, + parameters: { layout: "centered" }, + tags: ["autodocs"], +} satisfies Meta; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = { + render: () => ( + + + + + + + 1 + + + + 2 + + + + 3 + + + + + + + + + + ), +}; + +export const ManyPages: Story = { + render: () => ( + + + + + + + 1 + + + + + + 4 + + + + 5 + + + + 6 + + + + + + 20 + + + + + + + ), +}; + +export const FirstPage: Story = { + render: () => ( + + + + + 1 + + + + 2 + + + 3 + + + + + + + + + + ), +}; + +export const LastPage: Story = { + render: () => ( + + + + + + + + + + 8 + + + 9 + + + + 10 + + + + + ), +}; + +export const IconsOnly: Story = { + render: () => ( + + + + + + + 1 + + + + 2 + + + + 3 + + + + + + + ), +}; diff --git a/src/components/ui/index.ts b/src/components/ui/index.ts index cee164b..510ab30 100644 --- a/src/components/ui/index.ts +++ b/src/components/ui/index.ts @@ -333,6 +333,18 @@ export { type LayoutContextValue, } from "../wordpress/layout"; +// Pagination +export { + Pagination, + PaginationContent, + PaginationEllipsis, + PaginationItem, + PaginationLink, + PaginationNext, + PaginationPrevious, + type PaginationLinkProps, +} from "./pagination"; + // Sonner (toast notifications) export { Toaster } from "./sonner"; diff --git a/src/components/ui/pagination.tsx b/src/components/ui/pagination.tsx new file mode 100644 index 0000000..a542f28 --- /dev/null +++ b/src/components/ui/pagination.tsx @@ -0,0 +1,128 @@ +import * as React from "react"; +import { + ChevronLeftIcon, + ChevronRightIcon, + MoreHorizontalIcon, +} from "lucide-react"; + +import { cn } from "@/lib/utils"; +import { buttonVariants, type ButtonProps } from "./button"; + +function Pagination({ className, ...props }: React.ComponentProps<"nav">) { + return ( +