Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 5x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 5x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 8x 8x 12x 10x 10x 12x 11x 11x 12x 8x 1x 1x 1x 1x 1x 1x 7x 7x 12x 12x 6x 6x 7x 1x 1x 48x 48x 48x 6x 6x 42x 42x 6x 6x 36x 36x 12x 12x 12x 12x 12x 12x 12x 2x 2x 2x 2x 2x 2x 2x 2x 2x 10x 10x 1x 1x 1x 7x 7x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 7x 12x 12x 12x 12x 12x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 12x 12x 12x 12x 1x 1x 1x 6x 5x 5x 5x 6x 1x 1x 1x 1x 1x 1x 12x 7x 21x 21x 7x 14x 9x 9x 9x 7x 1x 168x 168x 21x 21x 147x 147x | <template>
<div>
<!-- No matches -->
<div
v-if="bracketTeams.length === 0"
class="text-center py-10 text-fg-muted"
>
No group-stage matches in this bracket yet.
</div>
<template v-else>
<!-- Standings table -->
<div class="overflow-x-auto bg-card rounded-lg border border-line mb-6">
<table class="min-w-full text-xs sm:text-sm">
<thead class="bg-surface-alt text-fg-muted">
<tr>
<th class="px-1.5 sm:px-2 py-2 w-7 text-center font-semibold">
#
</th>
<th class="px-2 sm:px-3 py-2 text-left font-semibold">Team</th>
<th
v-for="col in STAT_COLS"
:key="col.key"
:class="[
'px-1.5 sm:px-2 py-2 text-center font-semibold w-9 sm:w-12',
col.mobileHidden ? 'hidden sm:table-cell' : '',
]"
>
{{ col.label }}
</th>
</tr>
</thead>
<tbody>
<tr
v-for="(row, idx) in standings"
:key="row.team.id"
:class="[
idx === 0 ? 'bg-brand-50/50' : 'hover:bg-surface-alt',
'border-t border-line',
]"
>
<td
class="px-1.5 sm:px-2 py-2 text-center text-fg-muted tabular-nums"
>
{{ idx + 1 }}
</td>
<td
:class="[
'px-2 sm:px-3 py-2',
idx === 0 ? 'font-semibold text-fg' : 'text-fg',
]"
>
<!-- Inner block truncates reliably; max-width on a <td> alone
is ignored in auto table layout. -->
<div
class="truncate max-w-[40vw] sm:max-w-[240px]"
:title="row.team.name"
>
{{ row.team.name }}
</div>
</td>
<td
v-for="col in STAT_COLS"
:key="col.key"
:class="[
'px-1.5 sm:px-2 py-2 text-center tabular-nums',
col.mobileHidden ? 'hidden sm:table-cell' : '',
col.key === 'pts' ? 'font-bold text-fg' : 'text-fg-muted',
]"
>
{{ formatStat(row, col.key) }}
</td>
</tr>
</tbody>
</table>
</div>
<!-- Head-to-head cross-table -->
<div>
<div class="flex items-baseline justify-between mb-2">
<h3
class="text-xs font-semibold text-fg-muted uppercase tracking-wider"
>
Head-to-head
</h3>
<span class="text-xs text-fg-muted sm:hidden">swipe →</span>
</div>
<div class="overflow-x-auto bg-card rounded-lg border border-line">
<table class="min-w-full text-xs sm:text-sm">
<thead class="bg-surface-alt text-fg-muted">
<tr>
<th
class="px-2 sm:px-3 py-2 text-left font-semibold sticky left-0 bg-surface-alt z-10 min-w-[104px] sm:min-w-[180px]"
></th>
<th
v-for="team in bracketTeams"
:key="`hdr-${team.id}`"
class="px-2 sm:px-3 py-2 text-center font-semibold min-w-[64px] sm:min-w-[110px]"
>
<span
class="block truncate max-w-[56px] sm:max-w-[96px] mx-auto"
:title="team.name"
>{{ team.name }}</span
>
</th>
</tr>
</thead>
<tbody>
<tr
v-for="rowTeam in bracketTeams"
:key="`row-${rowTeam.id}`"
class="border-t border-line"
>
<td
class="px-2 sm:px-3 py-2 font-medium text-fg sticky left-0 bg-card z-10"
>
<div
class="truncate max-w-[88px] sm:max-w-[164px]"
:title="rowTeam.name"
>
{{ rowTeam.name }}
</div>
</td>
<td
v-for="colTeam in bracketTeams"
:key="`cell-${rowTeam.id}-${colTeam.id}`"
:class="[
'px-2 sm:px-3 py-2 text-center tabular-nums',
rowTeam.id === colTeam.id
? 'bg-surface-alt text-fg-muted'
: 'text-fg-muted',
]"
>
<span v-if="rowTeam.id === colTeam.id">—</span>
<span v-else>{{ h2hCell(rowTeam.id, colTeam.id) }}</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</template>
</div>
</template>
<script setup>
import { computed } from 'vue';
const props = defineProps({
// Pre-filtered: only matches we want to include in the standings
// (age group + tournament_group + group_stage round, filter happens
// upstream so this component stays small and pure).
matches: { type: Array, required: true },
});
// Columns shown in the standings table, in order. `mobileHidden` columns
// (raw goals for/against) are dropped on phones so the essential MP / W / D /
// L / GD / PTS set fits without horizontal scrolling — GD still summarizes
// the goal difference. They reappear at the `sm` breakpoint.
const STAT_COLS = [
{ key: 'mp', label: 'MP' },
{ key: 'w', label: 'W' },
{ key: 'd', label: 'D' },
{ key: 'l', label: 'L' },
{ key: 'gf', label: 'GF', mobileHidden: true },
{ key: 'ga', label: 'GA', mobileHidden: true },
{ key: 'gd', label: 'GD' },
{ key: 'pts', label: 'PTS' },
];
// Unique teams that appear in this match set, sorted by name. Used as
// both the row and column axis of the head-to-head cross-table.
const bracketTeams = computed(() => {
const seen = new Map();
for (const m of props.matches) {
if (m.home_team && !seen.has(m.home_team.id)) {
seen.set(m.home_team.id, m.home_team);
}
if (m.away_team && !seen.has(m.away_team.id)) {
seen.set(m.away_team.id, m.away_team);
}
}
return [...seen.values()].sort((a, b) => a.name.localeCompare(b.name));
});
// One completed match (or null) keyed by `${rowId}_${colId}` so the
// cross-table can look it up in O(1) per cell. The row team is the
// "perspective" team — the cell shows the score from the row team's
// point of view (i.e. row-team-goals first).
const completedByPair = computed(() => {
const map = new Map();
for (const m of props.matches) {
if (m.match_status !== 'completed') continue;
if (m.home_score == null || m.away_score == null) continue;
map.set(`${m.home_team.id}_${m.away_team.id}`, m);
}
return map;
});
// Format a cross-table cell from the row team's perspective.
function h2hCell(rowId, colId) {
const homeMatch = completedByPair.value.get(`${rowId}_${colId}`);
if (homeMatch) {
return formatScore(homeMatch.home_score, homeMatch.away_score, homeMatch);
}
const awayMatch = completedByPair.value.get(`${colId}_${rowId}`);
if (awayMatch) {
return formatScore(awayMatch.away_score, awayMatch.home_score, awayMatch);
}
return '-';
}
function formatScore(forGoals, againstGoals, match) {
// Penalty-shootout suffix when present.
if (
match.home_penalty_score != null &&
match.away_penalty_score != null &&
forGoals === againstGoals
) {
const isHomePerspective = match.home_score === forGoals;
const pkFor = isHomePerspective
? match.home_penalty_score
: match.away_penalty_score;
const pkAgainst = isHomePerspective
? match.away_penalty_score
: match.home_penalty_score;
return `${forGoals}-${againstGoals} (${pkFor}-${pkAgainst} PK)`;
}
return `${forGoals}-${againstGoals}`;
}
// Per-team standings rows. PK shootout wins count as wins; PK goals are
// excluded from GF/GA (regulation only).
const standings = computed(() => {
const rows = new Map();
for (const team of bracketTeams.value) {
rows.set(team.id, {
team,
mp: 0,
w: 0,
d: 0,
l: 0,
gf: 0,
ga: 0,
gd: 0,
pts: 0,
});
}
for (const m of props.matches) {
if (m.match_status !== 'completed') continue;
if (m.home_score == null || m.away_score == null) continue;
const home = rows.get(m.home_team?.id);
const away = rows.get(m.away_team?.id);
if (!home || !away) continue;
home.mp += 1;
away.mp += 1;
home.gf += m.home_score;
home.ga += m.away_score;
away.gf += m.away_score;
away.ga += m.home_score;
let homeWin = m.home_score > m.away_score;
let awayWin = m.away_score > m.home_score;
if (
!homeWin &&
!awayWin &&
m.home_penalty_score != null &&
m.away_penalty_score != null
) {
homeWin = m.home_penalty_score > m.away_penalty_score;
awayWin = m.away_penalty_score > m.home_penalty_score;
}
if (homeWin) {
home.w += 1;
home.pts += 3;
away.l += 1;
} else if (awayWin) {
away.w += 1;
away.pts += 3;
home.l += 1;
} else {
home.d += 1;
away.d += 1;
home.pts += 1;
away.pts += 1;
}
}
for (const r of rows.values()) {
r.gd = r.gf - r.ga;
}
return [...rows.values()].sort((a, b) => {
if (b.pts !== a.pts) return b.pts - a.pts;
if (b.gd !== a.gd) return b.gd - a.gd;
if (b.gf !== a.gf) return b.gf - a.gf;
return a.team.name.localeCompare(b.team.name);
});
});
function formatStat(row, key) {
if (key === 'gd') {
return row.gd > 0 ? `+${row.gd}` : String(row.gd);
}
return row[key];
}
</script>
|