mango-ui-v3/components/Pagination.tsx

72 lines
2.0 KiB
TypeScript
Raw Normal View History

import {
ChevronDoubleLeftIcon,
ChevronDoubleRightIcon,
ChevronLeftIcon,
ChevronRightIcon,
} from '@heroicons/react/solid'
export default function Pagination({
page,
totalPages,
firstPage,
lastPage,
nextPage,
previousPage,
}) {
return (
<div className="flex mt-4 items-center justify-end">
<div className="flex justify-center">
<button
onClick={firstPage}
disabled={page === 1}
2021-11-11 16:05:22 -08:00
className={`bg-th-bkg-4 px-1 py-1 ${
page !== 1
? 'hover:text-th-primary hover:cursor-pointer'
: 'hover:cursor-not-allowed'
2021-11-11 16:05:22 -08:00
} disabled:text-th-fgd-4`}
>
<ChevronDoubleLeftIcon className={`w-5 h-5`} />
</button>
<button
onClick={previousPage}
disabled={page === 1}
2021-11-11 16:05:22 -08:00
className={`bg-th-bkg-4 px-1 py-1 ml-2 ${
page !== 1
? 'hover:text-th-primary hover:cursor-pointer'
: 'hover:cursor-not-allowed'
2021-11-11 16:05:22 -08:00
} disabled:text-th-fgd-4`}
>
<ChevronLeftIcon className={`w-5 h-5`} />
</button>
</div>
<div className="ml-2">
{page} / {totalPages}
</div>
<div className="flex justify-center">
<button
onClick={nextPage}
disabled={page === totalPages}
2021-11-11 16:05:22 -08:00
className={`px-1 py-1 bg-th-bkg-4 ml-2 ${
page !== totalPages
? 'hover:text-th-primary hover:cursor-pointer'
: 'hover:cursor-not-allowed'
2021-11-11 16:05:22 -08:00
} disabled:text-th-fgd-4`}
>
<ChevronRightIcon className={`w-5 h-5`} />
</button>
<button
onClick={lastPage}
disabled={page === totalPages}
2021-11-11 16:05:22 -08:00
className={`px-1 py-1 bg-th-bkg-4 ml-2 ${
page !== totalPages
? 'hover:text-th-primary hover:cursor-pointer'
: 'hover:cursor-not-allowed'
2021-11-11 16:05:22 -08:00
} disabled:text-th-fgd-4`}
>
<ChevronDoubleRightIcon className={`w-5 h-5`} />
</button>
</div>
</div>
)
}