feat: polish double-elimination bracket navigation

Highlight connected routes, add readable round labels and accessible path descriptions, widen routing gaps, and centralize brand colors for winner progression.
This commit is contained in:
dahyeon committed 2026-07-13 23:17:19 -07:00
1 parent 03e88a03bc
commit b115072005
8 files changed
+761 -165

No files matched your search

@@ -1,16 +1,26 @@
import type { import type {
CompetitionTeamView, CompetitionTeamView,
DoubleEliminationCompetitionProjection, DoubleEliminationCompetitionProjection,
SeriesId,
TeamId, TeamId,
} from "@lolympus/contracts"; } from "@lolympus/contracts";
import { useCallback, useEffect, useId, useRef, useState } from "react";
import type { import type {
BracketConnectorKind, BracketConnectorKind,
DoubleEliminationBracketLayout, DoubleEliminationBracketLayout,
} from "./double-elimination-bracket-layout"; } from "./double-elimination-bracket-layout";
import { DOUBLE_ELIMINATION_BRACKET_GEOMETRY } from "./double-elimination-bracket-layout"; import { DOUBLE_ELIMINATION_BRACKET_GEOMETRY } from "./double-elimination-bracket-layout";
import {
bracketConnectorKey,
getBracketConnectorColorClass,
getBracketFocusState,
getHorizontalOverflowCues,
type HorizontalOverflowCues,
} from "./double-elimination-bracket-interaction";
import { DOUBLE_ELIMINATION_BRACKET_VIEWPORT_CLASS } from "./competition-display-layout"; import { DOUBLE_ELIMINATION_BRACKET_VIEWPORT_CLASS } from "./competition-display-layout";
import { DoubleEliminationMobileBracket } from "./DoubleEliminationMobileBracket"; import { DoubleEliminationMobileBracket } from "./DoubleEliminationMobileBracket";
import { SeriesScoreCard } from "./SeriesScoreCard"; import { SeriesScoreCard } from "./SeriesScoreCard";
import { getSeriesScoreCardAccessibleLabel } from "./series-score-card-model";
export function DoubleEliminationBracket({ export function DoubleEliminationBracket({
projection, projection,
@@ -52,154 +62,256 @@ function DesktopBracket({
const nodeById = new Map(layout.nodes.map((node) => [node.seriesId, node])); const nodeById = new Map(layout.nodes.map((node) => [node.seriesId, node]));
const finalNodes = layout.nodes.filter(({ lane }) => lane === "final"); const finalNodes = layout.nodes.filter(({ lane }) => lane === "final");
const hasResetRoute = layout.connectors.some(({ kind }) => kind === "reset"); const hasResetRoute = layout.connectors.some(({ kind }) => kind === "reset");
const bracketInstructionsId = useId();
const scrollViewportRef = useRef<HTMLDivElement>(null);
const [hoveredSeriesId, setHoveredSeriesId] = useState<SeriesId | null>(null);
const [focusedSeriesId, setFocusedSeriesId] = useState<SeriesId | null>(null);
const [overflowCues, setOverflowCues] = useState<HorizontalOverflowCues>({
showStart: false,
showEnd: false,
});
const activeSeriesId = focusedSeriesId ?? hoveredSeriesId;
const focusState = getBracketFocusState(layout.connectors, activeSeriesId);
const roundGuideXs = Array.from(
new Set(layout.rounds.map((round) => round.x)),
);
const finalZoneLeft = Math.max( const finalZoneLeft = Math.max(
0, 0,
Math.min(...finalNodes.map(({ x }) => x), layout.width) - 16, Math.min(...finalNodes.map(({ x }) => x), layout.width) - 16,
); );
const updateOverflowCues = useCallback((viewport: HTMLDivElement) => {
const next = getHorizontalOverflowCues(viewport);
setOverflowCues((current) =>
current.showStart === next.showStart && current.showEnd === next.showEnd
? current
: next,
);
}, []);
useEffect(() => {
const viewport = scrollViewportRef.current;
if (!viewport) return;
const update = () => updateOverflowCues(viewport);
update();
window.addEventListener("resize", update);
return () => window.removeEventListener("resize", update);
}, [layout.width, updateOverflowCues]);
return ( return (
<div <div
className={`hidden xl:block ${DOUBLE_ELIMINATION_BRACKET_VIEWPORT_CLASS}`} className={`hidden xl:block ${DOUBLE_ELIMINATION_BRACKET_VIEWPORT_CLASS}`}
> >
<div className="mb-2 flex flex-wrap items-center justify-between gap-3 text-xs text-content-muted"> <div className="mb-2 flex flex-wrap items-center justify-between gap-3 text-xs text-content-muted">
<p> <p id={bracketInstructionsId}>
승자조와 패자조는 같은 시간축을 공유하며 오른쪽 결승에서 합류합니다. 승자조와 패자조는 같은 시간축을 공유하며 오른쪽 결승에서 합류합니다.
<span className="ml-2 text-content-subtle"> <span className="ml-2 text-content-subtle">
화면에 모두 보이지 않으면 가로로 스크롤하세요. 화면에 모두 보이지 않으면 가로로 스크롤하세요.
</span> </span>
<span className="ml-2 text-content-subtle">
경기 카드에 마우스를 올리거나 Tab 키로 초점을 맞추면 연결 경로가
강조됩니다.
</span>
</p> </p>
<ConnectorLegend showReset={hasResetRoute} /> <ConnectorLegend showReset={hasResetRoute} />
</div> </div>
<div <div className="relative">
className="overflow-x-auto border-y border-base-content/10 bg-base-100 pb-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary"
role="region"
aria-label="더블 엘리미네이션 대진표"
tabIndex={0}
>
<div <div
className="relative" ref={scrollViewportRef}
style={{ width: layout.width, height: layout.height }} className="overflow-x-auto border-y border-base-content/10 bg-base-100 pb-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary"
role="region"
aria-label="더블 엘리미네이션 대진표"
aria-describedby={bracketInstructionsId}
tabIndex={0}
onScroll={(event) => updateOverflowCues(event.currentTarget)}
> >
<LaneBand <div
label="승자조" className="relative"
description="패배 시 패자조 이동" style={{ width: layout.width, height: layout.height }}
top={layout.upperLane.top}
height={layout.upperLane.height}
width={layout.width}
/>
<LaneBand
label="패자조"
description="패배 시 탈락"
top={layout.lowerLane.top}
height={layout.lowerLane.height}
width={layout.width}
/>
{finalNodes.length > 0 && (
<div
className="absolute border-l border-primary/15 bg-primary/[0.025]"
style={{
left: finalZoneLeft,
top: 0,
width: layout.width - finalZoneLeft,
height: layout.height,
}}
aria-hidden="true"
/>
)}
<svg
className="pointer-events-none absolute inset-0 z-[1]"
width={layout.width}
height={layout.height}
viewBox={`0 0 ${layout.width} ${layout.height}`}
aria-hidden="true"
focusable="false"
> >
{layout.connectors.map((connector) => ( <LaneBand
<g label="승자조"
key={`${connector.fromSeriesId}:${connector.select}:${connector.toSeriesId}:${connector.toSlot}`} description="패배 시 패자조 이동"
className={connectorClass(connector.kind)} top={layout.upperLane.top}
> height={layout.upperLane.height}
<path width={layout.width}
d={connector.path} />
fill="none" <LaneBand
stroke="var(--color-base-100)" label="패자조"
strokeWidth="4" description="패배 시 탈락"
strokeLinecap="round" top={layout.lowerLane.top}
strokeLinejoin="round" height={layout.lowerLane.height}
vectorEffect="non-scaling-stroke" width={layout.width}
/> />
<path {finalNodes.length > 0 && (
d={connector.path} <div
fill="none" className="absolute border-l border-primary/20 bg-primary/[0.04]"
stroke="currentColor"
strokeWidth="1.25"
strokeDasharray={connectorDash(connector.kind)}
strokeLinecap="round"
strokeLinejoin="round"
vectorEffect="non-scaling-stroke"
/>
<circle
cx={connector.targetX}
cy={connector.targetY}
r="2.25"
fill="currentColor"
/>
</g>
))}
</svg>
{layout.rounds.map((round) => (
<section
key={`${round.stage}:${round.roundNumber}`}
aria-labelledby={`competition-round-${round.stage}-${round.roundNumber}`}
>
<h3
id={`competition-round-${round.stage}-${round.roundNumber}`}
className="absolute z-[2] truncate px-1 text-xs font-bold text-content-muted"
style={{ style={{
left: round.x, left: finalZoneLeft,
top: round.labelY, top: 0,
width: DOUBLE_ELIMINATION_BRACKET_GEOMETRY.columnWidth, width: layout.width - finalZoneLeft,
height: layout.height,
}} }}
> aria-hidden="true"
{round.label} />
</h3> )}
{round.seriesIds.map((seriesId) => { {roundGuideXs.map((x) => (
const node = nodeById.get(seriesId); <div
const series = seriesById.get(seriesId); key={x}
if (!node || !series) return null; className="absolute top-0 border-l border-base-content/[0.045]"
const routes = layout.connectors.filter( style={{
(connector) => connector.fromSeriesId === node.seriesId, left: Math.max(
); 0,
x - DOUBLE_ELIMINATION_BRACKET_GEOMETRY.columnGap / 2,
),
height: layout.height,
}}
aria-hidden="true"
/>
))}
<svg
className="pointer-events-none absolute inset-0 z-[1]"
width={layout.width}
height={layout.height}
viewBox={`0 0 ${layout.width} ${layout.height}`}
aria-hidden="true"
focusable="false"
>
{layout.connectors.map((connector) => {
const connectorKey = bracketConnectorKey(connector);
const isFocused = focusState.connectorKeys.has(connectorKey);
return ( return (
<div <g
key={node.seriesId} key={connectorKey}
className="absolute z-[3]" className={getBracketConnectorColorClass(
style={{ connector.kind,
left: node.x, isFocused,
top: node.y,
width: node.width,
minHeight: node.height,
}}
>
<SeriesScoreCard
series={series}
displayLabel={node.label}
teamById={teamById}
variant="bracket"
/>
{routes.length > 0 && (
<span className="sr-only">
{routes.map(({ label }) => label).join(". ")}
</span>
)} )}
</div> >
<path
d={connector.path}
fill="none"
stroke="var(--color-base-100)"
strokeWidth={isFocused ? 5 : 4}
strokeLinecap="round"
strokeLinejoin="round"
vectorEffect="non-scaling-stroke"
/>
<path
d={connector.path}
fill="none"
stroke="currentColor"
strokeWidth={isFocused ? 2 : 1.5}
strokeDasharray={connectorDash(connector.kind)}
strokeLinecap="round"
strokeLinejoin="round"
vectorEffect="non-scaling-stroke"
/>
<circle
cx={connector.targetX}
cy={connector.targetY}
r={isFocused ? 3 : 2.5}
fill="currentColor"
/>
</g>
); );
})} })}
</section> </svg>
))}
{layout.rounds.map((round) => (
<section
key={`${round.stage}:${round.roundNumber}`}
aria-labelledby={`${bracketInstructionsId}-round-${round.stage}-${round.roundNumber}`}
>
<h3
id={`${bracketInstructionsId}-round-${round.stage}-${round.roundNumber}`}
aria-label={round.accessibleLabel}
className={`absolute z-[2] truncate border-l-2 px-2 text-xs font-bold ${round.lane === "final" ? "border-primary/45 text-base-content" : "border-base-content/15 text-content-muted"}`}
style={{
left: round.x,
top: round.labelY,
width: DOUBLE_ELIMINATION_BRACKET_GEOMETRY.columnWidth,
}}
>
{round.label}
</h3>
{round.seriesIds.map((seriesId, seriesIndex) => {
const node = nodeById.get(seriesId);
const series = seriesById.get(seriesId);
if (!node || !series) return null;
const relatedRoutes = layout.connectors.filter(
(connector) =>
connector.fromSeriesId === node.seriesId ||
connector.toSeriesId === node.seriesId,
);
const routeDescriptionId = `${bracketInstructionsId}-${round.stage}-${round.roundNumber}-${seriesIndex}`;
const isFocused = activeSeriesId === node.seriesId;
const isRelated = focusState.seriesIds.has(node.seriesId);
const accessibilityLabel = getSeriesScoreCardAccessibleLabel(
series,
node.accessibleLabel,
teamById,
);
return (
<div
key={node.seriesId}
className={`absolute z-[3] focus-visible:z-[4] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary ${isFocused ? "z-[4] ring-2 ring-primary/55" : isRelated ? "z-[4] ring-1 ring-base-content/30" : node.lane === "final" ? "outline outline-1 outline-primary/25" : ""}`}
style={{
left: node.x,
top: node.y,
width: node.width,
minHeight: node.height,
}}
role="group"
aria-label={accessibilityLabel}
aria-describedby={
relatedRoutes.length > 0 ? routeDescriptionId : undefined
}
tabIndex={0}
onMouseEnter={() => setHoveredSeriesId(node.seriesId)}
onMouseLeave={() =>
setHoveredSeriesId((current) =>
current === node.seriesId ? null : current,
)
}
onFocus={() => setFocusedSeriesId(node.seriesId)}
onBlur={(event) => {
if (!event.currentTarget.contains(event.relatedTarget)) {
setFocusedSeriesId((current) =>
current === node.seriesId ? null : current,
);
}
}}
>
<SeriesScoreCard
series={series}
displayLabel={node.label}
teamById={teamById}
variant="bracket"
accessibilityLabel={accessibilityLabel}
/>
{relatedRoutes.length > 0 && (
<span id={routeDescriptionId} className="sr-only">
{relatedRoutes
.map(({ accessibleLabel }) => accessibleLabel)
.join(". ")}
</span>
)}
</div>
);
})}
</section>
))}
</div>
</div> </div>
<div
className={`pointer-events-none absolute inset-y-px left-0 z-[5] w-8 bg-linear-to-r from-base-100 to-transparent transition-opacity duration-150 motion-reduce:transition-none ${overflowCues.showStart ? "opacity-100" : "opacity-0"}`}
aria-hidden="true"
/>
<div
className={`pointer-events-none absolute inset-y-px right-0 z-[5] w-8 bg-linear-to-l from-base-100 to-transparent transition-opacity duration-150 motion-reduce:transition-none ${overflowCues.showEnd ? "opacity-100" : "opacity-0"}`}
aria-hidden="true"
/>
</div> </div>
</div> </div>
); );
@@ -221,7 +333,7 @@ function LaneBand({
return ( return (
<> <>
<div <div
className="absolute border-y border-base-content/8 bg-base-content/[0.018]" className="absolute border-y border-base-content/10 bg-base-content/[0.03]"
style={{ top: top - 6, width, height: height + 12 }} style={{ top: top - 6, width, height: height + 12 }}
aria-hidden="true" aria-hidden="true"
/> />
@@ -240,7 +352,11 @@ function LaneBand({
function ConnectorLegend({ showReset }: { showReset: boolean }) { function ConnectorLegend({ showReset }: { showReset: boolean }) {
return ( return (
<div className="flex flex-wrap items-center gap-4" aria-label="연결선 범례"> <div
className="flex flex-wrap items-center gap-4"
role="group"
aria-label="연결선 범례"
>
<LegendItem label="승자 진출" kind="winner" /> <LegendItem label="승자 진출" kind="winner" />
<LegendItem label="패자조 이동" kind="loser" /> <LegendItem label="패자조 이동" kind="loser" />
{showReset && <LegendItem label="리셋 대진 유지" kind="reset" />} {showReset && <LegendItem label="리셋 대진 유지" kind="reset" />}
@@ -264,7 +380,7 @@ function LegendItem({
stroke="currentColor" stroke="currentColor"
strokeWidth="1.25" strokeWidth="1.25"
strokeDasharray={connectorDash(kind)} strokeDasharray={connectorDash(kind)}
className={connectorClass(kind)} className={getBracketConnectorColorClass(kind)}
/> />
</svg> </svg>
{label} {label}
@@ -272,12 +388,6 @@ function LegendItem({
); );
} }
function connectorClass(kind: BracketConnectorKind): string {
if (kind === "loser") return "text-warning/65";
if (kind === "reset") return "text-primary/55";
return "text-base-content/30";
}
function connectorDash(kind: BracketConnectorKind): string | undefined { function connectorDash(kind: BracketConnectorKind): string | undefined {
if (kind === "loser") return "6 5"; if (kind === "loser") return "6 5";
if (kind === "reset") return "2 5"; if (kind === "reset") return "2 5";
@@ -4,8 +4,10 @@ import type {
SeriesId, SeriesId,
TeamId, TeamId,
} from "@lolympus/contracts"; } from "@lolympus/contracts";
import { useId } from "react";
import type { DoubleEliminationBracketLayout } from "./double-elimination-bracket-layout"; import type { DoubleEliminationBracketLayout } from "./double-elimination-bracket-layout";
import { SeriesScoreCard } from "./SeriesScoreCard"; import { SeriesScoreCard } from "./SeriesScoreCard";
import { getSeriesScoreCardAccessibleLabel } from "./series-score-card-model";
export function DoubleEliminationMobileBracket({ export function DoubleEliminationMobileBracket({
projection, projection,
@@ -16,6 +18,7 @@ export function DoubleEliminationMobileBracket({
layout: DoubleEliminationBracketLayout; layout: DoubleEliminationBracketLayout;
teamById: ReadonlyMap<TeamId, CompetitionTeamView>; teamById: ReadonlyMap<TeamId, CompetitionTeamView>;
}) { }) {
const bracketId = useId();
const seriesById = new Map( const seriesById = new Map(
projection.series.map((series) => [series.seriesId, series]), projection.series.map((series) => [series.seriesId, series]),
); );
@@ -53,9 +56,15 @@ export function DoubleEliminationMobileBracket({
); );
if (groups.length === 0) return null; if (groups.length === 0) return null;
return ( return (
<section key={section.key} aria-labelledby={`bracket-${section.key}`}> <section
key={section.key}
aria-labelledby={`${bracketId}-${section.key}`}
>
<div className="mb-3 border-b border-base-content/10 pb-2"> <div className="mb-3 border-b border-base-content/10 pb-2">
<h3 id={`bracket-${section.key}`} className="text-sm font-bold"> <h3
id={`${bracketId}-${section.key}`}
className="text-sm font-bold"
>
{section.title} {section.title}
</h3> </h3>
<p className="mt-0.5 text-xs text-content-muted"> <p className="mt-0.5 text-xs text-content-muted">
@@ -66,24 +75,40 @@ export function DoubleEliminationMobileBracket({
{groups.map((group) => ( {groups.map((group) => (
<section <section
key={`${group.stage}:${group.roundNumber}`} key={`${group.stage}:${group.roundNumber}`}
aria-label={group.label} aria-labelledby={`${bracketId}-${group.stage}-${group.roundNumber}`}
> >
<h4 className="mb-2 text-xs font-bold text-content-muted"> <h4
id={`${bracketId}-${group.stage}-${group.roundNumber}`}
className="mb-2 text-xs font-bold text-content-muted"
aria-label={group.accessibleLabel}
>
{group.label} {group.label}
</h4> </h4>
<div className="space-y-3"> <div className="space-y-3">
{group.seriesIds.map((seriesId) => { {group.seriesIds.map((seriesId) => {
const series = seriesById.get(seriesId); const series = seriesById.get(seriesId);
if (!series) return null; if (!series) return null;
const node = nodeById.get(seriesId);
const accessibilityLabel =
getSeriesScoreCardAccessibleLabel(
series,
node?.accessibleLabel,
teamById,
);
return ( return (
<div key={seriesId}> <div key={seriesId}>
<SeriesScoreCard <SeriesScoreCard
series={series} series={series}
displayLabel={nodeById.get(seriesId)?.label} displayLabel={node?.label}
teamById={teamById} teamById={teamById}
variant="bracket" variant="bracket"
accessibilityLabel={accessibilityLabel}
/>
<MobileRoutes
layout={layout}
seriesId={seriesId}
seriesLabel={node?.accessibleLabel ?? "경기"}
/> />
<MobileRoutes layout={layout} seriesId={seriesId} />
</div> </div>
); );
})} })}
@@ -101,19 +126,25 @@ export function DoubleEliminationMobileBracket({
function MobileRoutes({ function MobileRoutes({
layout, layout,
seriesId, seriesId,
seriesLabel,
}: { }: {
layout: DoubleEliminationBracketLayout; layout: DoubleEliminationBracketLayout;
seriesId: SeriesId; seriesId: SeriesId;
seriesLabel: string;
}) { }) {
const routes = layout.connectors.filter( const routes = layout.connectors.filter(
(connector) => connector.fromSeriesId === seriesId, (connector) => connector.fromSeriesId === seriesId,
); );
if (routes.length === 0) return null; if (routes.length === 0) return null;
return ( return (
<ul className="mt-1.5 space-y-0.5 border-l border-base-content/10 pl-2 text-[11px] text-content-muted"> <ul
className="mt-1.5 space-y-0.5 border-l border-base-content/10 pl-2 text-[11px] text-content-muted"
aria-label={`${seriesLabel} 연결 경로`}
>
{routes.map((route) => ( {routes.map((route) => (
<li key={`${route.select}:${route.toSeriesId}:${route.toSlot}`}> <li key={`${route.select}:${route.toSeriesId}:${route.toSlot}`}>
{route.label} <span aria-hidden="true">{route.label}</span>
<span className="sr-only">{route.accessibleLabel}</span>
</li> </li>
))} ))}
</ul> </ul>
@@ -0,0 +1,85 @@
import type {
SeriesConnectorView,
SeriesId,
SeriesSlot,
} from "@lolympus/contracts";
import type { BracketConnectorKind } from "./double-elimination-bracket-layout";
export interface BracketFocusConnector {
fromSeriesId: SeriesId;
select: SeriesConnectorView["from"]["select"];
toSeriesId: SeriesId;
toSlot: SeriesSlot;
}
export interface BracketFocusState {
seriesIds: ReadonlySet<SeriesId>;
connectorKeys: ReadonlySet<string>;
}
export interface HorizontalScrollMetrics {
scrollLeft: number;
scrollWidth: number;
clientWidth: number;
}
export interface HorizontalOverflowCues {
showStart: boolean;
showEnd: boolean;
}
export function bracketConnectorKey(connector: BracketFocusConnector): string {
return `${connector.fromSeriesId}:${connector.select}:${connector.toSeriesId}:${connector.toSlot}`;
}
export function getBracketConnectorColorClass(
kind: BracketConnectorKind,
focused = false,
): string {
if (kind === "winner") return "text-bracket-winner";
return focused ? "text-base-content" : "text-base-content/55";
}
export function getBracketFocusState(
connectors: readonly BracketFocusConnector[],
activeSeriesId: SeriesId | null,
): BracketFocusState {
if (!activeSeriesId) {
return {
seriesIds: new Set(),
connectorKeys: new Set(),
};
}
const seriesIds = new Set<SeriesId>([activeSeriesId]);
const connectorKeys = new Set<string>();
for (const connector of connectors) {
if (
connector.fromSeriesId !== activeSeriesId &&
connector.toSeriesId !== activeSeriesId
) {
continue;
}
seriesIds.add(connector.fromSeriesId);
seriesIds.add(connector.toSeriesId);
connectorKeys.add(bracketConnectorKey(connector));
}
return { seriesIds, connectorKeys };
}
export function getHorizontalOverflowCues({
scrollLeft,
scrollWidth,
clientWidth,
}: HorizontalScrollMetrics): HorizontalOverflowCues {
const threshold = 1;
const maxScrollLeft = Math.max(0, scrollWidth - clientWidth);
if (maxScrollLeft <= threshold) {
return { showStart: false, showEnd: false };
}
return {
showStart: scrollLeft > threshold,
showEnd: scrollLeft < maxScrollLeft - threshold,
};
}
@@ -16,7 +16,7 @@ export type BracketConnectorKind = "winner" | "loser" | "reset";
export const DOUBLE_ELIMINATION_BRACKET_GEOMETRY = { export const DOUBLE_ELIMINATION_BRACKET_GEOMETRY = {
boardPadding: 12, boardPadding: 12,
columnWidth: 228, columnWidth: 228,
columnGap: 32, columnGap: 40,
cardBorderWidth: SERIES_SCORE_CARD_GEOMETRY.borderWidth, cardBorderWidth: SERIES_SCORE_CARD_GEOMETRY.borderWidth,
cardHeight: SERIES_SCORE_CARD_GEOMETRY.height, cardHeight: SERIES_SCORE_CARD_GEOMETRY.height,
cardHeaderHeight: SERIES_SCORE_CARD_GEOMETRY.headerHeight, cardHeaderHeight: SERIES_SCORE_CARD_GEOMETRY.headerHeight,
@@ -29,6 +29,7 @@ export const DOUBLE_ELIMINATION_BRACKET_GEOMETRY = {
export interface BracketNodeLayout { export interface BracketNodeLayout {
seriesId: SeriesId; seriesId: SeriesId;
label: string; label: string;
accessibleLabel: string;
stage: BracketStage; stage: BracketStage;
roundNumber: number; roundNumber: number;
lane: BracketLane; lane: BracketLane;
@@ -52,6 +53,7 @@ export interface BracketConnectorLayout {
targetY: number; targetY: number;
path: string; path: string;
label: string; label: string;
accessibleLabel: string;
} }
export interface DoubleEliminationBracketConfiguration { export interface DoubleEliminationBracketConfiguration {
@@ -63,6 +65,7 @@ export interface BracketRoundLayout {
stage: BracketStage; stage: BracketStage;
roundNumber: number; roundNumber: number;
label: string; label: string;
accessibleLabel: string;
lane: BracketLane; lane: BracketLane;
column: number; column: number;
x: number; x: number;
@@ -74,6 +77,7 @@ export interface MobileBracketGroup {
stage: BracketStage; stage: BracketStage;
roundNumber: number; roundNumber: number;
label: string; label: string;
accessibleLabel: string;
seriesIds: SeriesId[]; seriesIds: SeriesId[];
} }
@@ -101,6 +105,7 @@ interface NormalizedRound {
stage: BracketStage; stage: BracketStage;
roundNumber: number; roundNumber: number;
label: string; label: string;
accessibleLabel: string;
seriesIds: SeriesId[]; seriesIds: SeriesId[];
} }
@@ -169,13 +174,30 @@ export function createDoubleEliminationBracketLayout(
export function bracketRoundLabel( export function bracketRoundLabel(
stage: SeriesStageType, stage: SeriesStageType,
roundNumber?: number, roundNumber?: number,
): string {
return formatBracketRoundLabel(stage, roundNumber, "R");
}
export function bracketRoundAccessibleLabel(
stage: SeriesStageType,
roundNumber?: number,
): string {
return formatBracketRoundLabel(stage, roundNumber, "라운드");
}
function formatBracketRoundLabel(
stage: SeriesStageType,
roundNumber: number | undefined,
roundUnit: "R" | "라운드",
): string { ): string {
const round = roundNumber ?? 1; const round = roundNumber ?? 1;
switch (stage) { switch (stage) {
case "upper": case "upper":
return round === 1 ? `브래킷 1R` : `브래킷 상위 ${round}R`; return round === 1
? `브래킷 1${roundUnit}`
: `브래킷 상위 ${round}${roundUnit}`;
case "lower": case "lower":
return `브래킷 하위 ${round}R`; return `브래킷 하위 ${round}${roundUnit}`;
case "grand-final": case "grand-final":
return "그랜드 파이널"; return "그랜드 파이널";
case "reset-final": case "reset-final":
@@ -311,6 +333,10 @@ function normalizeRounds(
stage: round.stage, stage: round.stage,
roundNumber: round.roundNumber, roundNumber: round.roundNumber,
label: bracketRoundLabel(round.stage, round.roundNumber), label: bracketRoundLabel(round.stage, round.roundNumber),
accessibleLabel: bracketRoundAccessibleLabel(
round.stage,
round.roundNumber,
),
seriesIds: ids, seriesIds: ids,
}); });
} }
@@ -461,7 +487,12 @@ function buildNodes(
(laneGeometry.height * (index + 0.5)) / round.seriesIds.length; (laneGeometry.height * (index + 0.5)) / round.seriesIds.length;
result.push({ result.push({
seriesId, seriesId,
label: seriesName(graph.seriesById.get(seriesId), round), label: seriesDisplayName(round, seriesId, round.label),
accessibleLabel: seriesDisplayName(
round,
seriesId,
round.accessibleLabel,
),
stage: round.stage, stage: round.stage,
roundNumber: round.roundNumber, roundNumber: round.roundNumber,
lane, lane,
@@ -571,7 +602,8 @@ function buildConnectors(
targetX, targetX,
targetY, targetY,
path: `M ${number(sourceX)} ${number(sourceY)} H ${number(verticalX)} V ${number(targetY)} H ${number(targetX)}`, path: `M ${number(sourceX)} ${number(sourceY)} H ${number(verticalX)} V ${number(targetY)} H ${number(targetX)}`,
label: connectorLabel(connector, graph), label: connectorLabel(connector, graph, "label"),
accessibleLabel: connectorLabel(connector, graph, "accessibleLabel"),
}); });
} }
return result.sort( return result.sort(
@@ -593,13 +625,20 @@ function buildConnectors(
function connectorLabel( function connectorLabel(
connector: SeriesConnectorView, connector: SeriesConnectorView,
graph: ValidatedGraph, graph: ValidatedGraph,
labelKey: "label" | "accessibleLabel",
): string { ): string {
const source = graph.seriesById.get(connector.from.seriesId);
const target = graph.seriesById.get(connector.to.seriesId);
const sourceRound = graph.roundBySeriesId.get(connector.from.seriesId); const sourceRound = graph.roundBySeriesId.get(connector.from.seriesId);
const targetRound = graph.roundBySeriesId.get(connector.to.seriesId); const targetRound = graph.roundBySeriesId.get(connector.to.seriesId);
const sourceName = seriesName(source, sourceRound); const sourceName = seriesDisplayName(
const targetName = seriesName(target, targetRound); sourceRound,
connector.from.seriesId,
sourceRound?.[labelKey],
);
const targetName = seriesDisplayName(
targetRound,
connector.to.seriesId,
targetRound?.[labelKey],
);
const selection = const selection =
connector.from.select === "winner" connector.from.select === "winner"
? "승자" ? "승자"
@@ -611,16 +650,16 @@ function connectorLabel(
return `${sourceName} ${selection} → ${targetName} ${connector.to.slot} 슬롯`; return `${sourceName} ${selection} → ${targetName} ${connector.to.slot} 슬롯`;
} }
function seriesName( function seriesDisplayName(
series: DoubleEliminationCompetitionProjection["series"][number] | undefined,
round: NormalizedRound | undefined, round: NormalizedRound | undefined,
seriesId: SeriesId,
roundLabel: string | undefined,
): string { ): string {
if (series?.code) return series.code; if (!round || !roundLabel) return "알 수 없는 경기";
if (!series || !round) return "알 수 없는 경기"; const index = round.seriesIds.indexOf(seriesId);
const index = round.seriesIds.indexOf(series.seriesId);
return round.seriesIds.length > 1 return round.seriesIds.length > 1
? `${round.label} ${index + 1}경기` ? `${roundLabel} · ${index + 1}경기`
: round.label; : roundLabel;
} }
function connectorAnchorY( function connectorAnchorY(
+16 -10
View File
@@ -8,6 +8,15 @@
dark; dark;
} }
/* ── 브랜드 원색 ──
실제 색상값은 이곳에서만 관리하고, 화면에서는 아래의 의미 토큰을 사용한다. */
@theme static {
--color-brand-coral: oklch(0.708008 0.234375 24);
--color-brand-violet: oklch(0.481934 0.285938 285);
--color-brand-gold: oklch(0.853027 0.2 90);
--color-brand-cyan: oklch(70% 0.14523 200);
}
html { html {
scrollbar-gutter: stable; scrollbar-gutter: stable;
} }
@@ -68,6 +77,7 @@ body {
--color-content-subtle: var(--lts-content-subtle); --color-content-subtle: var(--lts-content-subtle);
--color-content-muted: var(--lts-content-muted); --color-content-muted: var(--lts-content-muted);
--color-content-disabled: var(--lts-content-disabled); --color-content-disabled: var(--lts-content-disabled);
--color-bracket-winner: var(--color-brand-coral);
} }
@layer utilities { @layer utilities {
@@ -89,28 +99,24 @@ body {
} }
} }
/* ════════════════════════════════════════════════════════════ /* ── 라이트 테마 의미 색상 ── */
🎛️ 튜닝 패널 (실험용) — 값만 바꾸면 dev에서 즉시 반영(HMR).
확정되면 element로 전환한 뒤 이 블록을 통째로 제거할 것.
색은 oklch(밝기% 채도 색상) 형식.
════════════════════════════════════════════════════════════ */
[data-theme="light"] { [data-theme="light"] {
/* ── 포인트 4색 (primary 주 액션 / secondary 강조 / accent 하이라이트 / info 정보·보조) ── */ /* ── 포인트 4색 (primary 주 액션 / secondary 강조 / accent 하이라이트 / info 정보·보조) ── */
/* 코랄레드 — primary 117곳 즉시 반영 */ /* 코랄레드 — primary 117곳 즉시 반영 */
--color-primary: oklch(0.708008 0.234375 24); --color-primary: var(--color-brand-coral);
--color-primary-content: oklch(98% 0 0); /* 흰 글자 */ --color-primary-content: oklch(98% 0 0); /* 흰 글자 */
/* 바이올렛 — 버튼·뱃지·보더용 */ /* 바이올렛 — 버튼·뱃지·보더용 */
--color-secondary: oklch(0.481934 0.285938 285); --color-secondary: var(--color-brand-violet);
--color-secondary-content: oklch(98% 0 0); /* 흰 글자 */ --color-secondary-content: oklch(98% 0 0); /* 흰 글자 */
/* 골드 — 배경·보더·아이콘만. 텍스트색(text-accent)으론 쓰지 말 것 */ /* 골드 — 배경·보더·아이콘만. 텍스트색(text-accent)으론 쓰지 말 것 */
--color-accent: oklch(0.853027 0.2 90); --color-accent: var(--color-brand-gold);
--color-accent-content: oklch(22% 0.03 80); /* 어두운 글자 */ --color-accent-content: oklch(22% 0.03 80); /* 어두운 글자 */
/* 시안 — 정보·링크·보조 강조. L70이라 흰배경 텍스트는 약함 → 배경/보더 위주 */ /* 시안 — 정보·링크·보조 강조. L70이라 흰배경 텍스트는 약함 → 배경/보더 위주 */
--color-info: oklch(70% 0.14523 200); --color-info: var(--color-brand-cyan);
--color-info-content: oklch(24% 0.03 215); /* 어두운 글자 */ --color-info-content: oklch(24% 0.03 215); /* 어두운 글자 */
/* 텍스트 기본 진하기 (회색 알파의 기준색). 낮출수록 전체가 진해짐 */ /* 텍스트 기본 진하기 (회색 알파의 기준색). 낮출수록 전체가 진해짐 */
@@ -125,7 +131,7 @@ body {
/* 경기 결과 기록의 링크 강조는 양쪽 테마에서 같은 브랜드 코랄을 쓴다. /* 경기 결과 기록의 링크 강조는 양쪽 테마에서 같은 브랜드 코랄을 쓴다.
전역 dark primary는 유지해 다른 화면의 기존 색상 의미를 바꾸지 않는다. */ 전역 dark primary는 유지해 다른 화면의 기존 색상 의미를 바꾸지 않는다. */
.competition-series-history { .competition-series-history {
--color-primary: oklch(0.708008 0.234375 24); --color-primary: var(--color-brand-coral);
} }
/* ── 실시간 입찰 피드백 모션 ── /* ── 실시간 입찰 피드백 모션 ──
+75
View File
@@ -0,0 +1,75 @@
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import test from "node:test";
const stylesheet = await readFile(
new URL("../src/index.css", import.meta.url),
"utf8",
);
const BRAND_COLORS = {
coral: "oklch(0.708008 0.234375 24)",
violet: "oklch(0.481934 0.285938 285)",
gold: "oklch(0.853027 0.2 90)",
cyan: "oklch(70% 0.14523 200)",
} as const;
test("defines each brand color once as a primitive token", () => {
for (const [name, value] of Object.entries(BRAND_COLORS)) {
assert.match(
stylesheet,
new RegExp(`--color-brand-${name}: ${escapeRegExp(value)};`),
);
assert.equal(
stylesheet.split(value).length - 1,
1,
`${name} should have one literal source`,
);
}
});
test("maps the light theme semantic roles to the brand primitives", () => {
const lightTheme = cssBlocksForSelector('[data-theme="light"]');
const mappings = [
["--color-primary", "--color-brand-coral"],
["--color-secondary", "--color-brand-violet"],
["--color-accent", "--color-brand-gold"],
["--color-info", "--color-brand-cyan"],
] as const;
for (const [semanticToken, primitiveToken] of mappings) {
assert.match(
lightTheme,
new RegExp(
`${escapeRegExp(semanticToken)}: var\\(${escapeRegExp(primitiveToken)}\\);`,
),
);
}
});
test("keeps coral scopes without overriding the global dark primary", () => {
assert.match(
stylesheet,
/--color-bracket-winner: var\(--color-brand-coral\);/,
);
assert.match(
stylesheet,
/\.competition-series-history\s*{\s*--color-primary: var\(--color-brand-coral\);\s*}/,
);
const darkTheme = cssBlocksForSelector('[data-theme="dark"]');
assert.doesNotMatch(darkTheme, /--color-primary/);
});
function cssBlocksForSelector(selector: string): string {
const blocks = stylesheet.matchAll(
new RegExp(`${escapeRegExp(selector)}\\s*{([^}]*)}`, "g"),
);
const contents = [...blocks].map((match) => match[1] ?? "").join("\n");
assert.notEqual(contents, "", `${selector} should have a CSS block`);
return contents;
}
function escapeRegExp(value: string): string {
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
@@ -0,0 +1,146 @@
import assert from "node:assert/strict";
import test from "node:test";
import type { SeriesId } from "@lolympus/contracts";
import {
bracketConnectorKey,
getBracketConnectorColorClass,
getBracketFocusState,
getHorizontalOverflowCues,
type BracketFocusConnector,
} from "../src/components/competition/double-elimination-bracket-interaction.ts";
const A = seriesId("a");
const B = seriesId("b");
const C = seriesId("c");
const D = seriesId("d");
const E = seriesId("e");
const CONNECTORS: BracketFocusConnector[] = [
connector(A, "winner", B, "A"),
connector(B, "winner", C, "A"),
connector(B, "loser", D, "B"),
connector(D, "winner", E, "A"),
];
test("focuses directly incoming and outgoing routes plus adjacent matches", () => {
const focus = getBracketFocusState(CONNECTORS, B);
assert.deepEqual([...focus.seriesIds].sort(), [A, B, C, D].sort());
assert.deepEqual(
[...focus.connectorKeys].sort(),
CONNECTORS.slice(0, 3).map(bracketConnectorKey).sort(),
);
assert.equal(focus.connectorKeys.has(bracketConnectorKey(CONNECTORS[3])), false);
});
test("returns a neutral focus state when no match is active", () => {
const focus = getBracketFocusState(CONNECTORS, null);
assert.equal(focus.seriesIds.size, 0);
assert.equal(focus.connectorKeys.size, 0);
});
test("keeps both grand-final carry-over routes focused", () => {
const grandFinal = seriesId("grand-final");
const resetFinal = seriesId("reset-final");
const resetConnectors = [
connector(grandFinal, "slot-a", resetFinal, "A"),
connector(grandFinal, "slot-b", resetFinal, "B"),
];
const focus = getBracketFocusState(resetConnectors, grandFinal);
assert.deepEqual([...focus.seriesIds].sort(), [grandFinal, resetFinal].sort());
assert.equal(focus.connectorKeys.size, 2);
});
test("keeps both grand-final carry-over routes focused from the reset final", () => {
const grandFinal = seriesId("grand-final");
const resetFinal = seriesId("reset-final");
const resetConnectors = [
connector(grandFinal, "slot-b", resetFinal, "B"),
connector(grandFinal, "slot-a", resetFinal, "A"),
];
const focus = getBracketFocusState(resetConnectors, resetFinal);
assert.deepEqual([...focus.seriesIds].sort(), [grandFinal, resetFinal].sort());
assert.deepEqual(
[...focus.connectorKeys].sort(),
resetConnectors.map(bracketConnectorKey).sort(),
);
});
test("uses the brand coral for winner routes without losing patterned route semantics", () => {
assert.equal(getBracketConnectorColorClass("winner"), "text-bracket-winner");
assert.equal(
getBracketConnectorColorClass("winner", true),
"text-bracket-winner",
);
assert.equal(getBracketConnectorColorClass("loser"), "text-base-content/55");
assert.equal(
getBracketConnectorColorClass("loser", true),
"text-base-content",
);
assert.equal(getBracketConnectorColorClass("reset"), "text-base-content/55");
});
test("derives truthful horizontal overflow cues at each scroll position", () => {
assert.deepEqual(
getHorizontalOverflowCues({ scrollLeft: 0, scrollWidth: 1600, clientWidth: 1200 }),
{ showStart: false, showEnd: true },
);
assert.deepEqual(
getHorizontalOverflowCues({
scrollLeft: 200,
scrollWidth: 1600,
clientWidth: 1200,
}),
{ showStart: true, showEnd: true },
);
assert.deepEqual(
getHorizontalOverflowCues({
scrollLeft: 400,
scrollWidth: 1600,
clientWidth: 1200,
}),
{ showStart: true, showEnd: false },
);
assert.deepEqual(
getHorizontalOverflowCues({ scrollLeft: 0, scrollWidth: 1200, clientWidth: 1200 }),
{ showStart: false, showEnd: false },
);
assert.deepEqual(
getHorizontalOverflowCues({ scrollLeft: 1, scrollWidth: 1600, clientWidth: 1200 }),
{ showStart: false, showEnd: true },
);
assert.deepEqual(
getHorizontalOverflowCues({ scrollLeft: 1.01, scrollWidth: 1600, clientWidth: 1200 }),
{ showStart: true, showEnd: true },
);
assert.deepEqual(
getHorizontalOverflowCues({ scrollLeft: 399, scrollWidth: 1600, clientWidth: 1200 }),
{ showStart: true, showEnd: false },
);
assert.deepEqual(
getHorizontalOverflowCues({ scrollLeft: 398.99, scrollWidth: 1600, clientWidth: 1200 }),
{ showStart: true, showEnd: true },
);
assert.deepEqual(
getHorizontalOverflowCues({ scrollLeft: 0, scrollWidth: 1201, clientWidth: 1200 }),
{ showStart: false, showEnd: false },
);
});
function connector(
fromSeriesId: SeriesId,
select: BracketFocusConnector["select"],
toSeriesId: SeriesId,
toSlot: BracketFocusConnector["toSlot"],
): BracketFocusConnector {
return { fromSeriesId, select, toSeriesId, toSlot };
}
function seriesId(value: string): SeriesId {
return value as SeriesId;
}
@@ -15,6 +15,8 @@ import {
createCompetitionBracketLayout, createCompetitionBracketLayout,
} from "../src/components/competition/competition-display-layout.ts"; } from "../src/components/competition/competition-display-layout.ts";
import { import {
bracketRoundAccessibleLabel,
bracketRoundLabel,
createDoubleEliminationBracketLayout, createDoubleEliminationBracketLayout,
DOUBLE_ELIMINATION_BRACKET_GEOMETRY, DOUBLE_ELIMINATION_BRACKET_GEOMETRY,
} from "../src/components/competition/double-elimination-bracket-layout.ts"; } from "../src/components/competition/double-elimination-bracket-layout.ts";
@@ -84,6 +86,52 @@ test("places the canonical four-team DAG in shared time columns", () => {
assert.equal(nodeFor(layout, ids.GF).lane, "final"); assert.equal(nodeFor(layout, ids.GF).lane, "final");
}); });
test("uses compact bracket vocabulary with expanded accessible round names", () => {
assert.equal(bracketRoundLabel("upper", 1), "브래킷 1R");
assert.equal(bracketRoundLabel("upper", 2), "브래킷 상위 2R");
assert.equal(bracketRoundLabel("lower", 1), "브래킷 하위 1R");
assert.equal(bracketRoundLabel("lower", 4), "브래킷 하위 4R");
assert.equal(bracketRoundLabel("grand-final", 1), "그랜드 파이널");
assert.equal(bracketRoundLabel("reset-final", 1), "리셋 파이널");
assert.equal(bracketRoundLabel("round-robin", 3), "3라운드");
assert.equal(
bracketRoundAccessibleLabel("upper", 1),
"브래킷 1라운드",
);
assert.equal(
bracketRoundAccessibleLabel("upper", 2),
"브래킷 상위 2라운드",
);
assert.equal(
bracketRoundAccessibleLabel("lower", 1),
"브래킷 하위 1라운드",
);
assert.equal(
bracketRoundAccessibleLabel("grand-final", 1),
"그랜드 파이널",
);
assert.equal(
bracketRoundAccessibleLabel("round-robin", 3),
"3라운드",
);
const { projection } = eightTeamProjection();
const layout = requireLayout(projection, EIGHT_TEAM_LAYOUT);
const upperOpening = layout.rounds.find(
({ stage, roundNumber }) => stage === "upper" && roundNumber === 1,
);
const lowerOpening = layout.mobileGroups.find(
({ stage, roundNumber }) => stage === "lower" && roundNumber === 1,
);
assert.ok(upperOpening);
assert.ok(lowerOpening);
assert.equal(upperOpening.label, "브래킷 1R");
assert.equal(upperOpening.accessibleLabel, "브래킷 1라운드");
assert.equal(lowerOpening.label, "브래킷 하위 1R");
assert.equal(lowerOpening.accessibleLabel, "브래킷 하위 1라운드");
});
test("keeps the match page narrow and gives only the desktop bracket a wide viewport", () => { test("keeps the match page narrow and gives only the desktop bracket a wide viewport", () => {
assert.equal(MATCH_PAGE_MAX_WIDTH_CLASS, "max-w-5xl"); assert.equal(MATCH_PAGE_MAX_WIDTH_CLASS, "max-w-5xl");
assert.match(DOUBLE_ELIMINATION_BRACKET_VIEWPORT_CLASS, /max-w-\[1600px\]/); assert.match(DOUBLE_ELIMINATION_BRACKET_VIEWPORT_CLASS, /max-w-\[1600px\]/);
@@ -93,6 +141,15 @@ test("keeps the match page narrow and gives only the desktop bracket a wide view
); );
}); });
test("uses a 40px routing gap while keeping the canonical bracket inside its viewport", () => {
const { projection } = eightTeamProjection();
const layout = requireLayout(projection, EIGHT_TEAM_LAYOUT);
assert.equal(DOUBLE_ELIMINATION_BRACKET_GEOMETRY.columnGap, 40);
assert.equal(layout.columnCount, 6);
assert.equal(layout.width, 1592);
});
test("selects the bracket only for a coherent double-elimination snapshot", () => { test("selects the bracket only for a coherent double-elimination snapshot", () => {
const { projection } = eightTeamProjection(); const { projection } = eightTeamProjection();
const competition = competitionDetail(projection); const competition = competitionDetail(projection);
@@ -200,6 +257,40 @@ test("places every code-less eight-team Series once regardless of input order",
); );
}); });
test("uses human-readable match names while preserving technical Series codes", () => {
const ordered = eightTeamProjection();
const shuffled = eightTeamProjection({ shuffled: true });
for (const fixture of [ordered, shuffled]) {
for (const series of fixture.projection.series) {
series.code = `CODE-${series.seriesId}`;
}
}
const codedSeries = shuffled.projection.series.find(
(series) => series.seriesId === shuffled.ids.WB_R2_M2,
);
assert.ok(codedSeries);
codedSeries.code = "WB_R2_M2";
const orderedLayout = requireLayout(ordered.projection, EIGHT_TEAM_LAYOUT);
const shuffledLayout = requireLayout(shuffled.projection, EIGHT_TEAM_LAYOUT);
const node = nodeFor(shuffledLayout, shuffled.ids.WB_R2_M2);
const winnerRoute = shuffledLayout.connectors.find(
(route) =>
route.fromSeriesId === shuffled.ids.WB_R2_M2 && route.select === "winner",
);
assert.ok(winnerRoute);
assert.equal(node.label, "브래킷 상위 2R · 2경기");
assert.equal(node.accessibleLabel, "브래킷 상위 2라운드 · 2경기");
assert.deepEqual(labelsBySeriesId(shuffledLayout), labelsBySeriesId(orderedLayout));
assert.match(winnerRoute.label, /^브래킷 상위 2R · 2경기 승자 →/);
assert.match(
winnerRoute.accessibleLabel,
/^브래킷 상위 2라운드 · 2경기 승자 →/,
);
assert.doesNotMatch(winnerRoute.label, /WB_R2_M2/);
});
test("keeps the known WB_R2_M2 winner and loser routes keyed by opaque Series identity", () => { test("keeps the known WB_R2_M2 winner and loser routes keyed by opaque Series identity", () => {
const { projection, ids } = eightTeamProjection({ shuffled: true }); const { projection, ids } = eightTeamProjection({ shuffled: true });
const layout = requireLayout(projection, EIGHT_TEAM_LAYOUT); const layout = requireLayout(projection, EIGHT_TEAM_LAYOUT);
@@ -401,7 +492,10 @@ test("keeps connector rails distinct and outside intervening card rectangles", (
assert.equal(route.path.includes("Infinity"), false); assert.equal(route.path.includes("Infinity"), false);
assert.notEqual(route.label.trim(), ""); assert.notEqual(route.label.trim(), "");
assert.ok(target.column > source.column); assert.ok(target.column > source.column);
assert.ok(route.verticalX > target.x - 32); assert.ok(
route.verticalX >
target.x - DOUBLE_ELIMINATION_BRACKET_GEOMETRY.columnGap,
);
assert.ok(route.verticalX < target.x); assert.ok(route.verticalX < target.x);
for (const intermediate of layout.nodes) { for (const intermediate of layout.nodes) {
@@ -896,6 +990,16 @@ function columnsBySeriesId(
); );
} }
function labelsBySeriesId(
layout: NonNullable<ReturnType<typeof createDoubleEliminationBracketLayout>>,
) {
return Object.fromEntries(
layout.nodes
.map((node) => [node.seriesId, node.label] as const)
.sort(([left], [right]) => left.localeCompare(right)),
);
}
function nodeFor( function nodeFor(
layout: NonNullable<ReturnType<typeof createDoubleEliminationBracketLayout>>, layout: NonNullable<ReturnType<typeof createDoubleEliminationBracketLayout>>,
id: SeriesId, id: SeriesId,