Refactor
This commit is contained in:
@@ -1,28 +1,20 @@
|
||||
<script lang="ts">
|
||||
import {eventRepo} from "./repo/repo.ts";
|
||||
import {astroI18n} from "astro-i18n";
|
||||
import {window} from "./util.ts";
|
||||
import {astroI18n, t} from "astro-i18n";
|
||||
import type {ExtendedEvent} from "./types/event.ts";
|
||||
|
||||
export let event: ExtendedEvent;
|
||||
export let group: string;
|
||||
export let rows: number = 1;
|
||||
|
||||
function window<T>(arr: T[], len: number): T[][] {
|
||||
let result: T[][] = [];
|
||||
for (let i = 0; i < arr.length; i += len) {
|
||||
result.push(arr.slice(i, i + len));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<table>
|
||||
<tr class="font-bold border-b">
|
||||
{#each Array(rows) as _}
|
||||
<td>Time</td>
|
||||
<td>Blue Team</td>
|
||||
<td>Red Team</td>
|
||||
<td>{t("announcements.table.time")}</td>
|
||||
<td>{t("announcements.table.blue")}</td>
|
||||
<td>{t("announcements.table.red")}</td>
|
||||
{/each}
|
||||
</tr>
|
||||
{#each window(event.fights.filter(f => f.group === group), rows) as fights}
|
||||
|
||||
Reference in New Issue
Block a user