diff --git a/components/Table/Pagination.tsx b/components/Table/Pagination.tsx new file mode 100644 index 00000000..c8f4c309 --- /dev/null +++ b/components/Table/Pagination.tsx @@ -0,0 +1,81 @@ +import { Box, Flex } from "@livepeer/design-system"; +import { ArrowLeftIcon, ArrowRightIcon } from "@radix-ui/react-icons"; + +type PaginationProps = { + currentPage: number; + totalPages: number; + canPrevious: boolean; + canNext: boolean; + onPrevious: () => void; + onNext: () => void; + css?: object; +}; + +const Pagination = ({ + currentPage, + totalPages, + canPrevious, + canNext, + onPrevious, + onNext, + css, +}: PaginationProps) => { + if (totalPages <= 0) return null; + + return ( + + { + if (canPrevious) { + onPrevious(); + } + }} + > + + + + Page {currentPage} of{" "} + {totalPages} + + { + if (canNext) { + onNext(); + } + }} + > + + + + ); +}; + +export default Pagination; diff --git a/components/Table/index.tsx b/components/Table/index.tsx index 6e9832fa..c0d2df11 100644 --- a/components/Table/index.tsx +++ b/components/Table/index.tsx @@ -8,12 +8,7 @@ import { Thead, Tr, } from "@livepeer/design-system"; -import { - ArrowLeftIcon, - ArrowRightIcon, - ChevronDownIcon, - ChevronUpIcon, -} from "@radix-ui/react-icons"; +import { ChevronDownIcon, ChevronUpIcon } from "@radix-ui/react-icons"; import { ReactNode } from "react"; import { Column, @@ -26,6 +21,8 @@ import { useTable, } from "react-table"; +import Pagination from "./Pagination"; + function DataTable({ heading = null, input = null, @@ -243,45 +240,14 @@ function DataTable({ - - { - if (canPreviousPage) { - previousPage(); - } - }} - /> - - Page {pageIndex + 1} of{" "} - {pageCount} - - { - if (canNextPage) { - nextPage(); - } - }} - /> - +