feat: render double-elimination bracket
This commit is contained in:
1 parent
738d274095
commit
075fb52848
10 files changed
+2379
-65
No files matched your search
@@ -5,6 +5,9 @@ import type {
|
||||
TeamId,
|
||||
} from "@lolympus/contracts";
|
||||
import { Link } from "react-router";
|
||||
import { DoubleEliminationBracket } from "./DoubleEliminationBracket";
|
||||
import { createCompetitionBracketLayout } from "./competition-display-layout";
|
||||
import { bracketRoundLabel } from "./double-elimination-bracket-layout";
|
||||
import { RoundRobinTable } from "./RoundRobinTable";
|
||||
import { SeriesScoreCard } from "./SeriesScoreCard";
|
||||
|
||||
@@ -20,6 +23,7 @@ export function CompetitionResults({
|
||||
const seriesById = new Map(
|
||||
projection.series.map((series) => [series.seriesId, series]),
|
||||
);
|
||||
const doubleEliminationLayout = createCompetitionBracketLayout(competition);
|
||||
|
||||
return (
|
||||
<section className="mb-6 space-y-4" aria-labelledby="competition-heading">
|
||||
@@ -54,18 +58,20 @@ export function CompetitionResults({
|
||||
)}
|
||||
|
||||
{projection.rounds.length > 0 ? (
|
||||
<div className="overflow-x-auto pb-2">
|
||||
<div className="grid min-w-max auto-cols-[17rem] grid-flow-col gap-4">
|
||||
{projection.rounds.map((round) => (
|
||||
<RoundColumn
|
||||
key={`${round.stage}:${round.roundNumber ?? 0}`}
|
||||
round={round}
|
||||
seriesById={seriesById}
|
||||
teamById={teamById}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
projection.formatType === "double-elimination" &&
|
||||
doubleEliminationLayout ? (
|
||||
<DoubleEliminationBracket
|
||||
projection={projection}
|
||||
layout={doubleEliminationLayout}
|
||||
teamById={teamById}
|
||||
/>
|
||||
) : (
|
||||
<GenericRoundGrid
|
||||
rounds={projection.rounds}
|
||||
seriesById={seriesById}
|
||||
teamById={teamById}
|
||||
/>
|
||||
)
|
||||
) : (
|
||||
<p
|
||||
className="border border-dashed border-base-content/15 px-4 py-5 text-sm text-base-content/45"
|
||||
@@ -101,6 +107,34 @@ export function CompetitionResults({
|
||||
);
|
||||
}
|
||||
|
||||
function GenericRoundGrid({
|
||||
rounds,
|
||||
seriesById,
|
||||
teamById,
|
||||
}: {
|
||||
rounds: BracketRoundView[];
|
||||
seriesById: Map<
|
||||
string,
|
||||
CompetitionDetailResponse["projection"]["series"][number]
|
||||
>;
|
||||
teamById: Map<TeamId, CompetitionDetailResponse["teams"][number]>;
|
||||
}) {
|
||||
return (
|
||||
<div className="overflow-x-auto pb-2">
|
||||
<div className="grid min-w-max auto-cols-[17rem] grid-flow-col gap-4">
|
||||
{rounds.map((round) => (
|
||||
<RoundColumn
|
||||
key={`${round.stage}:${round.roundNumber ?? 0}`}
|
||||
round={round}
|
||||
seriesById={seriesById}
|
||||
teamById={teamById}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function RoundColumn({
|
||||
round,
|
||||
seriesById,
|
||||
@@ -116,7 +150,7 @@ function RoundColumn({
|
||||
return (
|
||||
<section aria-label={round.label} className="space-y-2">
|
||||
<h3 className="px-1 text-xs font-bold text-base-content/45">
|
||||
{stageLabel(round.stage, round.roundNumber)}
|
||||
{bracketRoundLabel(round.stage, round.roundNumber)}
|
||||
</h3>
|
||||
<div className="space-y-3">
|
||||
{round.seriesIds.map((seriesId) => {
|
||||
@@ -166,20 +200,3 @@ function OutcomeSummary({
|
||||
</p>
|
||||
);
|
||||
}
|
||||
|
||||
function stageLabel(stage: BracketRoundView["stage"], round?: number) {
|
||||
switch (stage) {
|
||||
case "pair":
|
||||
return "대진";
|
||||
case "round-robin":
|
||||
return `${round ?? 1}라운드`;
|
||||
case "upper":
|
||||
return `승자조 ${round ?? 1}라운드`;
|
||||
case "lower":
|
||||
return `패자조 ${round ?? 1}라운드`;
|
||||
case "grand-final":
|
||||
return "그랜드 파이널";
|
||||
case "reset-final":
|
||||
return "리셋 파이널";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user