mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-26 09:20:24 -05:00
Fix bracket lines when bracket is compactified
This commit is contained in:
parent
3138e63004
commit
3c95f3c15c
|
|
@ -20,8 +20,22 @@ const MATCH_SPACING = MATCH_HEIGHT + GAP;
|
||||||
export function EliminationBracketSide(props: EliminationBracketSideProps) {
|
export function EliminationBracketSide(props: EliminationBracketSideProps) {
|
||||||
const rounds = getRounds({ ...props, bracketData: props.bracket.data });
|
const rounds = getRounds({ ...props, bracketData: props.bracket.data });
|
||||||
|
|
||||||
const firstRoundMatchCount = props.bracket.data.match.filter(
|
const firstRoundMatches = props.bracket.data.match.filter(
|
||||||
(match) => match.round_id === rounds[0]?.id,
|
(match) => match.round_id === rounds[0]?.id,
|
||||||
|
);
|
||||||
|
const firstRoundHasOngoing = firstRoundMatches.some(
|
||||||
|
(match) =>
|
||||||
|
match.opponent1 &&
|
||||||
|
match.opponent2 &&
|
||||||
|
match.opponent1.result !== "win" &&
|
||||||
|
match.opponent2.result !== "win",
|
||||||
|
);
|
||||||
|
const firstRoundHidden =
|
||||||
|
!props.isExpanded && rounds.length > 2 && !firstRoundHasOngoing;
|
||||||
|
|
||||||
|
const firstVisibleRoundId = firstRoundHidden ? rounds[1]?.id : rounds[0]?.id;
|
||||||
|
const firstVisibleRoundMatchCount = props.bracket.data.match.filter(
|
||||||
|
(match) => match.round_id === firstVisibleRoundId,
|
||||||
).length;
|
).length;
|
||||||
|
|
||||||
let atLeastOneColumnHidden = false;
|
let atLeastOneColumnHidden = false;
|
||||||
|
|
@ -103,7 +117,8 @@ export function EliminationBracketSide(props: EliminationBracketSideProps) {
|
||||||
if (matches.length <= 1) return undefined;
|
if (matches.length <= 1) return undefined;
|
||||||
if (nextRoundMatchCount === matches.length) return undefined;
|
if (nextRoundMatchCount === matches.length) return undefined;
|
||||||
|
|
||||||
const spreadFactor = firstRoundMatchCount / matches.length;
|
const spreadFactor =
|
||||||
|
firstVisibleRoundMatchCount / matches.length;
|
||||||
return GAP / 2 + (spreadFactor - 1) * (MATCH_SPACING / 2);
|
return GAP / 2 + (spreadFactor - 1) * (MATCH_SPACING / 2);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user