diff --git a/site/src/components/PaginationWidget/PaginationWidget.tsx b/site/src/components/PaginationWidget/PaginationWidget.tsx index ba963aed92..b8d4ba10a4 100644 --- a/site/src/components/PaginationWidget/PaginationWidget.tsx +++ b/site/src/components/PaginationWidget/PaginationWidget.tsx @@ -1,7 +1,10 @@ import Button from "@material-ui/core/Button" -import { makeStyles } from "@material-ui/core/styles" +import { makeStyles, useTheme } from "@material-ui/core/styles" +import useMediaQuery from "@material-ui/core/useMediaQuery" import KeyboardArrowLeft from "@material-ui/icons/KeyboardArrowLeft" import KeyboardArrowRight from "@material-ui/icons/KeyboardArrowRight" +import { ChooseOne, Cond } from "components/Conditionals/ChooseOne" +import { Maybe } from "components/Conditionals/Maybe" import { CSSProperties } from "react" export type PaginationWidgetProps = { @@ -74,6 +77,39 @@ export const buildPagedList = ( return range(1, numPages) } +interface PageButtonProps { + activePage: number + page: number + numPages: number + onPageClick?: (page: number) => void +} + +const PageButton = ({ + activePage, + page, + numPages, + onPageClick, +}: PageButtonProps): JSX.Element => { + const styles = useStyles() + return ( + + ) +} + export const PaginationWidget = ({ prevLabel, nextLabel, @@ -88,7 +124,8 @@ export const PaginationWidget = ({ const numPages = numRecords ? Math.ceil(numRecords / numRecordsPerPage) : 0 const firstPageActive = activePage === 1 && numPages !== 0 const lastPageActive = activePage === numPages && numPages !== 0 - + const theme = useTheme() + const isMobile = useMediaQuery(theme.breakpoints.down('sm')) const styles = useStyles() // No need to display any pagination if we know the number of pages is 1 @@ -107,30 +144,39 @@ export const PaginationWidget = ({
{prevLabel}
- {numPages > 0 && - buildPagedList(numPages, activePage).map((page) => - typeof page !== "number" ? ( - - ) : ( - - ), - )} + 0}> + + + + + + {buildPagedList(numPages, activePage).map((page) => + typeof page !== "number" ? ( + + ) : ( + + ), + )} + + +