-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
80 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
frontend/svelte-kit/src/lib/components/shared/pagination.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<script lang="ts"> | ||
import { page } from '$app/stores'; | ||
export let currentPage: number; | ||
export let totalPages: number; | ||
export let size: number; | ||
</script> | ||
|
||
<div class="join"> | ||
{#if currentPage > 1} | ||
<a | ||
class="btn btn-primary join-item" | ||
href="{$page.url.pathname}?page={currentPage - 1}&size={size}" | ||
> | ||
Previous | ||
</a> | ||
{/if} | ||
{#each [2, 1] as i} | ||
{#if currentPage - i > 0} | ||
<a | ||
class="btn btn-primary join-item" | ||
href="{$page.url.pathname}?page={currentPage - i}&size={size}" | ||
> | ||
{currentPage - i} | ||
</a> | ||
{/if} | ||
{/each} | ||
<span class="btn btn-primary join-item btn-active">{currentPage}</span> | ||
{#each Array(2) as _, i} | ||
{#if currentPage + (i + 1) <= totalPages} | ||
<a | ||
class="btn btn-primary join-item" | ||
href="{$page.url.pathname}?page={currentPage + (i + 1)}&size={size}" | ||
> | ||
{currentPage + (i + 1)} | ||
</a> | ||
{/if} | ||
{/each} | ||
{#if currentPage < totalPages} | ||
<a | ||
class="btn btn-primary join-item" | ||
href="{$page.url.pathname}?page={currentPage + 1}&size={size}">Next</a | ||
> | ||
{/if} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface Pageable<T> { | ||
data: T[]; | ||
total: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters