From 6c107fcd46faef2ff57dfc0eb56b21738bb85f51 Mon Sep 17 00:00:00 2001 From: tszhong0411 Date: Thu, 9 Jan 2025 23:46:10 +0800 Subject: [PATCH 1/7] feat(ui): add pagination component --- .changeset/ninety-spies-crash.md | 5 + .../docs/src/app/ui/components/pagination.mdx | 39 ++++++ .../demos/pagination/pagination.tsx | 40 +++++++ apps/docs/src/config/links.ts | 4 + packages/ui/src/index.ts | 1 + packages/ui/src/pagination.tsx | 113 ++++++++++++++++++ 6 files changed, 202 insertions(+) create mode 100644 .changeset/ninety-spies-crash.md create mode 100644 apps/docs/src/app/ui/components/pagination.mdx create mode 100644 apps/docs/src/components/demos/pagination/pagination.tsx create mode 100644 packages/ui/src/pagination.tsx diff --git a/.changeset/ninety-spies-crash.md b/.changeset/ninety-spies-crash.md new file mode 100644 index 00000000..bc2e7f39 --- /dev/null +++ b/.changeset/ninety-spies-crash.md @@ -0,0 +1,5 @@ +--- +'@tszhong0411/ui': patch +--- + +add pagination component diff --git a/apps/docs/src/app/ui/components/pagination.mdx b/apps/docs/src/app/ui/components/pagination.mdx new file mode 100644 index 00000000..41e23531 --- /dev/null +++ b/apps/docs/src/app/ui/components/pagination.mdx @@ -0,0 +1,39 @@ +--- +title: Pagination +description: Pagination with page navigation, next and previous links. +--- + + + +## Usage + +```tsx +import { + Pagination, + PaginationContent, + PaginationEllipsis, + PaginationItem, + PaginationLink, + PaginationNext, + PaginationPrevious +} from '@/components/ui/pagination' +``` + +```tsx + + + + + + + 1 + + + + + + + + + +``` diff --git a/apps/docs/src/components/demos/pagination/pagination.tsx b/apps/docs/src/components/demos/pagination/pagination.tsx new file mode 100644 index 00000000..d1c5f775 --- /dev/null +++ b/apps/docs/src/components/demos/pagination/pagination.tsx @@ -0,0 +1,40 @@ +import { + Pagination, + PaginationContent, + PaginationEllipsis, + PaginationItem, + PaginationLink, + PaginationNext, + PaginationPrevious +} from '@tszhong0411/ui' + +const PaginationDemo = () => { + return ( + + + + + + + 1 + + + + 2 + + + + 3 + + + + + + + + + + ) +} + +export default PaginationDemo diff --git a/apps/docs/src/config/links.ts b/apps/docs/src/config/links.ts index c236a945..ed5d8a3e 100644 --- a/apps/docs/src/config/links.ts +++ b/apps/docs/src/config/links.ts @@ -118,6 +118,10 @@ export const SIDEBAR_LINKS: SidebarLinks = [ href: '/ui/components/marquee', text: 'Marquee' }, + { + href: '/ui/components/pagination', + text: 'Pagination' + }, { href: '/ui/components/popover', text: 'Popover' diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts index 9b8a7d90..a1f8bd77 100644 --- a/packages/ui/src/index.ts +++ b/packages/ui/src/index.ts @@ -22,6 +22,7 @@ export * from './label' export * from './link' export * from './logo' export * from './marquee' +export * from './pagination' export * from './popover' export * from './scroll-area' export * from './select' diff --git a/packages/ui/src/pagination.tsx b/packages/ui/src/pagination.tsx new file mode 100644 index 00000000..d8129503 --- /dev/null +++ b/packages/ui/src/pagination.tsx @@ -0,0 +1,113 @@ +import { cn } from '@tszhong0411/utils' +import { ChevronLeftIcon, ChevronRightIcon, MoreHorizontalIcon } from 'lucide-react' +import Link from 'next/link' + +import { type ButtonProps, buttonVariants } from './button' + +type PaginationProps = React.ComponentProps<'nav'> + +export const Pagination = (props: PaginationProps) => { + const { className, ...rest } = props + + return ( +