-
Notifications
You must be signed in to change notification settings - Fork 0
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
3 changed files
with
25 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,34 @@ | ||
<script lang="ts"> | ||
import { createEventDispatcher } from "svelte"; | ||
import Button from "$lib/components/generics/Button.svelte"; | ||
import Flex from "$lib/components/generics/layout/flex.svelte"; | ||
import FormInput from "../inputs/FormInput.svelte"; | ||
export let itemsPerPage: number; | ||
export let totalPages: number; | ||
export let currentPage: number; | ||
const dispatch = createEventDispatcher<{ change: number }>(); | ||
</script> | ||
|
||
{#if totalPages > 1} | ||
<Flex class="mt-6" items="center"> | ||
<span>Pages</span> | ||
<Flex class="mt-6 {$$props.class}" items="center"> | ||
{#each [...Array(totalPages).keys()] as number} | ||
{@const roleMinus = (currentPage <= 0) ? number + 1 === 1 : number + 1 === currentPage} | ||
{@const rolePlus = (currentPage > totalPages) ? number + 1 === totalPages : number + 1 === currentPage} | ||
<Button | ||
class="aspect-square w-8" | ||
size="tiny" | ||
role={(roleMinus || rolePlus) ? "primary" : "tertiary"} | ||
on:click={() => { currentPage = (number+1); dispatch("change", currentPage); }} | ||
on:click={() => currentPage = (number+1) } | ||
>{number + 1}</Button> | ||
{/each} | ||
|
||
<span class="ml-2">Éléments par page</span> | ||
|
||
<FormInput type="select" name="page-items-count" bind:value={itemsPerPage}> | ||
<option value={50}>50</option> | ||
<option value={100}>100</option> | ||
<option value={200}>200</option> | ||
<option value={500}>500</option> | ||
</FormInput> | ||
</Flex> | ||
{/if} |
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