sendou.ink/app/components/Pagination.tsx
Kalle fd48bced91
Migrate Prettier/Eslint/Stylelint setup to Biome (#1772)
* Initial

* CSS lint

* Test CI

* Add 1v1, 2v2, and 3v3 Tags (#1771)

* Initial

* CSS lint

* Test CI

* Rename step

---------

Co-authored-by: xi <104683822+ximk@users.noreply.github.com>
2024-06-24 13:07:17 +03:00

53 lines
1.2 KiB
TypeScript

import clsx from "clsx";
import { Button } from "~/components/Button";
import { ArrowLeftIcon } from "~/components/icons/ArrowLeft";
import { ArrowRightIcon } from "~/components/icons/ArrowRight";
import { nullFilledArray } from "~/utils/arrays";
export function Pagination({
currentPage,
pagesCount,
nextPage,
previousPage,
setPage,
}: {
currentPage: number;
pagesCount: number;
nextPage: () => void;
previousPage: () => void;
setPage: (page: number) => void;
}) {
return (
<div className="stack sm horizontal items-center justify-center flex-wrap">
<Button
icon={<ArrowLeftIcon />}
variant="outlined"
className="fix-rtl"
disabled={currentPage === 1}
onClick={previousPage}
aria-label="Previous page"
/>
{nullFilledArray(pagesCount).map((_, i) => (
<div
key={i}
className={clsx("pagination__dot", {
pagination__dot__active: i === currentPage - 1,
})}
onClick={() => setPage(i + 1)}
/>
))}
<div className="pagination__page-count">
{currentPage}/{pagesCount}
</div>
<Button
icon={<ArrowRightIcon />}
variant="outlined"
className="fix-rtl"
disabled={currentPage === pagesCount}
onClick={nextPage}
aria-label="Next page"
/>
</div>
);
}