From ddb28e95d69efd96091a81440661e4ef5766a962 Mon Sep 17 00:00:00 2001 From: "Kalle (Sendou)" <38327916+Sendouc@users.noreply.github.com> Date: Mon, 10 Jan 2022 08:53:02 +0200 Subject: [PATCH] Line generation working for losers byes --- .../tournament/EliminationBracket.tsx | 86 +++++++++++-------- app/styles/tournament-bracket.css | 9 ++ 2 files changed, 57 insertions(+), 38 deletions(-) diff --git a/app/components/tournament/EliminationBracket.tsx b/app/components/tournament/EliminationBracket.tsx index c95819acb..ea92047ec 100644 --- a/app/components/tournament/EliminationBracket.tsx +++ b/app/components/tournament/EliminationBracket.tsx @@ -35,37 +35,6 @@ export function EliminationBracket({ round.matches.length === nextRound?.matches.length; const drawStraightLines = round.matches.length === 1 || amountOfMatchesBetweenRoundsEqual; - const theKindOfLinesToDraw: ( - | undefined - | "no-line" - | "bottom-only" - | "top-only" - )[] = new Array( - amountOfMatchesBetweenRoundsEqual - ? round.matches.length - : Math.ceil(round.matches.length / 2) - ) - .fill(null) - .map((_, lineI) => { - // lines 0 1 2 3 - // rounds 0 1 2 3 4 5 6 7 - if (roundI !== 0 || round.name.includes("Losers")) { - return undefined; - } - const matchOne = round.matches[lineI * 2]; - const matchTwo = round.matches[lineI * 2 + 1]; - invariant(matchOne, "matchOne is undefined"); - invariant(matchTwo, "matchTwo is undefined"); - - if ( - matchOne.participants?.includes(null) && - matchTwo.participants?.includes(null) - ) { - return "no-line"; - } - if (matchOne.participants?.includes(null)) return "bottom-only"; - return "top-only"; - }); const style: MyCSSProperties = { "--brackets-bottom-border-length": drawStraightLines @@ -83,14 +52,9 @@ export function EliminationBracket({ >
{round.matches.map((match) => { - // TODO: handle losers return (