Fixes and Changes
This commit is contained in:
@@ -20,9 +20,7 @@
|
||||
<script lang="ts">
|
||||
import {t} from "astro-i18n";
|
||||
import {
|
||||
ChevronDoubleLeftOutline,
|
||||
ChevronDoubleRightOutline,
|
||||
ChevronLeftOutline, ChevronRightOutline,
|
||||
FolderOutline,
|
||||
HomeOutline,
|
||||
InfoCircleOutline
|
||||
@@ -35,6 +33,7 @@
|
||||
import UploadModal from "./UploadModal.svelte";
|
||||
import type {Player} from "@type/data.ts";
|
||||
import SWButton from "../styled/SWButton.svelte";
|
||||
import SWPaginator from "@components/styled/SWPaginator.svelte";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
@@ -53,24 +52,9 @@
|
||||
}
|
||||
|
||||
let page = 0;
|
||||
$: maxPage = Math.ceil(schematics.schematics.length / 10);
|
||||
$: pagedSchematics = schematics.schematics.slice(page * 10, (page + 1) * 10);
|
||||
$: maxPage = Math.ceil(schematics.schematics.length / 15);
|
||||
$: pagedSchematics = schematics.schematics.slice(page * 15, (page + 1) * 15);
|
||||
|
||||
$: pages = new Array(maxPage).fill(0)
|
||||
.map((_, i) => i + 1)
|
||||
.slice(Math.max(page - 2, 0) - Math.abs(Math.max(page + 3 - maxPage, 0)), Math.min(page + 3, maxPage) + Math.abs(Math.min(page - 2, 0)))
|
||||
.map(i => ({
|
||||
name: i.toString(),
|
||||
active: i === page + 1,
|
||||
i: i - 1
|
||||
}));
|
||||
|
||||
const previous = () => {
|
||||
page = Math.max(page - 1, 0);
|
||||
};
|
||||
const next = () => {
|
||||
page = Math.min(page + 1, maxPage - 1);
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class="flex justify-between">
|
||||
@@ -147,41 +131,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="w-full flex justify-center mt-4">
|
||||
<ul class="inline-flex">
|
||||
<li>
|
||||
<button on:click={() => page = 0} class="btn btn-neutral h-8 px-3 text-sm flex items-center !m-0 !rounded-r-none">
|
||||
<span class="sr-only">Next</span>
|
||||
<ChevronDoubleLeftOutline class="w-3 h-3" />
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button on:click={previous} class="btn btn-neutral h-8 px-3 text-sm flex items-center !m-0 !rounded-none">
|
||||
<span class="sr-only">Previous</span>
|
||||
<ChevronLeftOutline class="w-3 h-3" />
|
||||
</button>
|
||||
</li>
|
||||
{#each pages as p}
|
||||
<li>
|
||||
<button on:click={() => page = p.i} class="btn h-8 px-3 text-sm flex items-center !m-0 !rounded-none" class:btn-neutral={!p.active}>
|
||||
<span>{p.name}</span>
|
||||
</button>
|
||||
</li>
|
||||
{/each}
|
||||
<li>
|
||||
<button on:click={next} class="btn btn-neutral h-8 px-3 text-sm flex items-center !m-0 !rounded-none">
|
||||
<span class="sr-only">Next</span>
|
||||
<ChevronRightOutline class="w-3 h-3" />
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button on:click={() => page = maxPage - 1} class="btn btn-neutral h-8 px-3 text-sm flex items-center !m-0 !rounded-l-none">
|
||||
<span class="sr-only">Next</span>
|
||||
<ChevronDoubleRightOutline class="w-3 h-3" />
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<SWPaginator bind:page maxPage={maxPage} />
|
||||
|
||||
<UploadModal bind:open={uploadOpen} on:refresh />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user