mirror of
https://github.com/jcreek/LivingDexTracker.git
synced 2026-07-13 19:13:43 +00:00
feat(*): Add pagination to my dex
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<script lang="ts">
|
||||
export let currentPage: number;
|
||||
export let itemsPerPage: number;
|
||||
export let totalPages: number;
|
||||
|
||||
function nextPage() {
|
||||
currentPage = Math.min(currentPage + 1, totalPages);
|
||||
}
|
||||
|
||||
function previousPage() {
|
||||
currentPage = Math.max(currentPage - 1, 1);
|
||||
}
|
||||
|
||||
function setItemsPerPage(event: any) {
|
||||
itemsPerPage = parseInt(event.target.value, 10);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<button on:click={previousPage} disabled={currentPage === 1}>Previous</button>
|
||||
<button on:click={nextPage} disabled={currentPage === totalPages}>Next</button>
|
||||
|
||||
<label for="itemsPerPage">Items per page:</label>
|
||||
<select id="itemsPerPage" on:change={setItemsPerPage}>
|
||||
<option value="20">20</option>
|
||||
<option value="50">50</option>
|
||||
<option value="100">100</option>
|
||||
</select>
|
||||
</div>
|
||||
Reference in New Issue
Block a user