forked from forthfate/openorbit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpagination.tsx
More file actions
21 lines (20 loc) · 792 Bytes
/
Copy pathpagination.tsx
File metadata and controls
21 lines (20 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { locales, type Locale } from "../../locales";
export function Pagination({
locale,
page,
totalPages,
totalItems,
pageSize,
onPageChange,
}: {
locale: Locale;
page: number;
totalPages: number;
totalItems: number;
pageSize: number;
onPageChange: (page: number) => void;
}) {
const range = totalItems ? `${(page - 1) * pageSize + 1}–${Math.min(page * pageSize, totalItems)} / ${totalItems}` : "0";
const ui = locales[locale].ui;
return <div className="run-pagination"><span>{range}</span><div><button className="ghost" disabled={page===1} onClick={()=>onPageChange(page-1)}>{ui.previous}</button><span>{page} / {totalPages}</span><button className="ghost" disabled={page===totalPages} onClick={()=>onPageChange(page+1)}>{ui.next}</button></div></div>;
}