2023-02-10 00:25:21 +00:00
|
|
|
<script lang="ts">
|
2024-05-15 00:33:39 +00:00
|
|
|
import { goto } from '$app/navigation';
|
|
|
|
|
import { Pagination } from "bits-ui";
|
|
|
|
|
import { ChevronLeft, ChevronRight } from 'lucide-svelte';
|
|
|
|
|
|
2023-02-10 00:25:21 +00:00
|
|
|
export let additionalClasses: string;
|
|
|
|
|
export let pageSize: number;
|
|
|
|
|
export let totalCount: number;
|
|
|
|
|
export let currentPage: number;
|
|
|
|
|
export let base: string;
|
|
|
|
|
</script>
|
|
|
|
|
|
2024-05-15 00:33:39 +00:00
|
|
|
<Pagination.Root let:pages count={totalCount} perPage={pageSize} page={currentPage || 1} class={`${additionalClasses}`}
|
|
|
|
|
onPageChange={(page) => goto(`${base}/${page}`)}>
|
|
|
|
|
<Pagination.PrevButton>
|
|
|
|
|
<ChevronLeft />
|
|
|
|
|
</Pagination.PrevButton>
|
|
|
|
|
{#each pages as page (page.key)}
|
|
|
|
|
{#if page.type === "ellipsis"}
|
2024-05-30 19:03:03 +00:00
|
|
|
<div class="ellipsis text-[15px] font-medium text-foreground-alt">...</div>
|
2024-05-15 00:33:39 +00:00
|
|
|
{:else}
|
|
|
|
|
<Pagination.Page {page}>
|
|
|
|
|
<a href={`${base}/${page.value}`}>
|
|
|
|
|
{page.value}
|
|
|
|
|
</a>
|
|
|
|
|
</Pagination.Page>
|
|
|
|
|
{/if}
|
2023-02-10 00:25:21 +00:00
|
|
|
{/each}
|
2024-05-15 00:33:39 +00:00
|
|
|
<Pagination.NextButton>
|
|
|
|
|
<ChevronRight />
|
|
|
|
|
</Pagination.NextButton>
|
|
|
|
|
</Pagination.Root>
|
2023-02-10 00:25:21 +00:00
|
|
|
|
|
|
|
|
<style lang="postcss">
|
2024-05-15 00:33:39 +00:00
|
|
|
:global([data-pagination-prev-button]) {
|
|
|
|
|
&:hover {
|
|
|
|
|
color: var(--shellYellow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&:active {
|
|
|
|
|
transform: scale(0.98); /* Equivalent to active:scale-98 in Tailwind */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&:disabled {
|
|
|
|
|
cursor: not-allowed; /* Equivalent to disabled:cursor-not-allowed in Tailwind */
|
|
|
|
|
color: #6b7280; /* Equivalent to disabled:text-muted-foreground in Tailwind */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&:hover:disabled {
|
|
|
|
|
background-color: transparent; /* Equivalent to hover:disabled:bg-transparent in Tailwind */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
border-right: 1px solid var(--grey);
|
|
|
|
|
padding: 1rem;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-30 19:03:03 +00:00
|
|
|
:global(.ellipsis) {
|
|
|
|
|
padding: 1rem;
|
|
|
|
|
border-right: 1px solid var(--grey);
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-15 00:33:39 +00:00
|
|
|
:global([data-pagination-next-button]) {
|
|
|
|
|
&:hover {
|
|
|
|
|
color: var(--shellYellow);
|
2023-02-10 00:25:21 +00:00
|
|
|
}
|
|
|
|
|
|
2024-05-15 00:33:39 +00:00
|
|
|
&:active {
|
|
|
|
|
transform: scale(0.98); /* Equivalent to active:scale-98 in Tailwind */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&:disabled {
|
|
|
|
|
cursor: not-allowed; /* Equivalent to disabled:cursor-not-allowed in Tailwind */
|
|
|
|
|
color: #6b7280; /* Equivalent to disabled:text-muted-foreground in Tailwind */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&:hover:disabled {
|
|
|
|
|
background-color: transparent; /* Equivalent to hover:disabled:bg-transparent in Tailwind */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
:global([data-selected]) {
|
|
|
|
|
a {
|
|
|
|
|
color: var(--shellYellow);
|
2023-02-10 00:25:21 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-15 00:33:39 +00:00
|
|
|
:global([data-pagination-root]) {
|
2023-02-10 00:25:21 +00:00
|
|
|
display: flex;
|
|
|
|
|
align-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-items: center;
|
|
|
|
|
border: 1px solid var(--grey);
|
|
|
|
|
margin: 3rem 0;
|
|
|
|
|
border-radius: 5px;
|
|
|
|
|
text-align: center;
|
|
|
|
|
font-size: 1.5rem;
|
|
|
|
|
}
|
2024-05-15 00:33:39 +00:00
|
|
|
|
|
|
|
|
:global([data-pagination-page]) {
|
|
|
|
|
padding: 1rem;
|
|
|
|
|
flex: 1;
|
|
|
|
|
border-right: 1px solid var(--grey);
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
|
|
|
|
|
a {
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-10 00:25:21 +00:00
|
|
|
</style>
|