Skip to content

Commit 00c9f74

Browse files
committed
fix pagination
1 parent c68faf0 commit 00c9f74

File tree

3 files changed

+27
-20
lines changed

3 files changed

+27
-20
lines changed

site/src/components/PaginationWidget/PageButtons.tsx

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PropsWithChildren } from "react";
1+
import { type FC, type PropsWithChildren } from "react";
22
import Button from "@mui/material/Button";
33
import { useTheme } from "@emotion/react";
44

@@ -11,13 +11,13 @@ type NumberedPageButtonProps = {
1111
disabled?: boolean;
1212
};
1313

14-
export function NumberedPageButton({
14+
export const NumberedPageButton: FC<NumberedPageButtonProps> = ({
1515
pageNumber,
1616
totalPages,
1717
onClick,
1818
highlighted = false,
1919
disabled = false,
20-
}: NumberedPageButtonProps) {
20+
}) => {
2121
return (
2222
<BasePageButton
2323
name="Page button"
@@ -29,16 +29,16 @@ export function NumberedPageButton({
2929
{pageNumber}
3030
</BasePageButton>
3131
);
32-
}
32+
};
3333

3434
type PlaceholderPageButtonProps = PropsWithChildren<{
3535
pagesOmitted: number;
3636
}>;
3737

38-
export function PlaceholderPageButton({
38+
export const PlaceholderPageButton: FC<PlaceholderPageButtonProps> = ({
3939
pagesOmitted,
4040
children = <>&hellip;</>,
41-
}: PlaceholderPageButtonProps) {
41+
}) => {
4242
return (
4343
<BasePageButton
4444
disabled
@@ -48,7 +48,7 @@ export function PlaceholderPageButton({
4848
{children}
4949
</BasePageButton>
5050
);
51-
}
51+
};
5252

5353
type BasePageButtonProps = PropsWithChildren<{
5454
name: string;
@@ -59,22 +59,29 @@ type BasePageButtonProps = PropsWithChildren<{
5959
disabled?: boolean;
6060
}>;
6161

62-
function BasePageButton({
62+
const BasePageButton: FC<BasePageButtonProps> = ({
6363
children,
6464
onClick,
6565
name,
6666
"aria-label": ariaLabel,
6767
highlighted = false,
6868
disabled = false,
69-
}: BasePageButtonProps) {
69+
}) => {
7070
const theme = useTheme();
7171

7272
return (
7373
<Button
7474
css={
7575
highlighted && {
76-
borderColor: `${theme.palette.info.main}`,
77-
backgroundColor: `${theme.palette.info.dark}`,
76+
borderColor: theme.experimental.roles.active.outline,
77+
backgroundColor: theme.experimental.roles.active.background,
78+
79+
// Override the hover state with active colors, but not hover
80+
// colors because clicking won't do anything.
81+
"&:hover": {
82+
borderColor: theme.experimental.roles.active.outline,
83+
backgroundColor: theme.experimental.roles.active.background,
84+
},
7885
}
7986
}
8087
aria-label={ariaLabel}
@@ -85,7 +92,7 @@ function BasePageButton({
8592
{children}
8693
</Button>
8794
);
88-
}
95+
};
8996

9097
function getNumberedButtonLabel(
9198
page: number,

site/src/components/PaginationWidget/PaginationWidgetBase.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import useMediaQuery from "@mui/material/useMediaQuery";
22
import { useTheme } from "@emotion/react";
3-
3+
import { type FC } from "react";
44
import { PlaceholderPageButton, NumberedPageButton } from "./PageButtons";
55
import { buildPagedList } from "./utils";
66
import { PaginationNavButton } from "./PaginationNavButton";
@@ -17,14 +17,14 @@ export type PaginationWidgetBaseProps = {
1717
hasNextPage?: boolean;
1818
};
1919

20-
export const PaginationWidgetBase = ({
20+
export const PaginationWidgetBase: FC<PaginationWidgetBaseProps> = ({
2121
currentPage,
2222
pageSize,
2323
totalRecords,
2424
onPageChange,
2525
hasPreviousPage,
2626
hasNextPage,
27-
}: PaginationWidgetBaseProps) => {
27+
}) => {
2828
const theme = useTheme();
2929
const isMobile = useMediaQuery(theme.breakpoints.down("md"));
3030
const totalPages = Math.ceil(totalRecords / pageSize);
@@ -99,11 +99,11 @@ type PaginationRowProps = {
9999
onChange: (newPage: number) => void;
100100
};
101101

102-
function PaginationRow({
102+
const PaginationRow: FC<PaginationRowProps> = ({
103103
currentPage,
104104
totalPages,
105105
onChange,
106-
}: PaginationRowProps) {
106+
}) => {
107107
const pageInfo = buildPagedList(totalPages, currentPage);
108108
const pagesOmitted = totalPages - pageInfo.length - 1;
109109

@@ -131,4 +131,4 @@ function PaginationRow({
131131
})}
132132
</>
133133
);
134-
}
134+
};

site/src/theme/light/experimental.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ export default {
120120
text: colors.sky[200],
121121
},
122122
hover: {
123-
background: colors.sky[100],
124-
outline: colors.sky[500],
123+
background: colors.sky[200],
124+
outline: colors.sky[400],
125125
fill: colors.sky[500],
126126
text: colors.black,
127127
},

0 commit comments

Comments
 (0)