File tree Expand file tree Collapse file tree 2 files changed +38
-23
lines changed
Expand file tree Collapse file tree 2 files changed +38
-23
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ interface PaginationButtonProps {
99 children : React . ReactNode ;
1010 active ?: boolean ;
1111 onClick ?: ( ) => void ;
12+ disabled ?: boolean ;
1213}
1314
1415export default function PaginationButton ( {
@@ -17,16 +18,18 @@ export default function PaginationButton({
1718 children,
1819 active,
1920 onClick,
21+ disabled,
2022} : PaginationButtonProps ) {
2123 const buttonContent = (
2224 < Button
2325 aria-label = { typeof children === "string" ? children : undefined }
2426 className = { cn (
25- "flex items-center gap-2 border-black border-" ,
26- active && "bg-white text-black " ,
27+ "flex items-center gap-2 border-black border-2 " ,
28+ active && "bg-white text-black cursor-default hover:bg-white " ,
2729 ) }
2830 size = "sm"
2931 onClick = { onClick }
32+ disabled = { disabled }
3033 >
3134 { arrow === "left" && (
3235 < ChevronLeft style = { { width : "10px" , height : "10px" } } />
@@ -38,7 +41,7 @@ export default function PaginationButton({
3841 </ Button >
3942 ) ;
4043
41- if ( href ) {
44+ if ( href && ! active && ! disabled ) {
4245 return (
4346 < Link href = { href } prefetch = { true } >
4447 { buttonContent }
Original file line number Diff line number Diff line change @@ -69,33 +69,45 @@ export default function Pagination({
6969 return (
7070 < div className = "flex flex-col sm:flex-row gap-4 items-center justify-between w-full mt-4" >
7171 < div className = "flex items-center justify-start gap-2" >
72- { pageNumber > 1 && (
73- < >
74- < PaginationButton href = { getPageHref ( 1 ) } arrow = "left" >
75- First
76- </ PaginationButton >
77- < PaginationButton href = { getPageHref ( pageNumber - 1 ) } arrow = "left" >
78- Previous
79- </ PaginationButton >
80- </ >
81- ) }
72+ < >
73+ < PaginationButton
74+ disabled = { pageNumber === 1 }
75+ href = { getPageHref ( 1 ) }
76+ arrow = "left"
77+ >
78+ First
79+ </ PaginationButton >
80+ < PaginationButton
81+ disabled = { pageNumber === 1 }
82+ href = { getPageHref ( pageNumber - 1 ) }
83+ arrow = "left"
84+ >
85+ Previous
86+ </ PaginationButton >
87+ </ >
8288 </ div >
8389
8490 < div className = "flex items-center justify-center gap-2" >
8591 { renderPageNumbers ( ) }
8692 </ div >
8793
8894 < div className = "flex items-center justify-end gap-2" >
89- { pageNumber < totalPages && (
90- < >
91- < PaginationButton href = { getPageHref ( pageNumber + 1 ) } arrow = "right" >
92- Next
93- </ PaginationButton >
94- < PaginationButton href = { getPageHref ( totalPages ) } arrow = "right" >
95- Last
96- </ PaginationButton >
97- </ >
98- ) }
95+ < >
96+ < PaginationButton
97+ disabled = { pageNumber === totalPages }
98+ href = { getPageHref ( pageNumber + 1 ) }
99+ arrow = "right"
100+ >
101+ Next
102+ </ PaginationButton >
103+ < PaginationButton
104+ disabled = { pageNumber === totalPages }
105+ href = { getPageHref ( totalPages ) }
106+ arrow = "right"
107+ >
108+ Last
109+ </ PaginationButton >
110+ </ >
99111 </ div >
100112 </ div >
101113 ) ;
You can’t perform that action at this time.
0 commit comments