~james/core

core/web/src/lib/components/ui/RoutePagination.svelte -rw-r--r-- 669 bytes
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 16 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<script lang="ts">
	import { cn } from "tailwind-variants";
	import Pagination from "#lib/components/ui/Pagination.svelte";
	import Pending from "#lib/components/ui/Pending.svelte";
	import { gotoPage } from "#lib/pagination.svelte.ts";

	interface Props {
		page: number;
		pageCount: Promise<number> | number;
		labels?: boolean;
		class?: string;
	}

	let { page: currentPage, pageCount, labels, class: className }: Props = $props();
</script>

<Pending>
	{@const count = await pageCount}
	{#if count > 1}
		<div class={cn("flex justify-center", className)}>
			<Pagination page={currentPage} total={count} {labels} onchange={gotoPage} />
		</div>
	{/if}
</Pending>