Skip to content

Commit 98a4e40

Browse files
samejrmatt-aitken
authored andcommitted
Improves the pagination styling
1 parent 15c6760 commit 98a4e40

File tree

1 file changed

+68
-25
lines changed

1 file changed

+68
-25
lines changed

apps/webapp/app/components/primitives/Pagination.tsx

Lines changed: 68 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,75 @@ export function PaginationControls({
1919
}
2020

2121
return (
22-
<nav className="flex items-center gap-0.5" aria-label="Pagination">
23-
<LinkButton
24-
to={pageUrl(location, currentPage - 1)}
25-
variant="secondary/small"
26-
LeadingIcon={ChevronLeftIcon}
27-
shortcut={{ key: "j" }}
28-
tooltip="Previous"
29-
disabled={currentPage === 1}
30-
className={currentPage > 1 ? "group" : ""}
31-
/>
32-
33-
{showPageNumbers
34-
? calculatePageLinks(currentPage, totalPages).map((page, i) => (
22+
<nav className="flex items-center gap-1" aria-label="Pagination">
23+
{showPageNumbers ? (
24+
<>
25+
<LinkButton
26+
to={pageUrl(location, currentPage - 1)}
27+
variant="secondary/small"
28+
LeadingIcon={ChevronLeftIcon}
29+
shortcut={{ key: "j" }}
30+
tooltip="Previous"
31+
disabled={currentPage === 1}
32+
className={cn("px-2", currentPage > 1 ? "group" : "")}
33+
/>
34+
35+
{calculatePageLinks(currentPage, totalPages).map((page, i) => (
3536
<PageLinkComponent page={page} key={i} location={location} />
36-
))
37-
: null}
38-
39-
<LinkButton
40-
to={pageUrl(location, currentPage + 1)}
41-
variant="secondary/small"
42-
TrailingIcon={ChevronRightIcon}
43-
shortcut={{ key: "k" }}
44-
tooltip="Next"
45-
disabled={currentPage === totalPages}
46-
className={currentPage !== totalPages ? "group" : ""}
47-
/>
37+
))}
38+
39+
<LinkButton
40+
to={pageUrl(location, currentPage + 1)}
41+
variant="secondary/small"
42+
TrailingIcon={ChevronRightIcon}
43+
shortcut={{ key: "k" }}
44+
tooltip="Next"
45+
disabled={currentPage === totalPages}
46+
className={cn("px-2", currentPage !== totalPages ? "group" : "")}
47+
/>
48+
</>
49+
) : (
50+
<div className="flex items-center">
51+
<div className={cn("peer/prev order-1", currentPage === 1 && "pointer-events-none")}>
52+
<LinkButton
53+
to={pageUrl(location, currentPage - 1)}
54+
variant="secondary/small"
55+
LeadingIcon={ChevronLeftIcon}
56+
shortcut={{ key: "j" }}
57+
tooltip="Previous"
58+
disabled={currentPage === 1}
59+
className={cn(
60+
"flex items-center rounded-r-none border-r-0 pl-2 pr-[0.5625rem]",
61+
currentPage === 1 && "cursor-not-allowed opacity-50"
62+
)}
63+
/>
64+
</div>
65+
66+
<div
67+
className={cn(
68+
"order-2 h-6 w-px bg-charcoal-600 transition-colors peer-hover/next:bg-charcoal-550 peer-hover/prev:bg-charcoal-550",
69+
currentPage === 1 && currentPage === totalPages && "opacity-30"
70+
)}
71+
/>
72+
73+
<div
74+
className={cn("peer/next order-3", currentPage === totalPages && "pointer-events-none")}
75+
>
76+
<LinkButton
77+
to={pageUrl(location, currentPage + 1)}
78+
variant="secondary/small"
79+
TrailingIcon={ChevronRightIcon}
80+
shortcut={{ key: "k" }}
81+
tooltip="Next"
82+
disabled={currentPage === totalPages}
83+
className={cn(
84+
"flex items-center rounded-l-none border-l-0 pl-[0.5625rem] pr-2",
85+
currentPage === totalPages && "cursor-not-allowed opacity-50"
86+
)}
87+
/>
88+
</div>
89+
</div>
90+
)}
4891
</nav>
4992
);
5093
}

0 commit comments

Comments
 (0)