Knockout Wheel
KnockoutWheel.vue- Spain v Argentina · 2–1
- Spain v Brazil · 2–1
- France v Argentina · 0–0 (3–4 pens)
- Spain v Portugal · 1–0
- England v Brazil · 2–3
- France v Italy · 2–1
- Argentina v Germany · 3–1
- Spain v Japan · 2–0
- Netherlands v Portugal · 1–3
- England v Uruguay · 2–1
- Croatia v Brazil · 0–1
- France v Morocco · 3–1
- Belgium v Italy · 1–2
- Argentina v Mexico · 2–0
- Germany v Norway · 1–1 (4–2 pens)
- Spain v Costa Rica · 3–0
- Japan v Serbia · 2–1
- Netherlands v Ecuador · 2–0
- Ghana v Portugal · 2–3
- England v Wales · 4–0
- Canada v Uruguay · 0–2
- Croatia v Denmark · 1–0
- Brazil v Cameroon · 3–1
- France v Poland · 2–1
- Senegal v Morocco · 0–1
- Belgium v Tunisia · 2–0
- Switzerland v Italy · 1–3
- Argentina v Peru · 2–0
- Qatar v Mexico · 0–1
- Germany v Sweden · 4–2
- Austria v Norway · 1–2
<script setup lang="ts">
import { KnockoutWheel } from 'beui-vue'
import { } from 'vue'
// Sample draws from the upstream previews (a World Cup-style 32-team cup), shared by the knockout bracket and wheel demos.
import type { TournamentMatch, TournamentRound, TournamentTeam } from 'beui-vue'
const BRACKET_TEAMS = {
southAfrica: { name: "South Africa", code: "za" },
canada: { name: "Canada", code: "ca" },
netherlands: { name: "Netherlands", code: "nl" },
morocco: { name: "Morocco", code: "ma" },
germany: { name: "Germany", code: "de" },
paraguay: { name: "Paraguay", code: "py" },
france: { name: "France", code: "fr" },
sweden: { name: "Sweden", code: "se" },
belgium: { name: "Belgium", code: "be" },
senegal: { name: "Senegal", code: "sn" },
usa: { name: "USA", code: "us" },
bosnia: { name: "Bosnia and Herzegovina", code: "ba" },
spain: { name: "Spain", code: "es" },
austria: { name: "Austria", code: "at" },
portugal: { name: "Portugal", code: "pt" },
croatia: { name: "Croatia", code: "hr" },
brazil: { name: "Brazil", code: "br" },
japan: { name: "Japan", code: "jp" },
ivoryCoast: { name: "Côte d'Ivoire", code: "ci" },
norway: { name: "Norway", code: "no" },
mexico: { name: "Mexico", code: "mx" },
ecuador: { name: "Ecuador", code: "ec" },
england: { name: "England", code: "gb-eng" },
drCongo: { name: "DR Congo", code: "cd" },
switzerland: { name: "Switzerland", code: "ch" },
algeria: { name: "Algeria", code: "dz" },
colombia: { name: "Colombia", code: "co" },
ghana: { name: "Ghana", code: "gh" },
australia: { name: "Australia", code: "au" },
egypt: { name: "Egypt", code: "eg" },
argentina: { name: "Argentina", code: "ar" },
caboVerde: { name: "Cabo Verde", code: "cv" },
} satisfies Record<string, TournamentTeam>;
export const BRACKET_ROUNDS: TournamentRound[] = [
{
name: "Round of 32",
matches: [
{
id: "r32-1",
date: "Mon, 29 Jun",
status: "finished",
home: { team: BRACKET_TEAMS.southAfrica, score: 0 },
away: { team: BRACKET_TEAMS.canada, score: 1 },
winner: "away",
},
{
id: "r32-2",
date: "Tue, 30 Jun",
status: "finished",
home: { team: BRACKET_TEAMS.netherlands, score: 1, penalties: 2 },
away: { team: BRACKET_TEAMS.morocco, score: 1, penalties: 3 },
winner: "away",
},
{
id: "r32-3",
date: "Tue, 30 Jun",
status: "finished",
home: { team: BRACKET_TEAMS.germany, score: 1, penalties: 3 },
away: { team: BRACKET_TEAMS.paraguay, score: 1, penalties: 4 },
winner: "away",
},
{
id: "r32-4",
date: "Wed, 1 Jul",
status: "finished",
home: { team: BRACKET_TEAMS.france, score: 3 },
away: { team: BRACKET_TEAMS.sweden, score: 0 },
winner: "home",
},
{
id: "r32-5",
date: "Thu, 2 Jul",
status: "finished",
home: { team: BRACKET_TEAMS.belgium, score: 3 },
away: { team: BRACKET_TEAMS.senegal, score: 2 },
winner: "home",
},
{
id: "r32-6",
date: "Thu, 2 Jul",
status: "finished",
home: { team: BRACKET_TEAMS.usa, score: 2 },
away: { team: BRACKET_TEAMS.bosnia, score: 0 },
winner: "home",
},
{
id: "r32-7",
date: "Fri, 3 Jul",
status: "finished",
home: { team: BRACKET_TEAMS.spain, score: 3 },
away: { team: BRACKET_TEAMS.austria, score: 0 },
winner: "home",
},
{
id: "r32-8",
date: "Fri, 3 Jul",
status: "finished",
home: { team: BRACKET_TEAMS.portugal, score: 2 },
away: { team: BRACKET_TEAMS.croatia, score: 1 },
winner: "home",
},
{
id: "r32-9",
date: "Mon, 29 Jun",
status: "finished",
home: { team: BRACKET_TEAMS.brazil, score: 2 },
away: { team: BRACKET_TEAMS.japan, score: 1 },
winner: "home",
},
{
id: "r32-10",
date: "Tue, 30 Jun",
status: "finished",
home: { team: BRACKET_TEAMS.ivoryCoast, score: 1 },
away: { team: BRACKET_TEAMS.norway, score: 2 },
winner: "away",
},
{
id: "r32-11",
date: "Wed, 1 Jul",
status: "finished",
home: { team: BRACKET_TEAMS.mexico, score: 2 },
away: { team: BRACKET_TEAMS.ecuador, score: 0 },
winner: "home",
},
{
id: "r32-12",
date: "Wed, 1 Jul",
status: "finished",
home: { team: BRACKET_TEAMS.england, score: 2 },
away: { team: BRACKET_TEAMS.drCongo, score: 1 },
winner: "home",
},
{
id: "r32-13",
date: "Fri, 3 Jul",
status: "finished",
home: { team: BRACKET_TEAMS.switzerland, score: 2 },
away: { team: BRACKET_TEAMS.algeria, score: 0 },
winner: "home",
},
{
id: "r32-14",
date: "Sat, 4 Jul",
status: "finished",
home: { team: BRACKET_TEAMS.colombia, score: 1 },
away: { team: BRACKET_TEAMS.ghana, score: 0 },
winner: "home",
},
{
id: "r32-15",
date: "Fri, 3 Jul",
status: "finished",
home: { team: BRACKET_TEAMS.australia, score: 1, penalties: 2 },
away: { team: BRACKET_TEAMS.egypt, score: 1, penalties: 4 },
winner: "away",
},
{
id: "r32-16",
date: "Sat, 4 Jul",
status: "finished",
home: { team: BRACKET_TEAMS.argentina, score: 3 },
away: { team: BRACKET_TEAMS.caboVerde, score: 2 },
winner: "home",
},
],
},
{
name: "Round of 16",
matches: [
{
id: "r16-1",
date: "Sat, 4 Jul",
status: "finished",
home: { team: BRACKET_TEAMS.canada, score: 0 },
away: { team: BRACKET_TEAMS.morocco, score: 3 },
winner: "away",
},
{
id: "r16-2",
date: "Sun, 5 Jul",
status: "finished",
home: { team: BRACKET_TEAMS.paraguay, score: 0 },
away: { team: BRACKET_TEAMS.france, score: 1 },
winner: "away",
},
{
id: "r16-3",
date: "Mon, 6 Jul",
status: "finished",
home: { team: BRACKET_TEAMS.usa, score: 1 },
away: { team: BRACKET_TEAMS.belgium, score: 4 },
winner: "away",
},
{
id: "r16-4",
date: "Mon, 6 Jul",
status: "finished",
home: { team: BRACKET_TEAMS.portugal, score: 0 },
away: { team: BRACKET_TEAMS.spain, score: 1 },
winner: "away",
},
{
id: "r16-5",
date: "Mon, 6 Jul",
status: "finished",
home: { team: BRACKET_TEAMS.brazil, score: 1 },
away: { team: BRACKET_TEAMS.norway, score: 2 },
winner: "away",
},
{
id: "r16-6",
date: "Mon, 6 Jul",
status: "finished",
home: { team: BRACKET_TEAMS.mexico, score: 2 },
away: { team: BRACKET_TEAMS.england, score: 3 },
winner: "away",
},
{
id: "r16-7",
date: "Tue, 7 Jul",
status: "finished",
home: { team: BRACKET_TEAMS.switzerland, score: 0, penalties: 4 },
away: { team: BRACKET_TEAMS.colombia, score: 0, penalties: 3 },
winner: "home",
},
{
id: "r16-8",
date: "Tue, 7 Jul",
status: "finished",
home: { team: BRACKET_TEAMS.argentina, score: 3 },
away: { team: BRACKET_TEAMS.egypt, score: 2 },
winner: "home",
},
],
},
{
name: "Quarter-finals",
matches: [
{
id: "qf-1",
date: "Fri, 10 Jul",
time: "4:00 am",
status: "finished",
home: { team: BRACKET_TEAMS.france, score: 2 },
away: { team: BRACKET_TEAMS.morocco, score: 0 },
winner: "home",
},
{
id: "qf-2",
date: "Sat, 11 Jul",
time: "3:00 am",
status: "finished",
home: { team: BRACKET_TEAMS.spain, score: 2 },
away: { team: BRACKET_TEAMS.belgium, score: 1 },
winner: "home",
},
{
id: "qf-3",
date: "Today",
status: "finished",
home: { team: BRACKET_TEAMS.norway, score: 1 },
away: { team: BRACKET_TEAMS.england, score: 2 },
winner: "away",
},
{
id: "qf-4",
date: "Today",
status: "finished",
home: { team: BRACKET_TEAMS.argentina, score: 3 },
away: { team: BRACKET_TEAMS.switzerland, score: 1 },
winner: "home",
},
],
},
{
name: "Semi-finals",
matches: [
{
id: "sf-1",
date: "Wed, 15 Jul",
time: "4:00 am",
status: "upcoming",
home: { team: BRACKET_TEAMS.france, score: null },
away: { team: BRACKET_TEAMS.spain, score: null },
},
{
id: "sf-2",
date: "Thu, 16 Jul",
time: "3:00 am",
status: "upcoming",
home: { team: BRACKET_TEAMS.england, score: null },
away: { team: BRACKET_TEAMS.argentina, score: null },
},
],
},
{
name: "Final",
matches: [
{
id: "f-1",
date: "Mon, 20 Jul",
time: "3:00 am",
status: "upcoming",
home: { team: null, score: null },
away: { team: null, score: null },
},
],
},
];
export const THIRD_PLACE: TournamentMatch = {
id: "tp-1",
date: "Sun, 19 Jul",
time: "3:00 am",
status: "upcoming",
home: { team: null, score: null },
away: { team: null, score: null },
};
const WHEEL_TEAMS = {
spain: { name: "Spain", code: "es" },
japan: { name: "Japan", code: "jp" },
netherlands: { name: "Netherlands", code: "nl" },
portugal: { name: "Portugal", code: "pt" },
england: { name: "England", code: "gb-eng" },
uruguay: { name: "Uruguay", code: "uy" },
croatia: { name: "Croatia", code: "hr" },
brazil: { name: "Brazil", code: "br" },
france: { name: "France", code: "fr" },
morocco: { name: "Morocco", code: "ma" },
belgium: { name: "Belgium", code: "be" },
italy: { name: "Italy", code: "it" },
argentina: { name: "Argentina", code: "ar" },
mexico: { name: "Mexico", code: "mx" },
germany: { name: "Germany", code: "de" },
norway: { name: "Norway", code: "no" },
costaRica: { name: "Costa Rica", code: "cr" },
serbia: { name: "Serbia", code: "rs" },
ecuador: { name: "Ecuador", code: "ec" },
ghana: { name: "Ghana", code: "gh" },
wales: { name: "Wales", code: "gb-wls" },
canada: { name: "Canada", code: "ca" },
denmark: { name: "Denmark", code: "dk" },
cameroon: { name: "Cameroon", code: "cm" },
poland: { name: "Poland", code: "pl" },
senegal: { name: "Senegal", code: "sn" },
tunisia: { name: "Tunisia", code: "tn" },
switzerland: { name: "Switzerland", code: "ch" },
peru: { name: "Peru", code: "pe" },
qatar: { name: "Qatar", code: "qa" },
sweden: { name: "Sweden", code: "se" },
austria: { name: "Austria", code: "at" },
} satisfies Record<string, TournamentTeam>;
export const WHEEL_ROUNDS: TournamentRound[] = [
{
name: "Round of 32",
matches: [
{
id: "w-r32-1",
home: { team: WHEEL_TEAMS.spain, score: 3 },
away: { team: WHEEL_TEAMS.costaRica, score: 0 },
winner: "home",
},
{
id: "w-r32-2",
home: { team: WHEEL_TEAMS.japan, score: 2 },
away: { team: WHEEL_TEAMS.serbia, score: 1 },
winner: "home",
},
{
id: "w-r32-3",
home: { team: WHEEL_TEAMS.netherlands, score: 2 },
away: { team: WHEEL_TEAMS.ecuador, score: 0 },
winner: "home",
},
{
id: "w-r32-4",
home: { team: WHEEL_TEAMS.ghana, score: 2 },
away: { team: WHEEL_TEAMS.portugal, score: 3 },
winner: "away",
},
{
id: "w-r32-5",
home: { team: WHEEL_TEAMS.england, score: 4 },
away: { team: WHEEL_TEAMS.wales, score: 0 },
winner: "home",
},
{
id: "w-r32-6",
home: { team: WHEEL_TEAMS.canada, score: 0 },
away: { team: WHEEL_TEAMS.uruguay, score: 2 },
winner: "away",
},
{
id: "w-r32-7",
home: { team: WHEEL_TEAMS.croatia, score: 1 },
away: { team: WHEEL_TEAMS.denmark, score: 0 },
winner: "home",
},
{
id: "w-r32-8",
home: { team: WHEEL_TEAMS.brazil, score: 3 },
away: { team: WHEEL_TEAMS.cameroon, score: 1 },
winner: "home",
},
{
id: "w-r32-9",
home: { team: WHEEL_TEAMS.france, score: 2 },
away: { team: WHEEL_TEAMS.poland, score: 1 },
winner: "home",
},
{
id: "w-r32-10",
home: { team: WHEEL_TEAMS.senegal, score: 0 },
away: { team: WHEEL_TEAMS.morocco, score: 1 },
winner: "away",
},
{
id: "w-r32-11",
home: { team: WHEEL_TEAMS.belgium, score: 2 },
away: { team: WHEEL_TEAMS.tunisia, score: 0 },
winner: "home",
},
{
id: "w-r32-12",
home: { team: WHEEL_TEAMS.switzerland, score: 1 },
away: { team: WHEEL_TEAMS.italy, score: 3 },
winner: "away",
},
{
id: "w-r32-13",
home: { team: WHEEL_TEAMS.argentina, score: 2 },
away: { team: WHEEL_TEAMS.peru, score: 0 },
winner: "home",
},
{
id: "w-r32-14",
home: { team: WHEEL_TEAMS.qatar, score: 0 },
away: { team: WHEEL_TEAMS.mexico, score: 1 },
winner: "away",
},
{
id: "w-r32-15",
home: { team: WHEEL_TEAMS.germany, score: 4 },
away: { team: WHEEL_TEAMS.sweden, score: 2 },
winner: "home",
},
{
id: "w-r32-16",
home: { team: WHEEL_TEAMS.austria, score: 1 },
away: { team: WHEEL_TEAMS.norway, score: 2 },
winner: "away",
},
],
},
{
name: "Round of 16",
matches: [
{
id: "w-r16-1",
home: { team: WHEEL_TEAMS.spain, score: 2 },
away: { team: WHEEL_TEAMS.japan, score: 0 },
winner: "home",
},
{
id: "w-r16-2",
home: { team: WHEEL_TEAMS.netherlands, score: 1 },
away: { team: WHEEL_TEAMS.portugal, score: 3 },
winner: "away",
},
{
id: "w-r16-3",
home: { team: WHEEL_TEAMS.england, score: 2 },
away: { team: WHEEL_TEAMS.uruguay, score: 1 },
winner: "home",
},
{
id: "w-r16-4",
home: { team: WHEEL_TEAMS.croatia, score: 0 },
away: { team: WHEEL_TEAMS.brazil, score: 1 },
winner: "away",
},
{
id: "w-r16-5",
home: { team: WHEEL_TEAMS.france, score: 3 },
away: { team: WHEEL_TEAMS.morocco, score: 1 },
winner: "home",
},
{
id: "w-r16-6",
home: { team: WHEEL_TEAMS.belgium, score: 1 },
away: { team: WHEEL_TEAMS.italy, score: 2 },
winner: "away",
},
{
id: "w-r16-7",
home: { team: WHEEL_TEAMS.argentina, score: 2 },
away: { team: WHEEL_TEAMS.mexico, score: 0 },
winner: "home",
},
{
id: "w-r16-8",
home: { team: WHEEL_TEAMS.germany, score: 1, penalties: 4 },
away: { team: WHEEL_TEAMS.norway, score: 1, penalties: 2 },
winner: "home",
},
],
},
{
name: "Quarter-finals",
matches: [
{
id: "w-qf-1",
home: { team: WHEEL_TEAMS.spain, score: 1 },
away: { team: WHEEL_TEAMS.portugal, score: 0 },
winner: "home",
},
{
id: "w-qf-2",
home: { team: WHEEL_TEAMS.england, score: 2 },
away: { team: WHEEL_TEAMS.brazil, score: 3 },
winner: "away",
},
{
id: "w-qf-3",
home: { team: WHEEL_TEAMS.france, score: 2 },
away: { team: WHEEL_TEAMS.italy, score: 1 },
winner: "home",
},
{
id: "w-qf-4",
home: { team: WHEEL_TEAMS.argentina, score: 3 },
away: { team: WHEEL_TEAMS.germany, score: 1 },
winner: "home",
},
],
},
{
name: "Semi-finals",
matches: [
{
id: "w-sf-1",
home: { team: WHEEL_TEAMS.spain, score: 2 },
away: { team: WHEEL_TEAMS.brazil, score: 1 },
winner: "home",
},
{
id: "w-sf-2",
home: { team: WHEEL_TEAMS.france, score: 0, penalties: 3 },
away: { team: WHEEL_TEAMS.argentina, score: 0, penalties: 4 },
winner: "away",
},
],
},
{
name: "Final",
matches: [
{
id: "w-f-1",
home: { team: WHEEL_TEAMS.spain, score: 2 },
away: { team: WHEEL_TEAMS.argentina, score: 1 },
winner: "home",
},
],
},
];
</script>
<template>
<div class="wheel-stage"><KnockoutWheel :rounds="WHEEL_ROUNDS" /></div>
</template>
<style scoped>
.wheel-stage { width: 100%; padding-block: 2rem; }
</style><script setup lang="ts">
import { motion, useInView } from 'motion-v'
import { useReducedMotion } from '../core/reduced-motion'
import { computed, reactive, shallowRef, useId, useTemplateRef, watch } from 'vue'
import FloatingPanel from '../controls/FloatingPanel.vue'
import { useMountedMedia } from '../core/mounted-media'
import { panelSpring } from '../core/motion'
import {
crestSrc,
initials,
keepTogether,
knockoutWheelMessages,
mergeTournamentMessages,
tournamentTranslate,
type KnockoutWheelMessages,
type TournamentMatch,
type TournamentRound,
type TournamentSide,
type TournamentTeam,
type TournamentTranslate,
} from './tournament'
const props = withDefaults(defineProps<{
/**
* The whole draw, ordered widest round first — the same array the knockout
* bracket takes. Any single-elimination tournament fits: each round holds half
* the matches of the one before it (16 → 8 → 4 → 2 → 1) and `rounds[r].matches[k]`
* is fed by matches `2k` and `2k + 1` of the round before it. Two rounds are
* enough; the wheel grows a ring per round and sizes itself to the rim.
*/
rounds: TournamentRound[]
/**
* Index of the outermost round to draw. Earlier rounds are dropped and the
* kept round's own teams become the rim, so `1` on a 32-team draw opens at the
* Round of 16. Defaults to 0 (the whole tree); clamped to the valid range.
*/
initialRound?: number
className?: string
/** Override any built-in string. */
labels?: Partial<KnockoutWheelMessages>
}>(), { initialRound: 0 })
const text = computed(() => mergeTournamentMessages(knockoutWheelMessages, props.labels))
const t = computed(() => tournamentTranslate(text.value))
// Stable animate targets: a fresh object per render is fine for motion, but a
// stable one keeps 63 marks from churning on every pointer move.
const ENTER_VISIBLE = { opacity: 1, scale: 1 } as const
const LINK_VISIBLE = { opacity: 1 } as const
const SIZE = 760
const CENTER = SIZE / 2
// Solid trophy glyph drawn in a 24-unit box.
const TROPHY_SIZE = 24
const TROPHY_PATH =
'M5 1h12v3h3a2 2 0 0 1 2 2c0 3.3-2.2 5.6-5.2 6A6 6 0 0 1 12 15a6 6 0 0 1-4.8-2.9C4.2 11.6 2 9.3 2 6a2 2 0 0 1 2-2h1V1Zm0 5H4c0 1.9 1.1 3.2 2.6 3.7A12 12 0 0 1 5 6Zm14 0h-1a12 12 0 0 1-1.6 3.7C17.9 9.2 19 7.9 19 6ZM9 16.5h6V19h2.5v2h-11v-2H9v-2.5Z'
// The lucide shield, in its 24-unit box. Same slot mark the bracket uses for a
// TBD team, so an undecided place reads identically across both fixture styles.
const SHIELD_PATH =
'M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z'
// Clears the hub's top edge. The hub's two feeders sit on the horizontal, so
// the space directly above it is always free.
const TROPHY_GAP = 6
// Outermost ring. The remaining 62px of the box absorbs the largest node plus
// its ring stroke, so nothing clips at the viewBox edge.
const OUTER_R = 318
const HUB_R = 34
// Nodes grow outward so the crowded outer ring still reads at small sizes.
const NODE_MIN = 14.2
const NODE_STEP = 2.2
// Initials floor, in viewBox units. The stage never goes below 32rem against a
// 760-unit box (scale ~0.674), so 15 units is ~10px on screen — under that, two
// letters are a smudge. `node.r * 0.8` alone puts the inner ring at 7.6px.
const INITIALS_MIN = 15
// Siblings pull slightly toward their parent, opening a lane between subtrees.
const SIBLING_GAP = 0.9
// Puts the hub's two feeders on the horizontal, where there's room for them.
const HUB_ANGLE = 90
// Component-specific timing, kept local: a hover dim and the tap label run
// quicker than any shared token, and the match must stay byte-identical.
const DIM_TRANSITION = { duration: 0.18 } as const
const NO_TRANSITION = { duration: 0 } as const
// Math.sin/cos are implementation-defined down in the last digits, so the SSR
// engine and the browser disagree on every coordinate. Quantizing well below
// sub-pixel makes both agree exactly.
const quantize = (n: number) => Math.round(n * 1e3) / 1e3
const polar = (radius: number, deg: number) => {
const rad = (deg * Math.PI) / 180
return {
x: quantize(CENTER + radius * Math.cos(rad)),
y: quantize(CENTER + radius * Math.sin(rad)),
}
}
const point = (radius: number, deg: number) => {
const { x, y } = polar(radius, deg)
return `${x.toFixed(2)} ${y.toFixed(2)}`
}
// Fixed precision so the server and client render byte-identical style strings.
const pct = (value: number) => `${((value / SIZE) * 100).toFixed(4)}%`
type WheelNode = {
id: string
parentId: string | null
depth: number
/** Position around the wheel, in degrees. Orders arrow-key navigation. */
angle: number
x: number
y: number
r: number
team: TournamentTeam | null
label: string
/** Round the node's match belongs to; null on the rim, which holds teams. */
round: string | null
}
type WheelLink = {
id: string
d: string
depth: number
}
const teamName = (side: TournamentSide, translate: TournamentTranslate<KnockoutWheelMessages>) =>
keepTogether(side.team?.name ?? translate('tbd'))
/** Teams · score, in the order they were played. The round is prepended by the
* caller that has it, so the round list can reuse this without repeating it. */
function matchLabel(match: TournamentMatch, translate: TournamentTranslate<KnockoutWheelMessages>) {
const teams = translate('versus', {
home: teamName(match.home, translate),
away: teamName(match.away, translate),
})
if (match.home.score == null || match.away.score == null) return teams
const score = { teams, home: match.home.score, away: match.away.score }
return match.home.penalties != null && match.away.penalties != null
? translate('resultPenalties', {
...score,
homePenalties: match.home.penalties,
awayPenalties: match.away.penalties,
})
: translate('result', score)
}
/** Walks the match tree from the final outward, laying every node on a ring and
* splitting each parent's wedge between its two feeders. */
function buildWheel(rounds: TournamentRound[], translate: TournamentTranslate<KnockoutWheelMessages>) {
const nodes: WheelNode[] = []
const links: WheelLink[] = []
const layers = rounds.length
const ringR = (depth: number) => (depth / layers) * OUTER_R
const nodeR = (depth: number) => NODE_MIN + (depth - 1) * NODE_STEP
// An empty or malformed catalog renders nothing rather than throwing on the
// way to the hub.
const final = rounds[layers - 1]?.matches[0]
if (!final) return { nodes, links, champion: null }
const champion = final.winner ? final[final.winner].team : null
nodes.push({
id: final.id,
parentId: null,
depth: 0,
angle: HUB_ANGLE,
x: CENTER,
y: CENTER,
r: HUB_R,
team: champion,
label: matchLabel(final, translate),
round: rounds[layers - 1]!.name,
})
// `roundIndex` is the round `match` belongs to; its two feeders live one round
// out, or, past the first round, are the two teams that played it.
const walk = (match: TournamentMatch, roundIndex: number, index: number, parent: WheelNode, angle: number, wedge: number) => {
const depth = parent.depth + 1
const radius = ringR(depth)
const r = nodeR(depth)
// The hub's two feeders sit opposite each other, so they get plain radial
// lines; an arc between them would be a half circle.
const offset = (wedge / 4) * (parent.depth === 0 ? 1 : SIBLING_GAP)
const angles = [angle - offset, angle + offset]
const sides = ['home', 'away'] as const
const children = angles.map((childAngle, side) => {
const { x, y } = polar(radius, childAngle)
const feeder = roundIndex > 0 ? rounds[roundIndex - 1]!.matches[2 * index + side] : undefined
const sideMatch = match[sides[side]]
const node: WheelNode = feeder
? {
id: feeder.id,
parentId: parent.id,
depth,
angle: childAngle,
x,
y,
r,
team: feeder.winner ? feeder[feeder.winner].team : null,
label: matchLabel(feeder, translate),
round: rounds[roundIndex - 1]!.name,
}
: {
id: `${match.id}-${sides[side]}`,
parentId: parent.id,
depth,
angle: childAngle,
x,
y,
r,
team: sideMatch.team,
label: sideMatch.team?.name ?? translate('tbd'),
round: null,
}
nodes.push(node)
return { node, angle: childAngle, feeder }
})
if (parent.depth === 0) {
for (const child of children) {
links.push({
id: `${parent.id}-${child.node.id}`,
d: `M ${point(radius, child.angle)} L ${CENTER} ${CENTER}`,
depth,
})
}
} else {
const midR = (ringR(parent.depth) + radius) / 2
links.push({
id: `${parent.id}-arc`,
d: `M ${point(radius, angles[0]!)} L ${point(midR, angles[0]!)} A ${midR} ${midR} 0 0 1 ${point(midR, angles[1]!)} L ${point(radius, angles[1]!)}`,
depth,
})
links.push({
id: `${parent.id}-stem`,
d: `M ${point(midR, angle)} L ${point(ringR(parent.depth), angle)}`,
depth,
})
}
children.forEach((child, side) => {
if (child.feeder) {
walk(child.feeder, roundIndex - 1, 2 * index + side, child.node, child.angle, wedge / 2)
}
})
}
walk(final, layers - 1, 0, nodes[0]!, HUB_ANGLE, 360)
return { nodes, links, champion }
}
/** Match ids from the hub down to the champion's first-round win. */
function championPath(rounds: TournamentRound[]) {
const path = new Set<string>()
let index = 0
for (let r = rounds.length - 1; r >= 0; r--) {
const match = rounds[r]!.matches[index]
if (!match?.winner) return path
path.add(match.id)
if (r === 0) path.add(`${match.id}-${match.winner}`)
index = 2 * index + (match.winner === 'home' ? 0 : 1)
}
return path
}
/* ---- state --------------------------------------------------------------- */
const reduce = useReducedMotion()
// Touch devices fire a phantom sticky `:hover` on tap, so hover labels only
// exist where a real pointer can leave.
const canHover = useMountedMedia('(hover: hover) and (pointer: fine)')
const uid = useId().replace(/:/g, '')
const wheelSvg = useTemplateRef<SVGSVGElement>('wheelSvg')
const stage = useTemplateRef<HTMLElement>('wheelStage')
// 63 flags for a 32-team draw, and SVG <image> has no lazy attribute — so the
// requests wait until the wheel is nearly on screen.
const inView = useInView(wheelSvg, { once: true, margin: '300px' })
// Hover, tap and focus are tracked apart. Sharing one slot let a stray mouse
// move clear the isolation while a node still held focus, and a tap has to
// outlive the pointerleave that a finger fires the moment it lifts.
const hovered = shallowRef<string | null>(null)
const pinned = shallowRef<string | null>(null)
const focused = shallowRef<string | null>(null)
const active = computed(() => hovered.value ?? pinned.value ?? focused.value)
/* ---- drawing ------------------------------------------------------------- */
// Everything downstream reads the trimmed catalog, so the kept round's own
// teams become the rim and the sr-only list matches what's drawn.
const visible = computed(() => {
const from = Math.min(Math.max(props.initialRound, 0), Math.max(props.rounds.length - 1, 0))
return from > 0 ? props.rounds.slice(from) : props.rounds
})
const drawing = computed(() => buildWheel(visible.value, t.value))
const nodes = computed(() => drawing.value.nodes)
const links = computed(() => drawing.value.links)
const champion = computed(() => drawing.value.champion)
const winners = computed(() => championPath(visible.value))
const activeNode = computed(() => nodes.value.find(node => node.id === active.value))
// Pointing at one flag isolates that flag. Only at rest does the wheel fall
// back to lighting the champion's whole run.
const lit = computed(() => (activeNode.value ? new Set([activeNode.value.id]) : winners.value))
// Stable identity, or every mark re-runs its entrance on each pointer move.
const enter = computed(() =>
reduce.value
? { duration: 0, opacity: { duration: 0 } }
: { ...panelSpring, opacity: { duration: 0.24 } },
)
// One transition object per ring, cached, so the ring-by-ring entrance delay
// survives re-renders instead of allocating one object per mark.
const enterFor = computed(() => {
const cache = new Map<number, object>()
const base = enter.value
const reduceMotion = reduce.value
return (depth: number) => {
const hit = cache.get(depth)
if (hit) return hit
const value = { ...base, delay: reduceMotion ? 0 : depth * 0.06 }
cache.set(depth, value)
return value
}
})
// Tooltip is hover-only by design, so touch gets the same label anchored to the
// tapped flag. It flips to the far side near the rim so it stays on stage.
const tapped = computed(() => (canHover.value ? undefined : activeNode.value))
const tapAbove = computed(() => (tapped.value ? tapped.value.y > CENTER : false))
// Links draw outward ring by ring, half a beat behind the marks they lead to.
const linkCache = new Map<number, object>()
function linkTransition(depth: number) {
const hit = linkCache.get(depth)
if (hit) return hit
const value = { duration: 0.3, delay: depth * 0.06 }
linkCache.set(depth, value)
return value
}
// Arrow keys follow the geometry: up walks toward the hub, down walks out to a
// feeder, left/right go round the ring.
const rings = computed(() => {
const byDepth = new Map<number, WheelNode[]>()
const child = new Map<string, WheelNode>()
for (const node of nodes.value) {
const peers = byDepth.get(node.depth) ?? []
peers.push(node)
byDepth.set(node.depth, peers)
if (node.parentId && !child.has(node.parentId)) child.set(node.parentId, node)
}
for (const peers of byDepth.values()) peers.sort((a, b) => a.angle - b.angle)
return { ring: byDepth, firstChild: child }
})
const tabStop = computed(() => activeNode.value?.id ?? nodes.value[0]?.id)
function moveFocus(node: WheelNode, key: string) {
if (!key.startsWith('Arrow')) return
let target: WheelNode | undefined
if (key === 'ArrowUp') target = nodes.value.find(peer => peer.id === node.parentId)
else if (key === 'ArrowDown') target = rings.value.firstChild.get(node.id)
else {
const peers = rings.value.ring.get(node.depth) ?? []
if (peers.length < 2) target = undefined
else {
const at = peers.indexOf(node)
const next = key === 'ArrowRight' ? at + 1 : at - 1
target = peers[(next + peers.length) % peers.length]
}
}
if (!target) return
// Focus moves; the focus handler lights the node it lands on.
document.getElementById(`${uid}-${target.id}`)?.focus()
}
/* ---- tap-to-pin and dismissal -------------------------------------------- */
// A finger never leaves the flag it lit, so the isolation would hold for good —
// and bare stage reports no pointer event of its own to end it. The next
// pointerdown that isn't on a flag stands in for the pointer leaving; it is
// consumed, since a wheel spanning the viewport makes tapping past it the
// natural way out and there is no reason for that tap to do anything else.
// Only a pinned flag arms this: a mouse ends its own hover, and the browser
// drops focus on its own.
function unpin() {
pinned.value = null
const focus = document.activeElement
if (focus instanceof HTMLElement && stage.value?.contains(focus)) focus.blur()
}
/** True when the target is a flag inside this wheel. */
const onFlag = (target: Element) => Boolean(stage.value?.contains(target) && target.closest('button'))
// What every currently open dismiss scope counts as inside itself, so a stray
// gesture from behind another overlay is not answered twice.
const openScopes = new Set<(target: Element) => boolean>()
function consumeActivation(source: Event) {
const swallow = (event: MouseEvent) => {
event.preventDefault()
event.stopPropagation()
release()
}
const restart = (event: Event) => {
if (event !== source) release()
}
const release = () => {
window.removeEventListener('click', swallow, true)
window.removeEventListener('pointerdown', restart, true)
window.removeEventListener('pointercancel', restart, true)
window.removeEventListener('keydown', release, true)
}
window.addEventListener('click', swallow, true)
window.addEventListener('pointerdown', restart, true)
window.addEventListener('pointercancel', restart, true)
window.addEventListener('keydown', release, true)
}
let detachDismiss: (() => void) | undefined
watch(() => pinned.value !== null, pinnedOpen => {
detachDismiss?.()
detachDismiss = undefined
if (!pinnedOpen) return
const onKey = (event: KeyboardEvent) => {
if (event.key === 'Escape') unpin()
}
const onPointer = (event: PointerEvent) => {
const target = event.target as Element | null
if (!target || onFlag(target)) return
let claimed = false
for (const scope of openScopes) if (scope !== onFlag && scope(target)) claimed = true
if (!claimed) consumeActivation(event)
unpin()
}
openScopes.add(onFlag)
window.addEventListener('keydown', onKey)
window.addEventListener('pointerdown', onPointer, true)
detachDismiss = () => {
openScopes.delete(onFlag)
window.removeEventListener('keydown', onKey)
window.removeEventListener('pointerdown', onPointer, true)
}
}, { immediate: true })
// Round · teams · score for a decided match; a rim node is just a team. A slot
// whose team isn't known yet reads TBD, matching the shield drawn in its place.
const captions = computed(() => new Map(nodes.value.map(node => [
node.id,
node.team == null
? t.value('tbd')
: node.round
? t.value('caption', { round: keepTogether(node.round), match: node.label })
: node.team.name,
])))
/* ---- per-mark artwork ---------------------------------------------------- */
// The failed URL, not a boolean: a corrected logo on the same node should be
// tried again rather than stay initials for the life of the wheel.
const failedSrc = reactive(new Map<string, string>())
function markSrc(node: WheelNode) {
const resolved = crestSrc(node.team)
return resolved === failedSrc.get(node.id) ? null : resolved
}
// A square logo is fitted whole; a 4:3 flag is cropped to fill the disc.
function markBox(node: WheelNode) {
return node.team?.logo
? { w: node.r * 1.44, h: node.r * 1.44, fit: 'xMidYMid meet' }
: { w: node.r * 2.68, h: node.r * 2, fit: 'xMidYMid slice' }
}
// Dimming rides on the mark itself rather than a scrim tinted with the page
// background, so the wheel recedes correctly on any surface it's dropped on.
const fade = (node: WheelNode) => ({ opacity: lit.value.has(node.id) || lit.value.size === 0 ? 1 : 0.38 })
const markTransition = computed(() => (reduce.value ? NO_TRANSITION : DIM_TRANSITION))
/* ---- hover label --------------------------------------------------------- */
// Mirrors the shared tooltip: 120 ms before a resting pointer opens a label,
// instant open for a keyboard focus or right after another label closed
// (skipDelay), and no tail on close.
const TIP_DELAY = 120
const TIP_SKIP_DELAY = 300
const tipId = `${uid}-tip`
const tipTarget = shallowRef<WheelNode | null>(null)
const tipAnchor = shallowRef<HTMLElement | null>(null)
const tipOpen = shallowRef(false)
let tipTimer: number | undefined
let tipClosedAt = 0
let graceStop: (() => void) | undefined
function clearTipTimer() {
window.clearTimeout(tipTimer)
tipTimer = undefined
}
function closeTip(wait = 0) {
clearTipTimer()
stopGrace()
const hide = () => {
if (!tipOpen.value) return
tipOpen.value = false
tipClosedAt = Date.now()
}
if (wait > 0) tipTimer = window.setTimeout(hide, wait)
else hide()
}
function openTip(node: WheelNode, anchor: HTMLElement | null, delay: number) {
clearTipTimer()
if (tipOpen.value && tipTarget.value?.id === node.id) return
tipTarget.value = node
tipAnchor.value = anchor
const warm = Date.now() - tipClosedAt < TIP_SKIP_DELAY
if (warm || delay <= 0) {
tipOpen.value = true
return
}
tipTimer = window.setTimeout(() => {
tipOpen.value = true
}, delay)
}
// Hold the label open while the pointer crosses the few pixels between the
// flag and the surface it opened: the pointer is inside their union either way.
function stopGrace() {
graceStop?.()
graceStop = undefined
}
function startGrace(from: HTMLElement) {
stopGrace()
const panel = document.querySelector<HTMLElement>(`.be-wheel-tip`)
if (!panel) {
closeTip(0)
return
}
const boxes = [from.getBoundingClientRect(), panel.getBoundingClientRect()]
const onMove = (event: PointerEvent) => {
const inside = boxes.some(box =>
event.clientX >= box.left - 6 && event.clientX <= box.right + 6 &&
event.clientY >= box.top - 6 && event.clientY <= box.bottom + 6)
if (!inside) closeTip(0)
}
document.addEventListener('pointermove', onMove)
graceStop = () => document.removeEventListener('pointermove', onMove)
}
/* ---- pointer and keyboard per flag --------------------------------------- */
// Enter and leave are paired per pointer: a pen that arrives in contact taps
// rather than hovers, and a mouse that pressed and dragged off still leaves.
const hoverContact = new Set<number>()
// Focus that came from the keyboard holds the label open on its own.
let keyboardFocus = false
function hoverEnter(node: WheelNode, event: PointerEvent) {
const hovering = event.pointerType !== 'touch' && event.buttons === 0
if (hovering) hoverContact.delete(event.pointerId)
else hoverContact.add(event.pointerId)
if (!hovering) return
stopGrace()
hovered.value = node.id
openTip(node, event.currentTarget as HTMLElement, TIP_DELAY)
}
function hoverLeave(event: PointerEvent) {
const arrivedInContact = hoverContact.delete(event.pointerId)
if (arrivedInContact || event.pointerType === 'touch') return
hovered.value = null
if (keyboardFocus) return
if (tipOpen.value) startGrace(event.currentTarget as HTMLElement)
else closeTip(0)
}
// A `click` carries no `pointerType`, so the `pointerdown` before it is the only
// thing that says which input activated the flag — and whether one did at all.
type TapRecord = { pointerType: string, state: string | null }
let tapRecord: TapRecord | null = null
function tapDrop() {
tapRecord = null
}
function flagClick(node: WheelNode, event: MouseEvent) {
const gesture = tapRecord
tapRecord = null
// A hovering pointer lit the flag on its way in and puts it out on the way
// past; only a gesture without a hover pins one.
if (!gesture || gesture.pointerType === 'mouse') return
pinned.value = pinned.value === node.id ? null : node.id
// Click, not pointerdown: a tap focuses the flag first, and unpinning has to
// also drop that focus or the flag stays lit.
if (gesture.state) (event.currentTarget as HTMLElement | null)?.blur()
}
function flagKey(node: WheelNode, event: KeyboardEvent) {
// A key press starts a keyboard activation, which never had a pointer behind
// it: a gesture the platform took away must not be read as the tap behind the
// click this press synthesizes.
tapDrop()
if (!event.key.startsWith('Arrow')) return
// Arrows drive the wheel here, so they must not also scroll the page.
event.preventDefault()
moveFocus(node, event.key)
}
function flagFocus(node: WheelNode, event: FocusEvent) {
focused.value = node.id
const element = event.currentTarget as HTMLElement
if (!element.matches(':focus-visible')) return
keyboardFocus = true
openTip(node, element, 0)
}
function flagBlur(event: FocusEvent) {
const next = event.relatedTarget
if (next instanceof Node && (event.currentTarget as HTMLElement).contains(next)) return
focused.value = null
keyboardFocus = false
closeTip(0)
}
</script>
<template>
<div class="be-wheel" :class="className">
<!-- Below the min width the rim's marks collapse too small to tell apart or
tap, so the wheel holds its size and pans instead. The floor is fixed,
not rim-derived: node radius grows with depth, so a shallower draw has
*smaller* marks and needs the width more, not less. -->
<div ref="wheelStage" class="be-wheel-stage">
<svg
ref="wheelSvg"
:viewBox="`0 0 ${SIZE} ${SIZE}`"
role="img"
:aria-label="champion ? t('labelWithChampion', { team: champion.name }) : t('label')"
class="be-wheel-svg"
>
<defs>
<!-- Warm halo marking the champion. Kept faint: the warning colour is
saturated enough that anything stronger drowns the connectors. -->
<radialGradient :id="`${uid}-glow`">
<stop offset="0%" class="be-wheel-glow" stop-opacity="0.14" />
<stop offset="45%" class="be-wheel-glow" stop-opacity="0.04" />
<stop offset="100%" class="be-wheel-glow" stop-opacity="0" />
</radialGradient>
</defs>
<circle
v-if="champion"
:cx="CENTER"
:cy="CENTER"
:r="OUTER_R * 0.62"
:fill="`url(#${uid}-glow)`"
/>
<!-- role="img" on the svg prunes descendants from the accessibility tree,
so the structure needs no aria-hidden of its own. -->
<!-- tabindex="-1" on every motion'd SVG child: motion-v mounts a focus
listener on each motion element unconditionally, and Chrome makes an
SVG graphics element tabbable once anything listens for its focus —
which put the connectors and marks in the Tab order ahead of the
flags. React's framer-motion only loads that feature when the element
uses whileFocus, so the original never had the listeners; the
attribute restores the original's tab order. -->
<g>
<motion.path
v-for="link in links"
:key="link.id"
:d="link.d"
fill="none"
:initial="reduce ? false : { opacity: 0 }"
:animate="LINK_VISIBLE"
:transition="linkTransition(link.depth)"
tabindex="-1"
class="be-wheel-link"
/>
</g>
<motion.g
v-for="node in nodes"
:key="node.id"
:initial="reduce ? false : { opacity: 0, scale: 0.6 }"
:animate="ENTER_VISIBLE"
:transition="enterFor(node.depth)"
:style="{ transformOrigin: `${node.x}px ${node.y}px` }"
tabindex="-1"
>
<g v-if="node.depth === 0 && champion" :transform="`translate(${CENTER - TROPHY_SIZE / 2}, ${CENTER - HUB_R - TROPHY_GAP - TROPHY_SIZE})`">
<path :d="TROPHY_PATH" class="be-wheel-trophy" />
</g>
<!-- Stays opaque at every state: links are routed underneath and would
otherwise read straight through the flag. -->
<circle :cx="node.x" :cy="node.y" :r="node.r" class="be-wheel-disc" />
<motion.g
:initial="false"
:animate="fade(node)"
:transition="markTransition"
tabindex="-1"
>
<template v-if="markSrc(node) && inView">
<clipPath :id="`${uid}-clip-${node.id}`">
<circle :cx="node.x" :cy="node.y" :r="node.r" />
</clipPath>
<!-- Plain <image> — flags from flagcdn.com, logos from wherever you
host them. A 4:3 flag is cropped to fill the disc; a logo is
fitted whole inside it, since a crest cropped to a circle loses
its shape. -->
<image
:href="markSrc(node)!"
:x="node.x - markBox(node).w / 2"
:y="node.y - markBox(node).h / 2"
:width="markBox(node).w"
:height="markBox(node).h"
:clip-path="`url(#${uid}-clip-${node.id})`"
:preserveAspectRatio="markBox(node).fit"
@error="failedSrc.set(node.id, markSrc(node)!)"
/>
</template>
<!-- No artwork on this team — initials keep the ring readable. -->
<text
v-else-if="node.team"
:x="node.x"
:y="node.y"
text-anchor="middle"
dominant-baseline="central"
:font-size="Math.max(node.r * 0.8, INITIALS_MIN)"
class="be-wheel-initials"
>{{ initials(node.team.name) }}</text>
<!-- Same shield the bracket uses for a TBD slot, so an undecided
place reads identically across both fixture styles. -->
<svg
v-else
:x="node.x - node.r * 0.7"
:y="node.y - node.r * 0.7"
:width="node.r * 1.4"
:height="node.r * 1.4"
viewBox="0 0 24 24"
fill="currentColor"
class="be-wheel-shield"
><path :d="SHIELD_PATH" /></svg>
</motion.g>
<circle
:cx="node.x"
:cy="node.y"
:r="node.r"
fill="none"
:stroke-width="lit.has(node.id) ? 2 : 1"
:class="lit.has(node.id) ? 'be-wheel-ring-lit' : 'be-wheel-ring'"
/>
</motion.g>
</svg>
<!-- An SVG <g> can't anchor a tooltip, so each flag gets an invisible HTML
hit area laid over it in percentage units, which track the wheel as it
scales. Both interaction paths are always attached: iPadOS answers the
hover query with true for a finger, so hanging the tap path off "cannot
hover" left it unreachable on the very device it was written for. The
event says which input arrived. -->
<div
v-for="node in nodes"
:key="`hit-${node.id}`"
class="be-wheel-anchor"
:style="{
left: pct(node.x - node.r),
top: pct(node.y - node.r),
width: pct(node.r * 2),
height: pct(node.r * 2),
}"
>
<button
:id="`${uid}-${node.id}`"
type="button"
:tabindex="node.id === tabStop ? 0 : -1"
:aria-label="captions.get(node.id) ?? ''"
:aria-describedby="tipOpen && tipTarget?.id === node.id ? tipId : undefined"
class="be-wheel-hit"
@keydown="flagKey(node, $event)"
@focusin="flagFocus(node, $event)"
@focusout="flagBlur"
@pointerenter="hoverEnter(node, $event)"
@pointerleave="hoverLeave"
@pointerdown="tapRecord = { pointerType: $event.pointerType, state: pinned }"
@pointercancel="tapDrop"
@click="flagClick(node, $event)"
/>
</div>
<motion.p
v-if="tapped"
:initial="reduce ? false : { opacity: 0, scale: 0.94 }"
:animate="{ opacity: 1, scale: 1 }"
:transition="markTransition"
class="be-wheel-tap"
:class="tapAbove ? 'is-above' : 'is-below'"
:style="{ left: pct(tapped.x), top: pct(tapped.y + (tapAbove ? -tapped.r : tapped.r)) }"
>{{ captions.get(tapped.id) }}</motion.p>
<!-- One hover label for the whole wheel: it follows the flag under the
pointer instead of mounting 63 teleported panels. -->
<FloatingPanel
v-if="canHover"
:id="tipId"
role="tooltip"
:open="tipOpen && Boolean(tipTarget)"
:anchor="tipAnchor"
side="top"
align="center"
:gap="5"
variant="tip"
class="be-wheel-tip"
@dismiss="closeTip(0)"
@pointerenter="clearTipTimer"
@pointerleave="closeTip(0)"
>{{ tipTarget ? captions.get(tipTarget.id) : '' }}</FloatingPanel>
</div>
<!-- role="img" prunes the svg's descendants, so every result is restated
here for screen readers. Named lists, not named sections — a named
section is a landmark, and five of those would crowd real page
landmarks. -->
<div class="be-wheel-sr">
<ul v-for="round in visible.slice().reverse()" :key="round.name" :aria-label="round.name">
<li v-for="match in round.matches" :key="match.id">{{ matchLabel(match, t) }}</li>
</ul>
</div>
</div>
</template>
<style scoped>
.be-wheel {
box-sizing: border-box;
width: 100%;
max-width: 100%;
overflow-x: auto;
overscroll-behavior-x: contain;
color: var(--beui-foreground);
}
.be-wheel-stage { position: relative; margin-inline: auto; width: 100%; min-width: 32rem; max-width: 34rem; }
.be-wheel-svg { display: block; width: 100%; height: auto; touch-action: manipulation; }
.be-wheel-link { stroke: var(--beui-border-strong, color-mix(in srgb, var(--beui-foreground) 12%, transparent)); }
.be-wheel-disc { fill: var(--beui-card); }
.be-wheel-initials { fill: var(--beui-muted-foreground); font-weight: 600; }
.be-wheel-ring { stroke: var(--beui-border); }
.be-wheel-ring-lit { stroke: var(--beui-foreground); }
.be-wheel-trophy { fill: var(--beui-warning, oklch(78% 0.18 75)); }
.be-wheel-glow { stop-color: var(--beui-warning, oklch(78% 0.18 75)); }
.be-wheel-shield { color: color-mix(in srgb, var(--beui-muted-foreground) 50%, transparent); }
.be-wheel-anchor { position: absolute; }
.be-wheel-hit {
display: block;
width: 100%;
height: 100%;
padding: 0;
border: 0;
border-radius: 999px;
background: transparent;
color: inherit;
cursor: pointer;
outline: none;
}
/* ring-foreground, not the ring token: --ring is a 10% hairline that disappears
over a flag. Focus has to be obvious. */
.be-wheel-hit:focus-visible { outline: 2px solid var(--beui-foreground); outline-offset: 2px; }
.be-wheel-tap {
position: absolute;
z-index: 10;
width: max-content;
max-width: min(18rem, 80vw);
margin: 0;
padding: .25rem .625rem;
pointer-events: none;
border: 1px solid var(--beui-border);
border-radius: .5rem;
background: var(--beui-background);
color: var(--beui-foreground);
font-size: .75rem;
font-weight: 500;
text-align: center;
text-wrap: balance;
overflow-wrap: break-word;
box-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);
}
.be-wheel-tap { translate: -50% 0; }
.be-wheel-tap.is-above { translate: -50% calc(-100% - 8px); }
.be-wheel-tap.is-below { translate: -50% .5rem; }
.be-wheel-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
</style>
<style>
/* The label is teleported to the body, so its chrome has to be global. */
.be-wheel-tip {
max-width: min(20rem, calc(100vw - 16px));
padding: .25rem .625rem;
border: 1px solid var(--beui-border);
border-radius: .5rem;
background: var(--beui-background);
color: var(--beui-foreground);
font-size: .75rem;
font-weight: 500;
white-space: normal;
text-align: center;
text-wrap: balance;
overflow-wrap: break-word;
box-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);
}
</style>Install
Run it in a project set up with shadcn-vue. The source is copied to components/beui and its dependencies are added to your package.json. Read the shadcn-vue guide
$ bunx --bun shadcn-vue@latest add @beui-vue/knockout-wheel$ bun add beui-vueDownload the release archive to your project root, then install the local file.
$ bun add ./beui-vue-0.1.0.tgzImport the shared styles once in your application.
import KnockoutWheel from '@/components/beui/blocks/KnockoutWheel.vue'
import '@/components/beui/styles.css'API Reference
roundsTournamentRound[]The whole draw, ordered widest round first — the same array the knockout bracket takes. Any single-elimination tournament fits: each round holds half the matches of the one before it (16 → 8 → 4 → 2 → 1) and `rounds[r].matches[k]` is fed by matches `2k` and `2k + 1` of the round before it. Two rounds are enough; the wheel grows a ring per round and sizes itself to the rim.
—initialRound?numberIndex of the outermost round to draw. Earlier rounds are dropped and the kept round's own teams become the rim, so `1` on a 32-team draw opens at the Round of 16. Defaults to 0 (the whole tree); clamped to the valid range.
0className?string—labels?Partial<KnockoutWheelMessages>Override any built-in string.
—Knockout Bracket
KnockoutBracket.vue- Mon, 29 JunFT
South Africa0
Canada1 - Tue, 30 JunFT (P)
Netherlands1 (2)
Morocco1 (3) - Tue, 30 JunFT (P)
Germany1 (3)
Paraguay1 (4) - Wed, 1 JulFT
France3
Sweden0 - Thu, 2 JulFT
Belgium3
Senegal2 - Thu, 2 JulFT
USA2
Bosnia and Herzegovina0 - Fri, 3 JulFT
Spain3
Austria0 - Fri, 3 JulFT
Portugal2
Croatia1 - Mon, 29 JunFT
Brazil2
Japan1 - Tue, 30 JunFT
Côte d'Ivoire1
Norway2 - Wed, 1 JulFT
Mexico2
Ecuador0 - Wed, 1 JulFT
England2
DR Congo1 - Fri, 3 JulFT
Switzerland2
Algeria0 - Sat, 4 JulFT
Colombia1
Ghana0 - Fri, 3 JulFT (P)
Australia1 (2)
Egypt1 (4) - Sat, 4 JulFT
Argentina3
Cabo Verde2
- Sat, 4 JulFT
Canada0
Morocco3 - Sun, 5 JulFT
Paraguay0
France1 - Mon, 6 JulFT
USA1
Belgium4 - Mon, 6 JulFT
Portugal0
Spain1 - Mon, 6 JulFT
Brazil1
Norway2 - Mon, 6 JulFT
Mexico2
England3 - Tue, 7 JulFT (P)
Switzerland0 (4)
Colombia0 (3) - Tue, 7 JulFT
Argentina3
Egypt2
- Fri, 10 Jul, 4:00 amFT
France2
Morocco0 - Sat, 11 Jul, 3:00 amFT
Spain2
Belgium1 - TodayFT
Norway1
England2 - TodayFT
Argentina3
Switzerland1
- Wed, 15 Jul, 4:00 am
France
Spain - Thu, 16 Jul, 3:00 am
England
Argentina
- Mon, 20 Jul, 3:00 amTBDTBD
Third place play-off
Sun, 19 Jul, 3:00 amTBDTBD
<script setup lang="ts">
import { KnockoutBracket } from 'beui-vue'
import { BRACKET_ROUNDS, THIRD_PLACE } from './tournament-data'
</script>
<template>
<div class="bracket-stage"><KnockoutBracket :rounds="BRACKET_ROUNDS" :third-place="THIRD_PLACE" /></div>
</template>
<style scoped>
.bracket-stage { width: 100%; padding-block: 2rem; }
</style><script setup lang="ts">
import { motion } from 'motion-v'
import { useReducedMotion } from '../core/reduced-motion'
import { computed, shallowRef } from 'vue'
import { easeOut } from '../core/motion'
import MatchCard from './MatchCard.vue'
import {
MATCH_CARD_HEIGHT,
MATCH_CARD_WIDTH,
isTournamentFinished,
knockoutBracketMessages,
mergeTournamentMessages,
tournamentTranslate,
type TournamentMatch,
type TournamentRound,
type TournamentSide,
} from './tournament'
const props = withDefaults(defineProps<{
/**
* The whole draw, ordered widest round first. Any single-elimination
* tournament fits: each round holds half the matches of the one before it
* (16 → 8 → 4 → 2 → 1) and `rounds[r].matches[k]` is fed by matches `2k` and
* `2k + 1` of the round before it. Two rounds are enough.
*/
rounds: TournamentRound[]
/** Round shown as the leftmost column on mount. Defaults to 1, clamped to the valid range. */
initialRound?: number
/** Third place play-off, rendered under the bracket instead of inside it. */
thirdPlace?: TournamentMatch
/** Heading over `thirdPlace`. Defaults to the `thirdPlace` message ("Third place play-off"). */
thirdPlaceLabel?: string
/** Override any built-in string. */
labels?: Partial<typeof knockoutBracketMessages>
/** BCP 47 tag used to join the visible round names in the live status. Defaults to `en`. */
locale?: string
className?: string
}>(), { initialRound: 1 })
const text = computed(() => mergeTournamentMessages(knockoutBracketMessages, props.labels))
const t = computed(() => tournamentTranslate(text.value))
const thirdPlaceLabel = computed(() => props.thirdPlaceLabel ?? t.value('thirdPlace'))
const reduce = useReducedMotion()
// Card geometry drives the whole computed layout — every later match sits at
// the exact vertical midpoint of its two feeders, so pairs line up with
// connectors. Keep CARD_H in sync with the card's internal spacing.
const CARD_W = MATCH_CARD_WIDTH
const CARD_H = MATCH_CARD_HEIGHT
// Pocket (20) + stem (20) — matches the CSS `]` connector geometry.
const GAP_X = 40
const GAP_Y = 20
const COL_W = CARD_W + GAP_X
const ROW = CARD_H + GAP_Y
const VISIBLE_COLS = 3
const CONNECTOR_POCKET = 20
const CONNECTOR_STEM = GAP_X - CONNECTOR_POCKET
// Tall enough for 44px chevron hit areas without clipping the focus ring.
const HEADER_H = 44
// Breathing room baked into the computed layout so the base column isn't flush
// against the clip edge and connector nubs aren't shaved off.
const PAD_X = 8
const PAD_Y = 12
// Firmer than `layoutSpring` so the many cards, connectors and stage height
// glide as one piece; damping just over critical (~1.05) settles with no bounce
// and no lazy overdamped tail. Component-specific, so kept local.
const REFLOW = {
type: 'spring',
stiffness: 260,
damping: 32,
mass: 0.9,
} as const
// Opacity cross-fades a touch ahead of the position spring so columns don't
// ghost while sliding.
const REFLOW_OPACITY = {
duration: 0.28,
ease: easeOut,
} as const
const clamp = (n: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, n))
// Column x-offset and window test — shared by the render pass and the computed
// layout so the two can't drift.
const colX = (r: number, page: number) => PAD_X + (r - page) * COL_W
const isInWindow = (r: number, page: number, visibleCols: number) =>
r >= page && r < page + visibleCols
const visibleCols = computed(() => Math.min(VISIBLE_COLS, props.rounds.length))
// The last page shows the final two rounds (semi-finals + final), not a full
// window — so paging continues past the QF/SF/Final view down to SF + Final.
const maxPage = computed(() => Math.max(0, props.rounds.length - Math.min(2, props.rounds.length)))
const rawPage = shallowRef(props.initialRound)
// Clamped in render: `rounds` can shrink after mount.
const page = computed(() => clamp(rawPage.value, 0, maxPage.value))
function step(delta: number) {
const current = clamp(rawPage.value, 0, maxPage.value)
rawPage.value = clamp(current + delta, 0, maxPage.value)
}
// Shared reflow — cards, connectors, headers and stage height page together.
// Height springs with the same token (layout morph is the product feel for
// collapsing rounds); opacity uses a short ease so fades don't lag the glide.
const transition = computed(() => (reduce.value ? { duration: 0 } : { ...REFLOW, opacity: REFLOW_OPACITY }))
// "en" without a provider so server and client join the names the same way.
const pageStatus = computed(() => {
const names = props.rounds.slice(page.value, page.value + visibleCols.value).map(round => round.name)
return t.value('showing', { rounds: new Intl.ListFormat(props.locale ?? 'en').format(names) })
})
// Layout is computed, not scrolled. The leftmost visible round (`page`) is the
// base and stacks at a fixed rhythm; every later match centers on its feeders,
// and behind rounds spread out (below). Cards and connectors derive from one
// pass and page together under the shared transition.
const layout = computed(() => {
const rounds = props.rounds
const pageIndex = page.value
const visible = visibleCols.value
const centers: number[][] = new Array(rounds.length)
const base = rounds[pageIndex]
if (!base) return { centers, containerHeight: 0, connectors: [] as BracketConnector[] }
centers[pageIndex] = base.matches.map((_, i) => PAD_Y + i * ROW + CARD_H / 2)
for (let r = pageIndex + 1; r < rounds.length; r++) {
const feeders = centers[r - 1]!
const row: number[] = []
for (let k = 0; k < rounds[r]!.matches.length; k++) {
const top = feeders[2 * k]
if (top == null) {
// A round with more matches than its feeders allow (an odd draw, a bye
// left out) stacks a full row under the last card placed in this round —
// a fixed rhythm from the top can land on top of a midpoint.
const prev = row[k - 1]
row[k] = prev == null ? PAD_Y + CARD_H / 2 : prev + ROW
} else {
row[k] = (top + (feeders[2 * k + 1] ?? top)) / 2
}
}
centers[r] = row
}
// Behind rounds keep their natural spread (spacing halves each step out, each
// match straddling its parent) instead of collapsing, so paging back slides a
// formed column in from the left just as paging forward does.
for (let r = pageIndex - 1; r >= 0; r--) {
const half = ROW / 2 ** (pageIndex - r + 1)
centers[r] = rounds[r]!.matches.map((_, i) => {
const parent = centers[r + 1]![Math.floor(i / 2)] ?? PAD_Y
return parent + (i % 2 === 0 ? -half : half)
})
}
const list: BracketConnector[] = []
for (let r = 1; r < rounds.length; r++) {
const feederRight = colX(r - 1, pageIndex) + CARD_W
const visibleConnector = isInWindow(r, pageIndex, visible) && isInWindow(r - 1, pageIndex, visible)
rounds[r]!.matches.forEach((_, k) => {
const yTop = centers[r - 1]?.[2 * k] ?? centers[r]?.[k] ?? PAD_Y
const yBot = centers[r - 1]?.[2 * k + 1] ?? yTop
list.push({
key: `${r}-${k}`,
x: feederRight,
y: yTop,
height: Math.max(0, yBot - yTop),
visible: visibleConnector,
})
})
}
// Measured, not derived from the base count: a fallback-stacked round can run
// past the base column, and the stage clips its overflow. Seeded with one
// card's center so an empty round yields a real height rather than -Infinity.
const lowest = Math.max(
PAD_Y + CARD_H / 2,
...centers.slice(pageIndex, pageIndex + visible).flatMap(row => row ?? []),
)
return {
centers,
containerHeight: lowest + CARD_H / 2 + PAD_Y,
connectors: list,
}
})
const containerWidth = computed(() => visibleCols.value * CARD_W + (visibleCols.value - 1) * GAP_X + 2 * PAD_X)
type BracketConnector = {
key: string
/** Feeder card right edge — left of the `]` pocket. */
x: number
/** Top feeder center Y. */
y: number
/** Distance between the two feeder centers. */
height: number
visible: boolean
}
// CSS `]` pocket + stem: border-y/border-r + a hairline to the child.
// Transform/opacity only — no SVG path morph, so paging stays flicker-free.
function connectorGeo(connector: BracketConnector) {
if (connector.visible) return transition.value
return { ...transition.value, x: { duration: 0 }, y: { duration: 0 }, height: { duration: 0 } }
}
/* ---- accessible names ---------------------------------------------------- */
function sideLabel(side: TournamentSide) {
const team = side.team?.name ?? t.value('tbd')
if (side.score == null) return team
return side.penalties != null
? t.value('sideScorePenalties', { team, score: side.score, penalties: side.penalties })
: t.value('sideScore', { team, score: side.score })
}
function matchLabel(roundName: string, match: TournamentMatch) {
const finished = isTournamentFinished(match)
const sides = t.value(finished ? 'matchResult' : 'matchVersus', {
round: roundName,
home: sideLabel(match.home),
away: sideLabel(match.away),
})
// Same pair the card's header row shows, so a time-only match isn't announced
// without its kick-off.
const schedule = finished ? [] : [match.date, match.time].filter(Boolean)
const when = schedule.length ? `, ${schedule.join(', ')}` : ''
const winnerName = match.winner ? match[match.winner].team?.name : undefined
const outcome = winnerName ? `, ${t.value('winner', { team: winnerName })}` : ''
return `${sides}${when}${outcome}`
}
</script>
<template>
<div v-if="rounds.length > 0" class="be-bracket">
<section class="be-bracket-section" :aria-label="text.label" :style="{ width: `${containerWidth}px` }">
<div class="be-sr" aria-live="polite">{{ pageStatus }}</div>
<!-- Only the gliding round titles are clipped (they enter/exit at the
canvas edge); the chevron buttons sit outside that clip. -->
<div class="be-bracket-header" :style="{ height: `${HEADER_H}px` }">
<div class="be-bracket-titles">
<motion.div
v-for="(round, r) in rounds"
:key="round.name"
:aria-hidden="isInWindow(r, page, visibleCols) ? undefined : true"
:initial="false"
:animate="{ x: colX(r, page), opacity: isInWindow(r, page, visibleCols) ? 1 : 0 }"
:transition="transition"
class="be-bracket-title"
:style="{ width: `${CARD_W}px` }"
>{{ round.name }}</motion.div>
</div>
<button
v-if="page > 0"
type="button"
class="be-bracket-nav is-previous"
:aria-label="text.previousRound"
:style="{ left: `${PAD_X}px` }"
@click="step(-1)"
>
<span class="be-bracket-nav-face">
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="m15 18-6-6 6-6" /></svg>
</span>
</button>
<button
v-if="page < maxPage"
type="button"
class="be-bracket-nav is-next"
:aria-label="text.nextRound"
:style="{ right: `${PAD_X}px` }"
@click="step(1)"
>
<span class="be-bracket-nav-face">
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="m9 18 6-6-6-6" /></svg>
</span>
</button>
</div>
<!-- Stage height springs with the reflow token so the bracket collapses as
one piece with the cards — the layout property is intentional here. -->
<motion.div
class="be-bracket-stage"
:initial="false"
:animate="{ height: layout.containerHeight }"
:transition="transition"
:style="{ width: `${containerWidth}px` }"
>
<motion.div
v-for="connector in layout.connectors"
:key="connector.key"
aria-hidden="true"
:initial="false"
:animate="{ x: connector.x, y: connector.y, height: connector.height, opacity: connector.visible ? 1 : 0 }"
:transition="connectorGeo(connector)"
class="be-bracket-connector"
:style="{ width: `${CONNECTOR_POCKET}px`, willChange: 'transform' }"
>
<span class="be-bracket-stem" :style="{ width: `${CONNECTOR_STEM}px` }" />
</motion.div>
<ul
v-for="(round, r) in rounds"
:key="round.name"
:aria-label="round.name"
:aria-hidden="isInWindow(r, page, visibleCols) ? undefined : true"
class="be-bracket-round"
>
<motion.li
v-for="(match, k) in round.matches"
:key="match.id"
:aria-label="matchLabel(round.name, match)"
:initial="false"
:animate="{
x: colX(r, page),
y: (layout.centers[r]?.[k] ?? 0) - CARD_H / 2,
opacity: isInWindow(r, page, visibleCols) ? 1 : 0,
}"
:transition="transition"
class="be-bracket-card"
:style="{ willChange: 'transform' }"
>
<MatchCard :match="match" :labels="text" />
</motion.li>
</ul>
</motion.div>
<!-- Outside the bracket stage — it feeds off the semi-finals rather than
into the final, so it gets its own rule instead of a column. -->
<div v-if="thirdPlace" class="be-bracket-third" :style="{ paddingLeft: `${PAD_X}px` }">
<ul :aria-label="thirdPlaceLabel" class="be-bracket-round">
<li :aria-label="matchLabel(thirdPlaceLabel, thirdPlace)">
<p class="be-bracket-third-label">{{ thirdPlaceLabel }}</p>
<MatchCard :match="thirdPlace" :labels="text" />
</li>
</ul>
</div>
</section>
</div>
</template>
<style scoped>
.be-bracket {
box-sizing: border-box;
width: 100%;
max-width: 100%;
overflow-x: auto;
overscroll-behavior-x: contain;
color: var(--beui-foreground);
font-size: .875rem;
line-height: 1.5;
}
.be-bracket-section { position: relative; margin-inline: auto; }
.be-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0; }
.be-bracket-header { position: relative; }
.be-bracket-titles { position: absolute; inset: 0; overflow: hidden; }
.be-bracket-title {
position: absolute;
left: 0;
top: 0;
display: flex;
align-items: center;
justify-content: center;
height: 100%;
font-size: .875rem;
line-height: 1.25rem;
font-weight: 700;
color: var(--beui-foreground);
}
.be-bracket-nav {
position: absolute;
top: 50%;
z-index: 10;
display: grid;
place-items: center;
width: 2.75rem;
height: 2.75rem;
padding: 0;
border: 0;
border-radius: 999px;
background: transparent;
color: inherit;
transform: translateY(-50%);
outline: none;
cursor: pointer;
}
.be-bracket-nav-face {
display: grid;
place-items: center;
width: 2.25rem;
height: 2.25rem;
border-radius: 999px;
color: var(--beui-muted-foreground);
transition: color .15s ease-out, background-color .15s ease-out;
}
.be-bracket-nav:hover .be-bracket-nav-face { background: color-mix(in srgb, var(--beui-foreground) 10%, transparent); color: var(--beui-foreground); }
.be-bracket-nav:focus-visible .be-bracket-nav-face { outline: 2px solid var(--beui-ring); outline-offset: 2px; }
.be-bracket-nav svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.be-bracket-stage { position: relative; overflow: hidden; }
.be-bracket-round { margin: 0; padding: 0; list-style: none; }
.be-bracket-card { position: absolute; left: 0; top: 0; }
.be-bracket-connector {
position: absolute;
left: 0;
top: 0;
box-sizing: border-box;
pointer-events: none;
border: 0 solid var(--beui-border);
border-width: 1px 1px 1px 0;
border-top-right-radius: .75rem;
border-bottom-right-radius: .75rem;
}
.be-bracket-stem {
position: absolute;
left: 100%;
top: 50%;
display: block;
height: 1px;
background: var(--beui-border);
}
.be-bracket-third {
margin-top: 2rem;
border-top: 1px solid var(--beui-border);
padding-top: 1.5rem;
}
.be-bracket-third-label {
margin: 0 0 .5rem;
font-size: .875rem;
line-height: 1.25rem;
color: color-mix(in srgb, var(--beui-muted-foreground) 70%, transparent);
}
@media (prefers-reduced-motion: reduce) {
.be-bracket-nav-face { transition: none; }
}
</style>Install
Run it in a project set up with shadcn-vue. The source is copied to components/beui and its dependencies are added to your package.json. Read the shadcn-vue guide
$ bunx --bun shadcn-vue@latest add @beui-vue/knockout-bracket$ bun add beui-vueDownload the release archive to your project root, then install the local file.
$ bun add ./beui-vue-0.1.0.tgzImport the shared styles once in your application.
import KnockoutBracket from '@/components/beui/blocks/KnockoutBracket.vue'
import '@/components/beui/styles.css'API Reference
roundsTournamentRound[]The whole draw, ordered widest round first. Any single-elimination tournament fits: each round holds half the matches of the one before it (16 → 8 → 4 → 2 → 1) and `rounds[r].matches[k]` is fed by matches `2k` and `2k + 1` of the round before it. Two rounds are enough.
—initialRound?numberRound shown as the leftmost column on mount. Defaults to 1, clamped to the valid range.
1thirdPlace?TournamentMatchThird place play-off, rendered under the bracket instead of inside it.
—thirdPlaceLabel?stringHeading over `thirdPlace`. Defaults to the `thirdPlace` message ("Third place play-off").
—labels?Partial<typeof knockoutBracketMessages>Override any built-in string.
—className?string—locale?stringBCP 47 tag used to join the visible round names in the live status. Defaults to `en`.
—Related components
OTP Input
One-time-code input with a gliding focus ring, digits that roll in per slot, error shake and a success check draw.
404 / Not Found
Animated 404 pages in five styles: glitch scramble, magnetic digits, cursor spotlight, a fanning card stack and a typed terminal.
Dynamic Island
iOS-style island pill that morphs between live activity views with bouncy shell resize and blur crossfades.
Updated