From 13c5f6763235e19cca651e5fd1ae1891b9046f48 Mon Sep 17 00:00:00 2001 From: Rick Staa Date: Sun, 1 Feb 2026 17:25:48 +0100 Subject: [PATCH 1/4] refactor: extract table pagination into reusable component Move table pagination logic into seperate component so it can be reused across the app. Co-authored-by: roaring30s --- components/Table/Pagination.tsx | 67 +++++++++++++++++++++++++++++++++ components/Table/index.tsx | 56 ++++++--------------------- 2 files changed, 78 insertions(+), 45 deletions(-) create mode 100644 components/Table/Pagination.tsx diff --git a/components/Table/Pagination.tsx b/components/Table/Pagination.tsx new file mode 100644 index 00000000..5a8ee131 --- /dev/null +++ b/components/Table/Pagination.tsx @@ -0,0 +1,67 @@ +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) => { + 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(); - } - }} - /> - + From c5dcce701b86d1512f9d78bcf2053abc3cf6783c Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Feb 2026 08:36:40 -0700 Subject: [PATCH 2/4] fix: handle zero pages edge case in Pagination component (#528) * Initial plan * fix: hide pagination when totalPages is 0 Co-authored-by: rickstaa <17570430+rickstaa@users.noreply.github.com> * Update components/Table/Pagination.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: rickstaa <17570430+rickstaa@users.noreply.github.com> Co-authored-by: ECWireless <40322776+ECWireless@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- components/Table/Pagination.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/Table/Pagination.tsx b/components/Table/Pagination.tsx index 5a8ee131..186397d4 100644 --- a/components/Table/Pagination.tsx +++ b/components/Table/Pagination.tsx @@ -20,6 +20,11 @@ const Pagination = ({ onNext, css, }: PaginationProps) => { + // Don't render pagination when there are no pages + if (totalPages <= 0) { + return null; + } + return ( Date: Mon, 2 Feb 2026 08:44:53 -0700 Subject: [PATCH 3/4] fix: add accessibility attributes to Pagination --- components/Table/Pagination.tsx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/components/Table/Pagination.tsx b/components/Table/Pagination.tsx index 186397d4..ea9fd45b 100644 --- a/components/Table/Pagination.tsx +++ b/components/Table/Pagination.tsx @@ -36,8 +36,12 @@ const Pagination = ({ }} > + > + + Page {currentPage} of{" "} {totalPages} + > + + ); }; From 2ffd3b8fab1f754c1c148a7ddd0d764ec7ba664a Mon Sep 17 00:00:00 2001 From: ECWireless Date: Mon, 2 Feb 2026 08:47:06 -0700 Subject: [PATCH 4/4] chore: simplify totalPages check in Pagination --- components/Table/Pagination.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/components/Table/Pagination.tsx b/components/Table/Pagination.tsx index ea9fd45b..c8f4c309 100644 --- a/components/Table/Pagination.tsx +++ b/components/Table/Pagination.tsx @@ -20,10 +20,7 @@ const Pagination = ({ onNext, css, }: PaginationProps) => { - // Don't render pagination when there are no pages - if (totalPages <= 0) { - return null; - } + if (totalPages <= 0) return null; return (