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:
1 parent
03e88a03bc
commit
b115072005
8 files changed
+761
-165
No files matched your search
@@ -15,6 +15,8 @@ import {
|
||||
createCompetitionBracketLayout,
|
||||
} from "../src/components/competition/competition-display-layout.ts";
|
||||
import {
|
||||
bracketRoundAccessibleLabel,
|
||||
bracketRoundLabel,
|
||||
createDoubleEliminationBracketLayout,
|
||||
DOUBLE_ELIMINATION_BRACKET_GEOMETRY,
|
||||
} 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");
|
||||
});
|
||||
|
||||
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", () => {
|
||||
assert.equal(MATCH_PAGE_MAX_WIDTH_CLASS, "max-w-5xl");
|
||||
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", () => {
|
||||
const { projection } = eightTeamProjection();
|
||||
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", () => {
|
||||
const { projection, ids } = eightTeamProjection({ shuffled: true });
|
||||
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.notEqual(route.label.trim(), "");
|
||||
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);
|
||||
|
||||
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(
|
||||
layout: NonNullable<ReturnType<typeof createDoubleEliminationBracketLayout>>,
|
||||
id: SeriesId,
|
||||
|
||||
Reference in new issue
Block a user