feat: Add roundRows configuration to group view and update event markdowns
All checks were successful
SteamWarCI Build successful

This commit is contained in:
2026-01-01 16:23:13 +01:00
parent f507dce94a
commit fa7e68ca10
4 changed files with 40 additions and 15 deletions

View File

@@ -41,6 +41,20 @@
return rounds; return rounds;
} }
function chunkIntoRows<T>(items: T[], rowCount: number): T[][] {
if (!items || items.length === 0) return [];
const rows = Math.max(1, Math.floor(rowCount || 1));
const perRow = Math.ceil(items.length / rows);
const chunked: T[][] = [];
for (let i = 0; i < rows; i++) {
const slice = items.slice(i * perRow, (i + 1) * perRow);
if (slice.length) chunked.push(slice);
}
return chunked;
}
const hover = $teamHoverService; const hover = $teamHoverService;
</script> </script>
@@ -48,6 +62,8 @@
{@const group = event.groups.find((g) => g.id === groupId)!!} {@const group = event.groups.find((g) => g.id === groupId)!!}
{@const fights = event.fights.filter((f) => f.group?.id === groupId)} {@const fights = event.fights.filter((f) => f.group?.id === groupId)}
{@const rounds = detectRounds(fights)} {@const rounds = detectRounds(fights)}
{@const roundRows = config.roundRows ?? 1}
{@const roundRowsChunked = chunkIntoRows(rounds, roundRows)}
<div class="flex"> <div class="flex">
<div> <div>
<EventCard title={group.name}> <EventCard title={group.name}>
@@ -60,10 +76,14 @@
</EventCardOutline> </EventCardOutline>
</EventCard> </EventCard>
</div> </div>
{#each rounds as round, index} <div class="flex flex-col">
{#each roundRowsChunked as row}
<div class="flex">
{#each row as round, index (round)}
{@const roundIndex = rounds.indexOf(round)}
{@const teams = Array.from(new Set(round.flatMap((f) => [f.redTeam, f.blueTeam])))} {@const teams = Array.from(new Set(round.flatMap((f) => [f.redTeam, f.blueTeam])))}
<div class="{hover.currentHover && !teams.some((t) => t?.id === hover.currentHover) ? 'opacity-30' : ''} transition-opacity"> <div class="{hover.currentHover && !teams.some((t) => t?.id === hover.currentHover) ? 'opacity-30' : ''} transition-opacity">
<EventCard title="Runde {index + 1}"> <EventCard title="Runde {roundIndex + 1}">
{#each round as fight} {#each round as fight}
<EventFightChip {event} {fight} {group} /> <EventFightChip {event} {fight} {group} />
{/each} {/each}
@@ -72,3 +92,6 @@
{/each} {/each}
</div> </div>
{/each} {/each}
</div>
</div>
{/each}

View File

@@ -3,6 +3,7 @@ import { z } from "astro:content";
export const GroupViewSchema = z.object({ export const GroupViewSchema = z.object({
type: z.literal("GROUP"), type: z.literal("GROUP"),
groups: z.array(z.number()), groups: z.array(z.number()),
roundRows: z.number().int().positive().optional().default(1),
}); });
export type GroupViewConfig = z.infer<typeof GroupViewSchema>; export type GroupViewConfig = z.infer<typeof GroupViewSchema>;

View File

@@ -8,6 +8,7 @@ viewConfig:
view: view:
type: "GROUP" type: "GROUP"
groups: [13] groups: [13]
roundRows: 2
--- ---
**Ahoi, liebe Community,** **Ahoi, liebe Community,**