Skip to content

Commit 2182c1e

Browse files
committed
made improvements in pagination
1 parent 70dfa19 commit 2182c1e

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

client/src/components/Pagination/Pagination.jsx

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ export default function Pagination({ pageNo, setPageNo, totalPages }) {
1515
<div className="flex flex-1 items-center justify-center">
1616
<div>
1717
<nav className="isolate inline-flex -space-x-px rounded-md shadow-sm" aria-label="Pagination">
18-
<button onClick={() => {
19-
if (pageNo < 2) return;
20-
setPageNo((no) => no - 1)
21-
}} className="relative inline-flex items-center rounded-l-md px-2 py-2 text-gray-400 ring-1 ring-inset ring-gray-300 hover:bg-gray-800 focus:z-20 focus:outline-offset-0">
22-
<span className="sr-only">Previous</span>
23-
◀️
24-
</button>
18+
{
19+
pageNo > 1 && <button onClick={() => setPageNo((no) => no - 1)} className="ring-1 ring-inset ring-gray-300 relative inline-flex items-center rounded-l-md px-2 py-2 text-gray-400 bg-[#0e0e0e] hover:bg-[#292829] focus:z-20 focus:outline-offset-0">
20+
<span className="sr-only">Previous</span>
21+
{/* <ChevronLeftIcon className="h-5 w-5" aria-hidden="true" /> */}
22+
◀️
23+
</button>
24+
}
2525

2626
{
2727
Array.from({ length: totalPages }, (_, index) => index + 1).map((item) => {
@@ -30,22 +30,21 @@ export default function Pagination({ pageNo, setPageNo, totalPages }) {
3030
key={item}
3131
onClick={() => setPageNo(item)}
3232
aria-current={pageNo === item ? 'page' : undefined}
33-
className={`ring-1 ring-inset ring-gray-300 relative z-10 inline-flex items-center px-4 py-2 text-sm font-semibold hover:bg-gray-800 text-white focus:z-20 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 ${pageNo === item ? 'bg-gray-500 hover:bg-gray-500 ' : 'bg-transparent'}`}
33+
className={`ring-1 ring-inset ring-gray-300 relative z-10 inline-flex items-center px-4 py-2 text-sm font-semibold hover:bg-[#292829] text-white focus:z-20 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 ${pageNo === item ? 'bg-[#292829] hover:bg-[#292829] ' : 'bg-[#0e0e0e]'}`}
3434
>
3535
{item}
3636
</button>
3737
)
3838
})
3939
}
4040

41-
<button onClick={() => {
42-
if (pageNo > totalPages - 1) return;
43-
setPageNo((no) => no + 1)
44-
}} className="ring-1 ring-inset ring-gray-300 relative inline-flex items-center rounded-r-md px-2 py-2 text-gray-400 hover:bg-gray-800 focus:z-20 focus:outline-offset-0">
45-
<span className="sr-only">Next</span>
46-
{/* <ChevronRightIcon className="h-5 w-5" aria-hidden="true" /> */}
47-
▶️
48-
</button>
41+
{
42+
pageNo < totalPages && <button onClick={() => setPageNo((no) => no + 1)} className="ring-1 ring-inset ring-gray-300 relative inline-flex items-center rounded-r-md px-2 py-2 text-gray-400 bg-[#0e0e0e] hover:bg-[#292829] focus:z-20 focus:outline-offset-0">
43+
<span className="sr-only">Next</span>
44+
{/* <ChevronRightIcon className="h-5 w-5" aria-hidden="true" /> */}
45+
▶️
46+
</button>
47+
}
4948
</nav>
5049
</div>
5150
</div>

0 commit comments

Comments
 (0)