From ccbfe8fe6c770533dc9c38dcc5729b7e67b44957 Mon Sep 17 00:00:00 2001 From: mattfeng6 Date: Sun, 12 Oct 2025 18:07:58 -0400 Subject: [PATCH] reformat dataTable pagination style --- .../src/DataTable/DataTable.tsx | 18 +-- .../src/DataTable/components/Pagination.tsx | 121 ++++++++++++++++-- 2 files changed, 123 insertions(+), 16 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx b/superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx index 21ce6541cf2f..d33cfd4c3e8e 100644 --- a/superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx +++ b/superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx @@ -405,14 +405,16 @@ export default typedMemo(function DataTable({ ) : null} {wrapStickyTable ? wrapStickyTable(renderTable) : renderTable()} {hasPagination && resultPageCount > 1 ? ( - +
+ +
) : null} ); diff --git a/superset-frontend/plugins/plugin-chart-table/src/DataTable/components/Pagination.tsx b/superset-frontend/plugins/plugin-chart-table/src/DataTable/components/Pagination.tsx index 870405453389..50ba1da53217 100644 --- a/superset-frontend/plugins/plugin-chart-table/src/DataTable/components/Pagination.tsx +++ b/superset-frontend/plugins/plugin-chart-table/src/DataTable/components/Pagination.tsx @@ -17,6 +17,7 @@ * under the License. */ import { CSSProperties, forwardRef, memo, Ref } from 'react'; +import { styled } from '@superset-ui/core'; export interface PaginationProps { pageCount: number; // number of pages @@ -30,6 +31,81 @@ export interface PaginationProps { // first, ..., prev, current, next, ..., last const MINIMAL_PAGE_ITEM_COUNT = 7; +// Styled components to match the main pagination style +const PaginationList = styled.ul` + display: inline-block; + margin: 16px 0; + padding: 0; + + li { + display: inline; + margin: 0 4px; + + span, a { + padding: 8px 12px; + text-decoration: none; + background-color: ${({ theme }) => theme.colors.grayscale.light5}; + border-radius: ${({ theme }) => theme.borderRadius}px; + color: inherit; + cursor: pointer; + border: none; + + &:hover, + &:focus { + z-index: 2; + color: ${({ theme }) => theme.colors.grayscale.dark1}; + background-color: ${({ theme }) => theme.colors.grayscale.light3}; + } + } + + &.active { + span, a { + z-index: 3; + color: ${({ theme }) => theme.colors.grayscale.light5}; + cursor: default; + background-color: ${({ theme }) => theme.colors.primary.base}; + + &:focus { + outline: none; + } + } + } + + &.disabled { + span { + background-color: transparent; + cursor: default; + opacity: 0.5; + + &:focus { + outline: none; + } + + &:hover { + background-color: transparent; + } + } + } + + &.dt-pagination-ellipsis { + span { + cursor: default; + &:hover { + background-color: ${({ theme }) => theme.colors.grayscale.light5}; + } + } + } + } +`; + +const PaginationContainer = styled.div` + &.dt-pagination { + display: flex; + justify-content: center; + align-items: center; + } +`; + /** * Generate numeric page items around current page. * - Always include first and last page @@ -89,8 +165,23 @@ export default memo( maxPageItemCount, ); return ( -
- -
+ + {/* Next button */} +
  • + { + e.preventDefault(); + if (currentPage < pageCount - 1) onPageChange(currentPage + 1); + }} + > + » + +
  • + + ); }), );