diff --git a/apps/web/src/components/competition/DoubleEliminationBracket.tsx b/apps/web/src/components/competition/DoubleEliminationBracket.tsx index d7d6a19d..291395be 100644 --- a/apps/web/src/components/competition/DoubleEliminationBracket.tsx +++ b/apps/web/src/components/competition/DoubleEliminationBracket.tsx @@ -1,16 +1,26 @@ import type { CompetitionTeamView, DoubleEliminationCompetitionProjection, + SeriesId, TeamId, } from "@lolympus/contracts"; +import { useCallback, useEffect, useId, useRef, useState } from "react"; import type { BracketConnectorKind, DoubleEliminationBracketLayout, } 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 { DoubleEliminationMobileBracket } from "./DoubleEliminationMobileBracket"; import { SeriesScoreCard } from "./SeriesScoreCard"; +import { getSeriesScoreCardAccessibleLabel } from "./series-score-card-model"; export function DoubleEliminationBracket({ projection, @@ -52,154 +62,256 @@ function DesktopBracket({ const nodeById = new Map(layout.nodes.map((node) => [node.seriesId, node])); const finalNodes = layout.nodes.filter(({ lane }) => lane === "final"); const hasResetRoute = layout.connectors.some(({ kind }) => kind === "reset"); + const bracketInstructionsId = useId(); + const scrollViewportRef = useRef(null); + const [hoveredSeriesId, setHoveredSeriesId] = useState(null); + const [focusedSeriesId, setFocusedSeriesId] = useState(null); + const [overflowCues, setOverflowCues] = useState({ + 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( 0, 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 (
-

+

승자조와 패자조는 같은 시간축을 공유하며 오른쪽 결승에서 합류합니다. 화면에 모두 보이지 않으면 가로로 스크롤하세요. + + 경기 카드에 마우스를 올리거나 Tab 키로 초점을 맞추면 연결 경로가 + 강조됩니다. +

-
+
updateOverflowCues(event.currentTarget)} > - - - {finalNodes.length > 0 && ( -
+ ); @@ -221,7 +333,7 @@ function LaneBand({ return ( <>