Compare commits
6
Commits
96bae0ce28
...
b115072005
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b115072005 | ||
|
|
03e88a03bc | ||
|
|
43c25c05cd | ||
|
|
dc77b37494 | ||
|
|
bb32c26694 | ||
|
|
81b951889f |
No files matched your search
@@ -93,7 +93,7 @@ function GameHistoryRowContent({
|
||||
}
|
||||
>
|
||||
<span className="font-bold text-content-muted">
|
||||
Game {game.ordinal}
|
||||
{game.ordinal}게임
|
||||
</span>
|
||||
<time
|
||||
dateTime={game.startedAt}
|
||||
|
||||
@@ -6,11 +6,14 @@ import type {
|
||||
TeamId,
|
||||
} from "@lolympus/contracts";
|
||||
import { ChevronDown } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { useLocation } from "react-router";
|
||||
import {
|
||||
createCompetitionSeriesHistory,
|
||||
formatCompetitionHistoryDate,
|
||||
formatCompetitionHistoryDayHeading,
|
||||
formatCompetitionHistoryTime,
|
||||
getSeriesHistoryRecordLabel,
|
||||
getSeriesHistoryResultLabel,
|
||||
getSeriesHistoryStatusLabel,
|
||||
shouldDisplaySeriesHistoryScore,
|
||||
type CompetitionSeriesHistoryRow,
|
||||
@@ -31,56 +34,102 @@ export function CompetitionSeriesHistory({
|
||||
teamById: ReadonlyMap<TeamId, CompetitionTeamView>;
|
||||
}) {
|
||||
const location = useLocation();
|
||||
const historyBackTo = `${location.pathname}${location.search}${location.hash}`;
|
||||
const historyPath = `${location.pathname}${location.search}`;
|
||||
const history = createCompetitionSeriesHistory(projection);
|
||||
if (history.length === 0) return null;
|
||||
const resultCount = history.reduce(
|
||||
(count, day) => count + day.rows.length,
|
||||
0,
|
||||
);
|
||||
|
||||
return (
|
||||
<section
|
||||
className="competition-series-history border border-base-content/10 bg-base-100"
|
||||
aria-labelledby="competition-series-history-heading"
|
||||
>
|
||||
<header className="border-b border-base-content/10 px-4 py-3">
|
||||
<h3
|
||||
id="competition-series-history-heading"
|
||||
className="text-sm font-bold"
|
||||
>
|
||||
경기 결과 기록
|
||||
</h3>
|
||||
<p className="mt-0.5 text-xs text-content-muted">
|
||||
진행 중인 시리즈와 종료 결과를 실제 경기 기록 순서로 보여줍니다.
|
||||
</p>
|
||||
<header className="flex flex-wrap items-start justify-between gap-4 border-b border-base-content/10 px-4 py-3">
|
||||
<div>
|
||||
<h3
|
||||
id="competition-series-history-heading"
|
||||
className="text-sm font-bold"
|
||||
>
|
||||
경기 결과 기록
|
||||
</h3>
|
||||
<p className="mt-0.5 text-xs text-content-muted">
|
||||
진행 중인 시리즈와 최종 결과를 실제 경기 기록 순서로 보여줍니다.
|
||||
</p>
|
||||
</div>
|
||||
{resultCount > 1 && (
|
||||
<a
|
||||
href="#competition-series-history-latest"
|
||||
className="inline-flex min-h-11 shrink-0 items-center gap-1 px-2 text-xs font-bold text-content-muted transition-colors hover:bg-base-content/[0.03] hover:text-base-content focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary"
|
||||
>
|
||||
최신 결과로
|
||||
<ChevronDown
|
||||
className="h-4 w-4 text-primary"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</a>
|
||||
)}
|
||||
</header>
|
||||
|
||||
<div
|
||||
className="hidden border-b border-base-content/10 bg-base-200/30 px-4 py-2 text-[11px] font-bold text-content-muted lg:grid lg:grid-cols-[minmax(0,1fr)_9rem_11rem_8rem] lg:gap-4"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<span>경기 결과</span>
|
||||
<span>라운드</span>
|
||||
<span>기록 시각 · 상태</span>
|
||||
<span className="text-right">게임 상세</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{history.map((day) => {
|
||||
const headingId = `competition-history-${day.dateKey}`;
|
||||
{history.map((day, dayIndex) => {
|
||||
const headingId = historyDayHeadingId(day.dateKey);
|
||||
const dayHeading = formatCompetitionHistoryDayHeading(
|
||||
day.dateKey,
|
||||
day.rows.length,
|
||||
);
|
||||
return (
|
||||
<section key={day.dateKey} aria-labelledby={headingId}>
|
||||
<h4
|
||||
id={headingId}
|
||||
className="border-b border-base-content/10 bg-base-200/60 px-4 py-3 text-sm font-bold"
|
||||
className="scroll-mt-24 border-b border-base-content/10 bg-base-200/60 px-4 py-3 text-sm font-bold"
|
||||
>
|
||||
{day.dateKey === "unknown" ? (
|
||||
formatCompetitionHistoryDate(day.dateKey)
|
||||
dayHeading
|
||||
) : (
|
||||
<time dateTime={day.dateKey}>
|
||||
{formatCompetitionHistoryDate(day.dateKey)}
|
||||
{dayHeading}
|
||||
</time>
|
||||
)}
|
||||
</h4>
|
||||
<ol className="divide-y divide-base-content/10">
|
||||
{day.rows.map((row) => (
|
||||
<li key={row.series.seriesId}>
|
||||
<SeriesHistoryRow
|
||||
row={row}
|
||||
teamById={teamById}
|
||||
communityId={communityId}
|
||||
matchId={matchId}
|
||||
historyBackTo={historyBackTo}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
{day.rows.map((row, rowIndex) => {
|
||||
const isLatestResult =
|
||||
dayIndex === history.length - 1 &&
|
||||
rowIndex === day.rows.length - 1;
|
||||
return (
|
||||
<li
|
||||
key={row.series.seriesId}
|
||||
id={
|
||||
isLatestResult
|
||||
? "competition-series-history-latest"
|
||||
: undefined
|
||||
}
|
||||
className={isLatestResult ? "scroll-mt-24" : undefined}
|
||||
>
|
||||
<SeriesHistoryRow
|
||||
row={row}
|
||||
teamById={teamById}
|
||||
communityId={communityId}
|
||||
matchId={matchId}
|
||||
historyPath={historyPath}
|
||||
currentHash={location.hash}
|
||||
/>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ol>
|
||||
</section>
|
||||
);
|
||||
@@ -95,31 +144,50 @@ function SeriesHistoryRow({
|
||||
teamById,
|
||||
communityId,
|
||||
matchId,
|
||||
historyBackTo,
|
||||
historyPath,
|
||||
currentHash,
|
||||
}: {
|
||||
row: CompetitionSeriesHistoryRow;
|
||||
teamById: ReadonlyMap<TeamId, CompetitionTeamView>;
|
||||
communityId: CommunityId;
|
||||
matchId: MatchId;
|
||||
historyBackTo: string;
|
||||
historyPath: string;
|
||||
currentHash: string;
|
||||
}) {
|
||||
const detailsId = seriesHistoryDetailsId(row.series.seriesId);
|
||||
const seriesHash = `#${detailsId}`;
|
||||
const [expanded, setExpanded] = useState(currentHash === seriesHash);
|
||||
|
||||
if (row.games.length === 0) {
|
||||
return (
|
||||
<SeriesSummary row={row} teamById={teamById} hasGameDetails={false} />
|
||||
<SeriesSummary
|
||||
row={row}
|
||||
teamById={teamById}
|
||||
hasGameDetails={false}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<details className="group">
|
||||
<summary className="list-none cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary [&::-webkit-details-marker]:hidden">
|
||||
<SeriesSummary row={row} teamById={teamById} hasGameDetails />
|
||||
<details
|
||||
id={detailsId}
|
||||
className="group scroll-mt-24"
|
||||
open={expanded}
|
||||
onToggle={(event) => setExpanded(event.currentTarget.open)}
|
||||
>
|
||||
<summary className="list-none cursor-pointer transition-colors hover:bg-base-content/[0.04] active:bg-base-content/[0.06] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary group-open:bg-base-content/[0.025] [&::-webkit-details-marker]:hidden">
|
||||
<SeriesSummary
|
||||
row={row}
|
||||
teamById={teamById}
|
||||
hasGameDetails
|
||||
/>
|
||||
</summary>
|
||||
<CompetitionGameHistory
|
||||
games={row.games}
|
||||
teamById={teamById}
|
||||
communityId={communityId}
|
||||
matchId={matchId}
|
||||
historyBackTo={historyBackTo}
|
||||
historyBackTo={`${historyPath}${seriesHash}`}
|
||||
/>
|
||||
</details>
|
||||
);
|
||||
@@ -136,47 +204,55 @@ function SeriesSummary({
|
||||
}) {
|
||||
const { series } = row;
|
||||
const statusLabel = getSeriesHistoryStatusLabel(series);
|
||||
const timeLabel =
|
||||
row.timestampSource === "game-start"
|
||||
? formatCompetitionHistoryTime(row.occurredAt)
|
||||
: null;
|
||||
const timeLabel = formatCompetitionHistoryTime(row.occurredAt);
|
||||
const timeKind = row.timestampSource === "game-start" ? "시작" : "결정";
|
||||
const roundLabel = bracketRoundLabel(
|
||||
series.stage.type,
|
||||
series.stage.roundNumber,
|
||||
);
|
||||
const closedRecordLabel = getSeriesHistoryRecordLabel(
|
||||
series,
|
||||
row.games.length,
|
||||
false,
|
||||
);
|
||||
|
||||
return (
|
||||
<span className="block px-4 py-3 lg:grid lg:min-h-18 lg:grid-cols-[4.5rem_5rem_9rem_minmax(0,1fr)_6.5rem] lg:items-center lg:gap-4">
|
||||
<span className="flex min-w-0 items-center gap-2 lg:contents">
|
||||
<HistoryTime
|
||||
occurredAt={row.occurredAt}
|
||||
timeLabel={timeLabel}
|
||||
/>
|
||||
<StatusLabel
|
||||
label={statusLabel}
|
||||
inProgress={series.status === "in-progress"}
|
||||
/>
|
||||
<span className="block px-4 py-3 lg:grid lg:min-h-20 lg:grid-cols-[minmax(0,1fr)_9rem_11rem_8rem] lg:items-center lg:gap-4">
|
||||
<span className="block">
|
||||
<SeriesMatchup row={row} teamById={teamById} />
|
||||
</span>
|
||||
|
||||
<span className="mt-3 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 lg:contents">
|
||||
<span className="min-w-0 break-words text-xs leading-4 text-content-muted">
|
||||
{roundLabel}
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span className="mt-3 block lg:mt-0">
|
||||
<SeriesMatchup row={row} teamById={teamById} />
|
||||
<span className="flex min-w-0 flex-wrap items-center gap-2">
|
||||
<HistoryTime
|
||||
occurredAt={row.occurredAt}
|
||||
timeKind={timeKind}
|
||||
timeLabel={timeLabel}
|
||||
/>
|
||||
<StatusLabel
|
||||
label={statusLabel}
|
||||
inProgress={series.status === "in-progress"}
|
||||
/>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span className="mt-2 flex min-h-6 items-center justify-end text-xs font-bold text-content-muted lg:mt-0">
|
||||
{hasGameDetails ? (
|
||||
<>
|
||||
<span className="group-open:hidden">{row.games.length}게임 보기</span>
|
||||
<span className="hidden group-open:inline">게임 접기</span>
|
||||
<span className="group-open:hidden">{closedRecordLabel}</span>
|
||||
<span className="hidden group-open:inline">
|
||||
{getSeriesHistoryRecordLabel(series, row.games.length, true)}
|
||||
</span>
|
||||
<ChevronDown
|
||||
className="ml-1 h-4 w-4 text-primary transition-transform group-open:rotate-180 motion-reduce:transition-none"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<span>개별 기록 없음</span>
|
||||
<span>{closedRecordLabel}</span>
|
||||
)}
|
||||
</span>
|
||||
</span>
|
||||
@@ -185,22 +261,24 @@ function SeriesSummary({
|
||||
|
||||
function HistoryTime({
|
||||
occurredAt,
|
||||
timeKind,
|
||||
timeLabel,
|
||||
}: {
|
||||
occurredAt: string;
|
||||
timeKind: "시작" | "결정";
|
||||
timeLabel: string | null;
|
||||
}) {
|
||||
return timeLabel ? (
|
||||
<time
|
||||
dateTime={occurredAt}
|
||||
className="shrink-0 font-mono text-sm font-bold tabular-nums"
|
||||
className="shrink-0 text-xs font-bold tabular-nums text-content-muted"
|
||||
>
|
||||
{timeLabel}
|
||||
{timeKind} <span className="font-mono">{timeLabel}</span>
|
||||
</time>
|
||||
) : (
|
||||
<span className="shrink-0 text-sm text-content-muted">
|
||||
<span aria-hidden="true">—</span>
|
||||
<span className="sr-only">시작 시간 기록 없음</span>
|
||||
<span className="shrink-0 text-xs font-bold text-content-muted">
|
||||
<span aria-hidden="true">{timeKind} —</span>
|
||||
<span className="sr-only">{timeKind} 시각 기록 없음</span>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -238,27 +316,36 @@ function SeriesMatchup({
|
||||
const teamAWon = isSeriesEntryWinner(row.series, entryA.teamId);
|
||||
const teamBWon = isSeriesEntryWinner(row.series, entryB.teamId);
|
||||
const showScore = shouldDisplaySeriesHistoryScore(row.series);
|
||||
const resultLabel = getSeriesHistoryResultLabel(row.series);
|
||||
const statusLabel = getSeriesHistoryStatusLabel(row.series);
|
||||
const officialWinnerTeamId =
|
||||
row.series.status === "completed" && row.series.outcome.type !== "draw"
|
||||
? row.series.outcome.winnerTeamId
|
||||
: null;
|
||||
const winnerAnnouncement = officialWinnerTeamId
|
||||
? `, ${teamName(officialWinnerTeamId, teamById)} 승`
|
||||
: "";
|
||||
const accessibleResult = showScore
|
||||
? `${teamAName} ${entryA.gameWins} 대 ${entryB.gameWins} ${teamBName}${winnerAnnouncement}`
|
||||
: `${teamAName} 대 ${teamBName}, ${getSeriesHistoryStatusLabel(row.series)}${winnerAnnouncement}`;
|
||||
const matchupAnnouncement = showScore
|
||||
? `${teamAName} ${entryA.gameWins} 대 ${entryB.gameWins} ${teamBName}`
|
||||
: `${teamAName} 대 ${teamBName}`;
|
||||
const accessibleResult = [
|
||||
matchupAnnouncement,
|
||||
resultLabel,
|
||||
officialWinnerTeamId
|
||||
? `${teamName(officialWinnerTeamId, teamById)} 승`
|
||||
: null,
|
||||
statusLabel,
|
||||
]
|
||||
.filter((part): part is string => Boolean(part))
|
||||
.join(", ");
|
||||
|
||||
return (
|
||||
<>
|
||||
<span
|
||||
className="grid grid-cols-[minmax(0,1fr)_3.5rem_minmax(0,1fr)] items-center gap-2"
|
||||
className="grid grid-cols-[minmax(0,1fr)_5rem_minmax(0,1fr)] items-center gap-2"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<TeamName name={teamAName} winner={teamAWon} align="right" />
|
||||
<span className="flex items-center justify-center gap-1 font-mono text-base font-bold tabular-nums">
|
||||
<span className="flex min-h-10 flex-col items-center justify-center">
|
||||
{showScore ? (
|
||||
<>
|
||||
<span className="flex items-center justify-center gap-1 font-mono text-base font-bold tabular-nums">
|
||||
<span
|
||||
className={
|
||||
teamAWon ? "text-base-content" : "text-content-muted"
|
||||
@@ -274,9 +361,18 @@ function SeriesMatchup({
|
||||
>
|
||||
{entryB.gameWins}
|
||||
</span>
|
||||
</>
|
||||
) : (
|
||||
<span className="text-content-disabled">—</span>
|
||||
</span>
|
||||
) : null}
|
||||
{resultLabel && (
|
||||
<span
|
||||
className={
|
||||
showScore
|
||||
? "mt-0.5 text-[11px] font-bold leading-4 text-content-muted"
|
||||
: "text-sm font-bold leading-5 text-base-content"
|
||||
}
|
||||
>
|
||||
{resultLabel}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<TeamName name={teamBName} winner={teamBWon} align="left" />
|
||||
@@ -316,3 +412,11 @@ function teamName(
|
||||
): string {
|
||||
return teamById.get(teamId)?.name ?? "알 수 없는 팀";
|
||||
}
|
||||
|
||||
function historyDayHeadingId(dateKey: string): string {
|
||||
return `competition-series-history-day-${dateKey}`;
|
||||
}
|
||||
|
||||
function seriesHistoryDetailsId(seriesId: string): string {
|
||||
return `competition-series-history-series-${seriesId}`;
|
||||
}
|
||||
@@ -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<HTMLDivElement>(null);
|
||||
const [hoveredSeriesId, setHoveredSeriesId] = useState<SeriesId | null>(null);
|
||||
const [focusedSeriesId, setFocusedSeriesId] = useState<SeriesId | null>(null);
|
||||
const [overflowCues, setOverflowCues] = useState<HorizontalOverflowCues>({
|
||||
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 (
|
||||
<div
|
||||
className={`hidden xl:block ${DOUBLE_ELIMINATION_BRACKET_VIEWPORT_CLASS}`}
|
||||
>
|
||||
<div className="mb-2 flex flex-wrap items-center justify-between gap-3 text-xs text-content-muted">
|
||||
<p>
|
||||
<p id={bracketInstructionsId}>
|
||||
승자조와 패자조는 같은 시간축을 공유하며 오른쪽 결승에서 합류합니다.
|
||||
<span className="ml-2 text-content-subtle">
|
||||
화면에 모두 보이지 않으면 가로로 스크롤하세요.
|
||||
</span>
|
||||
<span className="ml-2 text-content-subtle">
|
||||
경기 카드에 마우스를 올리거나 Tab 키로 초점을 맞추면 연결 경로가
|
||||
강조됩니다.
|
||||
</span>
|
||||
</p>
|
||||
<ConnectorLegend showReset={hasResetRoute} />
|
||||
</div>
|
||||
<div
|
||||
className="overflow-x-auto border-y border-base-content/10 bg-base-100 pb-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary"
|
||||
role="region"
|
||||
aria-label="더블 엘리미네이션 대진표"
|
||||
tabIndex={0}
|
||||
>
|
||||
<div className="relative">
|
||||
<div
|
||||
className="relative"
|
||||
style={{ width: layout.width, height: layout.height }}
|
||||
ref={scrollViewportRef}
|
||||
className="overflow-x-auto border-y border-base-content/10 bg-base-100 pb-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary"
|
||||
role="region"
|
||||
aria-label="더블 엘리미네이션 대진표"
|
||||
aria-describedby={bracketInstructionsId}
|
||||
tabIndex={0}
|
||||
onScroll={(event) => updateOverflowCues(event.currentTarget)}
|
||||
>
|
||||
<LaneBand
|
||||
label="승자조"
|
||||
description="패배 시 패자조 이동"
|
||||
top={layout.upperLane.top}
|
||||
height={layout.upperLane.height}
|
||||
width={layout.width}
|
||||
/>
|
||||
<LaneBand
|
||||
label="패자조"
|
||||
description="패배 시 탈락"
|
||||
top={layout.lowerLane.top}
|
||||
height={layout.lowerLane.height}
|
||||
width={layout.width}
|
||||
/>
|
||||
{finalNodes.length > 0 && (
|
||||
<div
|
||||
className="absolute border-l border-primary/15 bg-primary/[0.025]"
|
||||
style={{
|
||||
left: finalZoneLeft,
|
||||
top: 0,
|
||||
width: layout.width - finalZoneLeft,
|
||||
height: layout.height,
|
||||
}}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
)}
|
||||
|
||||
<svg
|
||||
className="pointer-events-none absolute inset-0 z-[1]"
|
||||
width={layout.width}
|
||||
height={layout.height}
|
||||
viewBox={`0 0 ${layout.width} ${layout.height}`}
|
||||
aria-hidden="true"
|
||||
focusable="false"
|
||||
<div
|
||||
className="relative"
|
||||
style={{ width: layout.width, height: layout.height }}
|
||||
>
|
||||
{layout.connectors.map((connector) => (
|
||||
<g
|
||||
key={`${connector.fromSeriesId}:${connector.select}:${connector.toSeriesId}:${connector.toSlot}`}
|
||||
className={connectorClass(connector.kind)}
|
||||
>
|
||||
<path
|
||||
d={connector.path}
|
||||
fill="none"
|
||||
stroke="var(--color-base-100)"
|
||||
strokeWidth="4"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
vectorEffect="non-scaling-stroke"
|
||||
/>
|
||||
<path
|
||||
d={connector.path}
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="1.25"
|
||||
strokeDasharray={connectorDash(connector.kind)}
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
vectorEffect="non-scaling-stroke"
|
||||
/>
|
||||
<circle
|
||||
cx={connector.targetX}
|
||||
cy={connector.targetY}
|
||||
r="2.25"
|
||||
fill="currentColor"
|
||||
/>
|
||||
</g>
|
||||
))}
|
||||
</svg>
|
||||
|
||||
{layout.rounds.map((round) => (
|
||||
<section
|
||||
key={`${round.stage}:${round.roundNumber}`}
|
||||
aria-labelledby={`competition-round-${round.stage}-${round.roundNumber}`}
|
||||
>
|
||||
<h3
|
||||
id={`competition-round-${round.stage}-${round.roundNumber}`}
|
||||
className="absolute z-[2] truncate px-1 text-xs font-bold text-content-muted"
|
||||
<LaneBand
|
||||
label="승자조"
|
||||
description="패배 시 패자조 이동"
|
||||
top={layout.upperLane.top}
|
||||
height={layout.upperLane.height}
|
||||
width={layout.width}
|
||||
/>
|
||||
<LaneBand
|
||||
label="패자조"
|
||||
description="패배 시 탈락"
|
||||
top={layout.lowerLane.top}
|
||||
height={layout.lowerLane.height}
|
||||
width={layout.width}
|
||||
/>
|
||||
{finalNodes.length > 0 && (
|
||||
<div
|
||||
className="absolute border-l border-primary/20 bg-primary/[0.04]"
|
||||
style={{
|
||||
left: round.x,
|
||||
top: round.labelY,
|
||||
width: DOUBLE_ELIMINATION_BRACKET_GEOMETRY.columnWidth,
|
||||
left: finalZoneLeft,
|
||||
top: 0,
|
||||
width: layout.width - finalZoneLeft,
|
||||
height: layout.height,
|
||||
}}
|
||||
>
|
||||
{round.label}
|
||||
</h3>
|
||||
{round.seriesIds.map((seriesId) => {
|
||||
const node = nodeById.get(seriesId);
|
||||
const series = seriesById.get(seriesId);
|
||||
if (!node || !series) return null;
|
||||
const routes = layout.connectors.filter(
|
||||
(connector) => connector.fromSeriesId === node.seriesId,
|
||||
);
|
||||
aria-hidden="true"
|
||||
/>
|
||||
)}
|
||||
{roundGuideXs.map((x) => (
|
||||
<div
|
||||
key={x}
|
||||
className="absolute top-0 border-l border-base-content/[0.045]"
|
||||
style={{
|
||||
left: Math.max(
|
||||
0,
|
||||
x - DOUBLE_ELIMINATION_BRACKET_GEOMETRY.columnGap / 2,
|
||||
),
|
||||
height: layout.height,
|
||||
}}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
))}
|
||||
|
||||
<svg
|
||||
className="pointer-events-none absolute inset-0 z-[1]"
|
||||
width={layout.width}
|
||||
height={layout.height}
|
||||
viewBox={`0 0 ${layout.width} ${layout.height}`}
|
||||
aria-hidden="true"
|
||||
focusable="false"
|
||||
>
|
||||
{layout.connectors.map((connector) => {
|
||||
const connectorKey = bracketConnectorKey(connector);
|
||||
const isFocused = focusState.connectorKeys.has(connectorKey);
|
||||
return (
|
||||
<div
|
||||
key={node.seriesId}
|
||||
className="absolute z-[3]"
|
||||
style={{
|
||||
left: node.x,
|
||||
top: node.y,
|
||||
width: node.width,
|
||||
minHeight: node.height,
|
||||
}}
|
||||
>
|
||||
<SeriesScoreCard
|
||||
series={series}
|
||||
displayLabel={node.label}
|
||||
teamById={teamById}
|
||||
variant="bracket"
|
||||
/>
|
||||
{routes.length > 0 && (
|
||||
<span className="sr-only">
|
||||
{routes.map(({ label }) => label).join(". ")}
|
||||
</span>
|
||||
<g
|
||||
key={connectorKey}
|
||||
className={getBracketConnectorColorClass(
|
||||
connector.kind,
|
||||
isFocused,
|
||||
)}
|
||||
</div>
|
||||
>
|
||||
<path
|
||||
d={connector.path}
|
||||
fill="none"
|
||||
stroke="var(--color-base-100)"
|
||||
strokeWidth={isFocused ? 5 : 4}
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
vectorEffect="non-scaling-stroke"
|
||||
/>
|
||||
<path
|
||||
d={connector.path}
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth={isFocused ? 2 : 1.5}
|
||||
strokeDasharray={connectorDash(connector.kind)}
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
vectorEffect="non-scaling-stroke"
|
||||
/>
|
||||
<circle
|
||||
cx={connector.targetX}
|
||||
cy={connector.targetY}
|
||||
r={isFocused ? 3 : 2.5}
|
||||
fill="currentColor"
|
||||
/>
|
||||
</g>
|
||||
);
|
||||
})}
|
||||
</section>
|
||||
))}
|
||||
</svg>
|
||||
|
||||
{layout.rounds.map((round) => (
|
||||
<section
|
||||
key={`${round.stage}:${round.roundNumber}`}
|
||||
aria-labelledby={`${bracketInstructionsId}-round-${round.stage}-${round.roundNumber}`}
|
||||
>
|
||||
<h3
|
||||
id={`${bracketInstructionsId}-round-${round.stage}-${round.roundNumber}`}
|
||||
aria-label={round.accessibleLabel}
|
||||
className={`absolute z-[2] truncate border-l-2 px-2 text-xs font-bold ${round.lane === "final" ? "border-primary/45 text-base-content" : "border-base-content/15 text-content-muted"}`}
|
||||
style={{
|
||||
left: round.x,
|
||||
top: round.labelY,
|
||||
width: DOUBLE_ELIMINATION_BRACKET_GEOMETRY.columnWidth,
|
||||
}}
|
||||
>
|
||||
{round.label}
|
||||
</h3>
|
||||
{round.seriesIds.map((seriesId, seriesIndex) => {
|
||||
const node = nodeById.get(seriesId);
|
||||
const series = seriesById.get(seriesId);
|
||||
if (!node || !series) return null;
|
||||
const relatedRoutes = layout.connectors.filter(
|
||||
(connector) =>
|
||||
connector.fromSeriesId === node.seriesId ||
|
||||
connector.toSeriesId === node.seriesId,
|
||||
);
|
||||
const routeDescriptionId = `${bracketInstructionsId}-${round.stage}-${round.roundNumber}-${seriesIndex}`;
|
||||
const isFocused = activeSeriesId === node.seriesId;
|
||||
const isRelated = focusState.seriesIds.has(node.seriesId);
|
||||
const accessibilityLabel = getSeriesScoreCardAccessibleLabel(
|
||||
series,
|
||||
node.accessibleLabel,
|
||||
teamById,
|
||||
);
|
||||
return (
|
||||
<div
|
||||
key={node.seriesId}
|
||||
className={`absolute z-[3] focus-visible:z-[4] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary ${isFocused ? "z-[4] ring-2 ring-primary/55" : isRelated ? "z-[4] ring-1 ring-base-content/30" : node.lane === "final" ? "outline outline-1 outline-primary/25" : ""}`}
|
||||
style={{
|
||||
left: node.x,
|
||||
top: node.y,
|
||||
width: node.width,
|
||||
minHeight: node.height,
|
||||
}}
|
||||
role="group"
|
||||
aria-label={accessibilityLabel}
|
||||
aria-describedby={
|
||||
relatedRoutes.length > 0 ? routeDescriptionId : undefined
|
||||
}
|
||||
tabIndex={0}
|
||||
onMouseEnter={() => setHoveredSeriesId(node.seriesId)}
|
||||
onMouseLeave={() =>
|
||||
setHoveredSeriesId((current) =>
|
||||
current === node.seriesId ? null : current,
|
||||
)
|
||||
}
|
||||
onFocus={() => setFocusedSeriesId(node.seriesId)}
|
||||
onBlur={(event) => {
|
||||
if (!event.currentTarget.contains(event.relatedTarget)) {
|
||||
setFocusedSeriesId((current) =>
|
||||
current === node.seriesId ? null : current,
|
||||
);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<SeriesScoreCard
|
||||
series={series}
|
||||
displayLabel={node.label}
|
||||
teamById={teamById}
|
||||
variant="bracket"
|
||||
accessibilityLabel={accessibilityLabel}
|
||||
/>
|
||||
{relatedRoutes.length > 0 && (
|
||||
<span id={routeDescriptionId} className="sr-only">
|
||||
{relatedRoutes
|
||||
.map(({ accessibleLabel }) => accessibleLabel)
|
||||
.join(". ")}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</section>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className={`pointer-events-none absolute inset-y-px left-0 z-[5] w-8 bg-linear-to-r from-base-100 to-transparent transition-opacity duration-150 motion-reduce:transition-none ${overflowCues.showStart ? "opacity-100" : "opacity-0"}`}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<div
|
||||
className={`pointer-events-none absolute inset-y-px right-0 z-[5] w-8 bg-linear-to-l from-base-100 to-transparent transition-opacity duration-150 motion-reduce:transition-none ${overflowCues.showEnd ? "opacity-100" : "opacity-0"}`}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@@ -221,7 +333,7 @@ function LaneBand({
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className="absolute border-y border-base-content/8 bg-base-content/[0.018]"
|
||||
className="absolute border-y border-base-content/10 bg-base-content/[0.03]"
|
||||
style={{ top: top - 6, width, height: height + 12 }}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
@@ -240,7 +352,11 @@ function LaneBand({
|
||||
|
||||
function ConnectorLegend({ showReset }: { showReset: boolean }) {
|
||||
return (
|
||||
<div className="flex flex-wrap items-center gap-4" aria-label="연결선 범례">
|
||||
<div
|
||||
className="flex flex-wrap items-center gap-4"
|
||||
role="group"
|
||||
aria-label="연결선 범례"
|
||||
>
|
||||
<LegendItem label="승자 진출" kind="winner" />
|
||||
<LegendItem label="패자조 이동" kind="loser" />
|
||||
{showReset && <LegendItem label="리셋 대진 유지" kind="reset" />}
|
||||
@@ -264,7 +380,7 @@ function LegendItem({
|
||||
stroke="currentColor"
|
||||
strokeWidth="1.25"
|
||||
strokeDasharray={connectorDash(kind)}
|
||||
className={connectorClass(kind)}
|
||||
className={getBracketConnectorColorClass(kind)}
|
||||
/>
|
||||
</svg>
|
||||
{label}
|
||||
@@ -272,12 +388,6 @@ function LegendItem({
|
||||
);
|
||||
}
|
||||
|
||||
function connectorClass(kind: BracketConnectorKind): string {
|
||||
if (kind === "loser") return "text-warning/65";
|
||||
if (kind === "reset") return "text-primary/55";
|
||||
return "text-base-content/30";
|
||||
}
|
||||
|
||||
function connectorDash(kind: BracketConnectorKind): string | undefined {
|
||||
if (kind === "loser") return "6 5";
|
||||
if (kind === "reset") return "2 5";
|
||||
|
||||
@@ -4,8 +4,10 @@ import type {
|
||||
SeriesId,
|
||||
TeamId,
|
||||
} from "@lolympus/contracts";
|
||||
import { useId } from "react";
|
||||
import type { DoubleEliminationBracketLayout } from "./double-elimination-bracket-layout";
|
||||
import { SeriesScoreCard } from "./SeriesScoreCard";
|
||||
import { getSeriesScoreCardAccessibleLabel } from "./series-score-card-model";
|
||||
|
||||
export function DoubleEliminationMobileBracket({
|
||||
projection,
|
||||
@@ -16,6 +18,7 @@ export function DoubleEliminationMobileBracket({
|
||||
layout: DoubleEliminationBracketLayout;
|
||||
teamById: ReadonlyMap<TeamId, CompetitionTeamView>;
|
||||
}) {
|
||||
const bracketId = useId();
|
||||
const seriesById = new Map(
|
||||
projection.series.map((series) => [series.seriesId, series]),
|
||||
);
|
||||
@@ -53,9 +56,15 @@ export function DoubleEliminationMobileBracket({
|
||||
);
|
||||
if (groups.length === 0) return null;
|
||||
return (
|
||||
<section key={section.key} aria-labelledby={`bracket-${section.key}`}>
|
||||
<section
|
||||
key={section.key}
|
||||
aria-labelledby={`${bracketId}-${section.key}`}
|
||||
>
|
||||
<div className="mb-3 border-b border-base-content/10 pb-2">
|
||||
<h3 id={`bracket-${section.key}`} className="text-sm font-bold">
|
||||
<h3
|
||||
id={`${bracketId}-${section.key}`}
|
||||
className="text-sm font-bold"
|
||||
>
|
||||
{section.title}
|
||||
</h3>
|
||||
<p className="mt-0.5 text-xs text-content-muted">
|
||||
@@ -66,24 +75,40 @@ export function DoubleEliminationMobileBracket({
|
||||
{groups.map((group) => (
|
||||
<section
|
||||
key={`${group.stage}:${group.roundNumber}`}
|
||||
aria-label={group.label}
|
||||
aria-labelledby={`${bracketId}-${group.stage}-${group.roundNumber}`}
|
||||
>
|
||||
<h4 className="mb-2 text-xs font-bold text-content-muted">
|
||||
<h4
|
||||
id={`${bracketId}-${group.stage}-${group.roundNumber}`}
|
||||
className="mb-2 text-xs font-bold text-content-muted"
|
||||
aria-label={group.accessibleLabel}
|
||||
>
|
||||
{group.label}
|
||||
</h4>
|
||||
<div className="space-y-3">
|
||||
{group.seriesIds.map((seriesId) => {
|
||||
const series = seriesById.get(seriesId);
|
||||
if (!series) return null;
|
||||
const node = nodeById.get(seriesId);
|
||||
const accessibilityLabel =
|
||||
getSeriesScoreCardAccessibleLabel(
|
||||
series,
|
||||
node?.accessibleLabel,
|
||||
teamById,
|
||||
);
|
||||
return (
|
||||
<div key={seriesId}>
|
||||
<SeriesScoreCard
|
||||
series={series}
|
||||
displayLabel={nodeById.get(seriesId)?.label}
|
||||
displayLabel={node?.label}
|
||||
teamById={teamById}
|
||||
variant="bracket"
|
||||
accessibilityLabel={accessibilityLabel}
|
||||
/>
|
||||
<MobileRoutes
|
||||
layout={layout}
|
||||
seriesId={seriesId}
|
||||
seriesLabel={node?.accessibleLabel ?? "경기"}
|
||||
/>
|
||||
<MobileRoutes layout={layout} seriesId={seriesId} />
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
@@ -101,19 +126,25 @@ export function DoubleEliminationMobileBracket({
|
||||
function MobileRoutes({
|
||||
layout,
|
||||
seriesId,
|
||||
seriesLabel,
|
||||
}: {
|
||||
layout: DoubleEliminationBracketLayout;
|
||||
seriesId: SeriesId;
|
||||
seriesLabel: string;
|
||||
}) {
|
||||
const routes = layout.connectors.filter(
|
||||
(connector) => connector.fromSeriesId === seriesId,
|
||||
);
|
||||
if (routes.length === 0) return null;
|
||||
return (
|
||||
<ul className="mt-1.5 space-y-0.5 border-l border-base-content/10 pl-2 text-[11px] text-content-muted">
|
||||
<ul
|
||||
className="mt-1.5 space-y-0.5 border-l border-base-content/10 pl-2 text-[11px] text-content-muted"
|
||||
aria-label={`${seriesLabel} 연결 경로`}
|
||||
>
|
||||
{routes.map((route) => (
|
||||
<li key={`${route.select}:${route.toSeriesId}:${route.toSlot}`}>
|
||||
{route.label}
|
||||
<span aria-hidden="true">{route.label}</span>
|
||||
<span className="sr-only">{route.accessibleLabel}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
@@ -79,7 +79,7 @@ export function MatchDetailTabBar({
|
||||
onKeyDown={(event) => handleKeyDown(event, tab.id)}
|
||||
className={`min-h-11 flex-none whitespace-nowrap border-b-2 px-4 text-xs font-bold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary ${
|
||||
selected
|
||||
? "border-primary bg-primary/5 text-primary"
|
||||
? "border-primary bg-primary/5 text-base-content"
|
||||
: "border-transparent text-base-content/45 hover:bg-base-content/[0.03] hover:text-base-content"
|
||||
}`}
|
||||
>
|
||||
|
||||
@@ -4,14 +4,37 @@ import type {
|
||||
TeamId,
|
||||
} from "@lolympus/contracts";
|
||||
import { SERIES_SCORE_CARD_GEOMETRY } from "./series-score-card-geometry";
|
||||
import { isSeriesEntryWinner } from "./series-score-card-model";
|
||||
import {
|
||||
formatSeriesScore,
|
||||
getSeriesScoreCardAccessibleLabel,
|
||||
getSeriesScoreCardIdentity,
|
||||
getSeriesScoreCardPresentation,
|
||||
isSeriesEntryWinner,
|
||||
type SeriesScoreCardTone,
|
||||
} from "./series-score-card-model";
|
||||
|
||||
const STATUS_LABEL: Record<SeriesProjection["status"], string> = {
|
||||
inactive: "비활성",
|
||||
waiting: "대진 대기",
|
||||
ready: "경기 가능",
|
||||
"in-progress": "진행 중",
|
||||
completed: "종료",
|
||||
const CARD_TONE_CLASS: Record<SeriesScoreCardTone, string> = {
|
||||
muted: "",
|
||||
ready: "border-l-2 border-l-success/70",
|
||||
live: "border-l-2 border-l-primary/70",
|
||||
completed: "",
|
||||
adjudicated: "",
|
||||
};
|
||||
|
||||
const HEADER_TONE_CLASS: Record<SeriesScoreCardTone, string> = {
|
||||
muted: "",
|
||||
ready: "bg-success/[0.035]",
|
||||
live: "bg-primary/[0.04]",
|
||||
completed: "",
|
||||
adjudicated: "",
|
||||
};
|
||||
|
||||
const STATUS_TONE_CLASS: Record<SeriesScoreCardTone, string> = {
|
||||
muted: "border-base-content/10 bg-base-200 text-content-muted",
|
||||
ready: "border-success/30 bg-success/10 text-base-content",
|
||||
live: "border-primary/30 bg-primary/10 text-base-content",
|
||||
completed: "border-base-content/10 bg-base-200 text-content-muted",
|
||||
adjudicated: "border-warning/35 bg-warning/10 text-base-content",
|
||||
};
|
||||
|
||||
export function SeriesScoreCard({
|
||||
@@ -19,25 +42,31 @@ export function SeriesScoreCard({
|
||||
displayLabel,
|
||||
teamById,
|
||||
variant = "default",
|
||||
accessibilityLabel,
|
||||
}: {
|
||||
series: SeriesProjection;
|
||||
displayLabel?: string;
|
||||
teamById: ReadonlyMap<TeamId, CompetitionTeamView>;
|
||||
variant?: "default" | "bracket";
|
||||
accessibilityLabel?: string;
|
||||
}) {
|
||||
const isBracket = variant === "bracket";
|
||||
const seriesLabel = series.code ?? displayLabel;
|
||||
const identity = getSeriesScoreCardIdentity(series, displayLabel);
|
||||
const presentation = getSeriesScoreCardPresentation(series);
|
||||
const cardAccessibilityLabel =
|
||||
accessibilityLabel ??
|
||||
getSeriesScoreCardAccessibleLabel(series, displayLabel, teamById);
|
||||
|
||||
return (
|
||||
<article
|
||||
className="border border-base-content/10 bg-base-100"
|
||||
aria-label={`${seriesLabel ?? "경기"} ${STATUS_LABEL[series.status]}`}
|
||||
className={`border border-base-content/10 bg-base-100 ${CARD_TONE_CLASS[presentation.tone]}`}
|
||||
aria-label={cardAccessibilityLabel}
|
||||
style={
|
||||
isBracket ? { height: SERIES_SCORE_CARD_GEOMETRY.height } : undefined
|
||||
}
|
||||
>
|
||||
<header
|
||||
className={`flex items-center justify-between gap-3 border-b border-base-content/8 ${
|
||||
className={`flex items-center justify-between gap-2 border-b border-base-content/8 ${HEADER_TONE_CLASS[presentation.tone]} ${
|
||||
isBracket ? "px-2" : "px-3 py-2"
|
||||
}`}
|
||||
style={
|
||||
@@ -47,19 +76,39 @@ export function SeriesScoreCard({
|
||||
}
|
||||
>
|
||||
<span
|
||||
className="truncate text-xs font-bold text-base-content/65"
|
||||
title={seriesLabel ?? "Series"}
|
||||
className="min-w-0"
|
||||
title={
|
||||
identity.code
|
||||
? `${identity.label} (${identity.code})`
|
||||
: identity.label
|
||||
}
|
||||
>
|
||||
{seriesLabel ?? "Series"}
|
||||
<span className="block truncate text-[11px] font-bold leading-3 text-base-content/75">
|
||||
{identity.label}
|
||||
</span>
|
||||
{identity.code && (
|
||||
<span className="mt-0.5 block truncate font-mono text-[9px] leading-[10px] text-content-subtle">
|
||||
{identity.code}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<span className="shrink-0 text-[11px] text-base-content/40">
|
||||
{STATUS_LABEL[series.status]}
|
||||
<span
|
||||
className={`inline-flex shrink-0 items-center gap-1 border px-1 py-0.5 text-[10px] font-bold leading-3 ${STATUS_TONE_CLASS[presentation.tone]}`}
|
||||
>
|
||||
{(presentation.tone === "ready" || presentation.tone === "live") && (
|
||||
<span
|
||||
className={`size-1.5 ${presentation.tone === "ready" ? "bg-success" : "bg-primary"}`}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
)}
|
||||
{presentation.label}
|
||||
</span>
|
||||
</header>
|
||||
<div className="divide-y divide-base-content/8">
|
||||
{series.entries.map((entry) => {
|
||||
const team = entry.teamId ? teamById.get(entry.teamId) : undefined;
|
||||
const isWinner = isSeriesEntryWinner(series, entry.teamId);
|
||||
const score = formatSeriesScore(series, entry.gameWins);
|
||||
const teamName =
|
||||
team?.name ?? (entry.teamId ? "알 수 없는 팀" : "대기 중");
|
||||
return isBracket ? (
|
||||
@@ -67,6 +116,7 @@ export function SeriesScoreCard({
|
||||
key={entry.slot}
|
||||
entry={entry}
|
||||
isWinner={isWinner}
|
||||
score={score}
|
||||
teamName={teamName}
|
||||
/>
|
||||
) : (
|
||||
@@ -74,6 +124,7 @@ export function SeriesScoreCard({
|
||||
key={entry.slot}
|
||||
entry={entry}
|
||||
isWinner={isWinner}
|
||||
score={score}
|
||||
teamName={teamName}
|
||||
/>
|
||||
);
|
||||
@@ -86,10 +137,12 @@ export function SeriesScoreCard({
|
||||
function DefaultEntryRow({
|
||||
entry,
|
||||
isWinner,
|
||||
score,
|
||||
teamName,
|
||||
}: {
|
||||
entry: SeriesProjection["entries"][number];
|
||||
isWinner: boolean;
|
||||
score: string;
|
||||
teamName: string;
|
||||
}) {
|
||||
return (
|
||||
@@ -99,15 +152,17 @@ function DefaultEntryRow({
|
||||
</span>
|
||||
<span
|
||||
className={`truncate text-sm ${
|
||||
isWinner ? "font-bold text-base-content" : "text-base-content/60"
|
||||
isWinner ? "font-bold text-base-content" : "text-content-subtle"
|
||||
}`}
|
||||
>
|
||||
{teamName}
|
||||
{isWinner && (
|
||||
<span className="ml-2 text-[10px] font-bold text-success">승리</span>
|
||||
<span className="ml-2 text-[10px] font-bold text-base-content">
|
||||
승리
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<Score gameWins={entry.gameWins} />
|
||||
<Score score={score} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -115,10 +170,12 @@ function DefaultEntryRow({
|
||||
function BracketEntryRow({
|
||||
entry,
|
||||
isWinner,
|
||||
score,
|
||||
teamName,
|
||||
}: {
|
||||
entry: SeriesProjection["entries"][number];
|
||||
isWinner: boolean;
|
||||
score: string;
|
||||
teamName: string;
|
||||
}) {
|
||||
return (
|
||||
@@ -131,24 +188,27 @@ function BracketEntryRow({
|
||||
</span>
|
||||
<span
|
||||
className={`line-clamp-2 break-words text-[13px] leading-4 ${
|
||||
isWinner ? "font-bold text-base-content" : "text-base-content/60"
|
||||
isWinner ? "font-bold text-base-content" : "text-content-subtle"
|
||||
}`}
|
||||
title={teamName}
|
||||
>
|
||||
{teamName}
|
||||
</span>
|
||||
<span className="text-center text-[10px] font-bold text-success">
|
||||
<span className="text-center text-[10px] font-bold text-base-content">
|
||||
{isWinner ? "승리" : null}
|
||||
</span>
|
||||
<Score gameWins={entry.gameWins} />
|
||||
<Score score={score} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Score({ gameWins }: { gameWins: number }) {
|
||||
function Score({ score }: { score: string }) {
|
||||
return (
|
||||
<span className="text-right font-mono text-base font-bold tabular-nums text-base-content/75">
|
||||
{gameWins}
|
||||
<span
|
||||
className="text-right font-mono text-base font-bold tabular-nums text-base-content/75"
|
||||
aria-label={score === "—" ? "점수 없음" : `${score}승`}
|
||||
>
|
||||
{score}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
import type {
|
||||
CompetitionTeamView,
|
||||
SeriesProjection,
|
||||
TeamId,
|
||||
} from "@lolympus/contracts";
|
||||
import type { ReactNode } from "react";
|
||||
import {
|
||||
getTeamSeriesPresentation,
|
||||
type TeamSeriesTone,
|
||||
} from "../../pages/match-team-progress-view";
|
||||
import { isSeriesEntryWinner } from "./series-score-card-model";
|
||||
|
||||
const STATUS_TONE_CLASS: Record<TeamSeriesTone, string> = {
|
||||
muted: "border-base-content/15 bg-base-200 text-base-content",
|
||||
ready: "border-primary/50 bg-primary/10 text-base-content",
|
||||
live: "border-info/60 bg-info/10 text-base-content",
|
||||
completed: "border-base-content/20 bg-base-200 text-base-content",
|
||||
adjudicated: "border-warning/60 bg-warning/15 text-base-content",
|
||||
};
|
||||
|
||||
export function TeamSeriesCard({
|
||||
series,
|
||||
displayLabel,
|
||||
teamById,
|
||||
highlightedTeamId,
|
||||
emphasized = false,
|
||||
children,
|
||||
}: {
|
||||
series: SeriesProjection;
|
||||
displayLabel: string;
|
||||
teamById: ReadonlyMap<TeamId, CompetitionTeamView>;
|
||||
highlightedTeamId: TeamId;
|
||||
emphasized?: boolean;
|
||||
children?: ReactNode;
|
||||
}) {
|
||||
const presentation = getTeamSeriesPresentation(series);
|
||||
const headingId = `team-series-${String(series.seriesId)}`;
|
||||
|
||||
return (
|
||||
<article
|
||||
className={`overflow-hidden border bg-base-100 ${
|
||||
emphasized ? "border-primary/30" : "border-base-content/10"
|
||||
}`}
|
||||
aria-labelledby={headingId}
|
||||
>
|
||||
<header
|
||||
className={`flex flex-wrap items-start justify-between gap-3 border-b px-4 py-3 sm:px-5 ${
|
||||
emphasized
|
||||
? "border-primary/20 bg-primary/[0.035]"
|
||||
: "border-base-content/10 bg-base-200/40"
|
||||
}`}
|
||||
>
|
||||
<div className="min-w-0">
|
||||
<h3
|
||||
id={headingId}
|
||||
className="break-words text-base font-black text-base-content"
|
||||
>
|
||||
{displayLabel}
|
||||
</h3>
|
||||
<div className="mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-content-muted">
|
||||
{series.code && (
|
||||
<code className="break-all font-mono">{series.code}</code>
|
||||
)}
|
||||
<span>{seriesRuleLabel(series)}</span>
|
||||
</div>
|
||||
</div>
|
||||
<span
|
||||
className={`shrink-0 border-l-2 px-2 py-1 text-xs font-bold ${STATUS_TONE_CLASS[presentation.tone]}`}
|
||||
>
|
||||
{presentation.label}
|
||||
</span>
|
||||
</header>
|
||||
|
||||
<ul
|
||||
className="divide-y divide-base-content/10"
|
||||
aria-label={`${displayLabel} 대진`}
|
||||
>
|
||||
{series.entries.map((entry) => {
|
||||
const team = entry.teamId ? teamById.get(entry.teamId) : undefined;
|
||||
const teamName =
|
||||
team?.name ?? (entry.teamId ? "알 수 없는 팀" : "상대 결정 대기");
|
||||
const isHighlightedTeam = entry.teamId === highlightedTeamId;
|
||||
const isWinner = isSeriesEntryWinner(series, entry.teamId);
|
||||
return (
|
||||
<li
|
||||
key={entry.slot}
|
||||
className={`grid min-h-12 grid-cols-[minmax(0,1fr)_3rem] items-center gap-3 px-4 py-2.5 sm:px-5 ${
|
||||
isHighlightedTeam ? "bg-base-200/35" : ""
|
||||
}`}
|
||||
>
|
||||
<div className="flex min-w-0 flex-wrap items-center gap-2">
|
||||
<span
|
||||
className={`min-w-0 break-words text-sm ${
|
||||
isWinner || isHighlightedTeam
|
||||
? "font-bold text-base-content"
|
||||
: "text-content-subtle"
|
||||
}`}
|
||||
>
|
||||
<span className="sr-only">{entry.slot} 슬롯: </span>
|
||||
{teamName}
|
||||
</span>
|
||||
{isHighlightedTeam && (
|
||||
<span className="border border-base-content/15 bg-base-100 px-1.5 py-0.5 text-[11px] font-bold text-base-content">
|
||||
이 팀
|
||||
</span>
|
||||
)}
|
||||
{isWinner && (
|
||||
<span className="border-l-2 border-success bg-success/10 px-1.5 py-0.5 text-[11px] font-bold text-base-content">
|
||||
승리
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<span className="text-right font-mono text-base font-bold tabular-nums text-base-content">
|
||||
<span className="sr-only">
|
||||
{presentation.showScore ? "게임 승수: " : "점수 없음"}
|
||||
</span>
|
||||
{presentation.showScore ? (
|
||||
entry.gameWins
|
||||
) : (
|
||||
<span aria-hidden="true">—</span>
|
||||
)}
|
||||
</span>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
|
||||
{children}
|
||||
</article>
|
||||
);
|
||||
}
|
||||
|
||||
function seriesRuleLabel(series: SeriesProjection): string {
|
||||
if (series.rule.type === "fixed-games") {
|
||||
return `${series.rule.gameCount}게임`;
|
||||
}
|
||||
return `${series.rule.maxGames}전 ${series.rule.winsRequired}선승`;
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
import type { TeamTournamentCodeView } from "@lolympus/contracts";
|
||||
import { Check, Copy, LoaderCircle } from "lucide-react";
|
||||
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
||||
import {
|
||||
copyTournamentCode,
|
||||
getNextTournamentCodeExpiryDelay,
|
||||
getTournamentCodeCopyLabel,
|
||||
getTournamentCodeExpiryLabel,
|
||||
getTournamentCodePresentation,
|
||||
type TournamentCodeCopyFeedback,
|
||||
type TournamentCodeTone,
|
||||
} from "../../pages/match-team-progress-view";
|
||||
|
||||
const CODE_TONE_CLASS: Record<TournamentCodeTone, string> = {
|
||||
pending: "border-base-content/15 bg-base-200 text-base-content",
|
||||
available: "border-primary/50 bg-primary/10 text-base-content",
|
||||
expired: "border-error/50 bg-error/10 text-base-content",
|
||||
used: "border-base-content/20 bg-base-200 text-base-content",
|
||||
};
|
||||
|
||||
type VisibleFeedback = TournamentCodeCopyFeedback & { gameSlotId: string };
|
||||
|
||||
export function TeamTournamentCodes({
|
||||
assignments,
|
||||
seriesLabel,
|
||||
}: {
|
||||
assignments: readonly TeamTournamentCodeView[];
|
||||
seriesLabel: string;
|
||||
}) {
|
||||
const [copyingSlotId, setCopyingSlotId] = useState<string | null>(null);
|
||||
const [feedback, setFeedback] = useState<VisibleFeedback | null>(null);
|
||||
const [now, setNow] = useState(() => Date.now());
|
||||
const clearFeedbackTimeoutRef = useRef<number | null>(null);
|
||||
|
||||
useEffect(
|
||||
() => () => {
|
||||
if (clearFeedbackTimeoutRef.current !== null) {
|
||||
window.clearTimeout(clearFeedbackTimeoutRef.current);
|
||||
}
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const delay = getNextTournamentCodeExpiryDelay(assignments, now);
|
||||
if (delay === null) return;
|
||||
const timeoutId = window.setTimeout(
|
||||
() => setNow(Date.now()),
|
||||
Math.max(1, delay),
|
||||
);
|
||||
return () => window.clearTimeout(timeoutId);
|
||||
}, [assignments, now]);
|
||||
|
||||
if (assignments.length === 0) {
|
||||
return (
|
||||
<div className="border-t border-base-content/10 px-4 py-5 sm:px-5">
|
||||
<p role="status" className="text-sm text-content-muted">
|
||||
이 경기에 배정된 토너먼트 코드가 없습니다.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
async function handleCopy(assignment: TeamTournamentCodeView) {
|
||||
if (!assignment.code || copyingSlotId !== null) return;
|
||||
if (clearFeedbackTimeoutRef.current !== null) {
|
||||
window.clearTimeout(clearFeedbackTimeoutRef.current);
|
||||
clearFeedbackTimeoutRef.current = null;
|
||||
}
|
||||
|
||||
const slotId = String(assignment.gameSlotId);
|
||||
const gameLabel = `${seriesLabel} ${assignment.ordinal}세트`;
|
||||
const currentTime = readCurrentTime();
|
||||
setNow(currentTime);
|
||||
if (!getTournamentCodePresentation(assignment, currentTime).canCopy) {
|
||||
setFeedback({
|
||||
kind: "error",
|
||||
gameSlotId: slotId,
|
||||
message: `${gameLabel} 코드는 만료되었거나 사용할 수 없어 복사하지 않았습니다.`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
setCopyingSlotId(slotId);
|
||||
setFeedback(null);
|
||||
const clipboard = navigator.clipboard;
|
||||
const result = await copyTournamentCode(
|
||||
clipboard?.writeText ? clipboard.writeText.bind(clipboard) : undefined,
|
||||
assignment.code,
|
||||
gameLabel,
|
||||
);
|
||||
setCopyingSlotId(null);
|
||||
setFeedback({ ...result, gameSlotId: slotId });
|
||||
|
||||
if (result.kind === "success") {
|
||||
clearFeedbackTimeoutRef.current = window.setTimeout(() => {
|
||||
setFeedback(null);
|
||||
clearFeedbackTimeoutRef.current = null;
|
||||
}, 2500);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<section
|
||||
className="border-t border-base-content/10"
|
||||
aria-label={`${seriesLabel} 토너먼트 코드`}
|
||||
>
|
||||
<div className="flex flex-wrap items-baseline justify-between gap-2 bg-base-200/25 px-4 py-2.5 sm:px-5">
|
||||
<h4 className="text-sm font-bold text-base-content">게임 코드</h4>
|
||||
<p className="text-xs text-content-muted">
|
||||
세트에 맞는 코드를 복사해 클라이언트에 입력하세요.
|
||||
</p>
|
||||
</div>
|
||||
<ol className="divide-y divide-base-content/10">
|
||||
{assignments.map((assignment) => {
|
||||
const slotId = String(assignment.gameSlotId);
|
||||
const presentation = getTournamentCodePresentation(assignment, now);
|
||||
const isCopying = copyingSlotId === slotId;
|
||||
const copied =
|
||||
feedback?.kind === "success" && feedback.gameSlotId === slotId;
|
||||
return (
|
||||
<li
|
||||
key={slotId}
|
||||
className="grid gap-3 px-4 py-3 sm:px-5 md:grid-cols-[5.5rem_minmax(0,1fr)_auto] md:items-center"
|
||||
>
|
||||
<div>
|
||||
<p className="text-sm font-bold text-base-content">
|
||||
{assignment.ordinal}세트
|
||||
</p>
|
||||
<p className="mt-0.5 text-xs text-content-muted">
|
||||
전체 Game {assignment.displayNumber}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="min-w-0">
|
||||
{assignment.code ? (
|
||||
<AutoSizingCodeField
|
||||
label={`${seriesLabel} ${assignment.ordinal}세트 토너먼트 코드`}
|
||||
value={assignment.code}
|
||||
/>
|
||||
) : (
|
||||
<p className="text-sm font-bold text-content-muted">
|
||||
발급 대기 중
|
||||
</p>
|
||||
)}
|
||||
{assignment.code &&
|
||||
assignment.state === "reserved" &&
|
||||
assignment.expiresAt && (
|
||||
<p className="mt-1 text-xs text-content-muted">
|
||||
<time dateTime={assignment.expiresAt}>
|
||||
{getTournamentCodeExpiryLabel(
|
||||
assignment.expiresAt,
|
||||
now,
|
||||
)}
|
||||
</time>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-2 md:justify-end">
|
||||
<span
|
||||
className={`border-l-2 px-2 py-1 text-xs font-bold ${CODE_TONE_CLASS[presentation.tone]}`}
|
||||
role="status"
|
||||
aria-live="polite"
|
||||
aria-atomic="true"
|
||||
>
|
||||
{presentation.label}
|
||||
</span>
|
||||
{assignment.code && assignment.state === "reserved" && (
|
||||
<button
|
||||
type="button"
|
||||
className="inline-flex min-h-11 items-center justify-center gap-1.5 border border-base-content/20 bg-base-100 px-3 text-sm font-bold text-base-content hover:border-primary/50 hover:bg-primary/5 focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-70"
|
||||
aria-label={
|
||||
presentation.canCopy
|
||||
? getTournamentCodeCopyLabel(assignment, seriesLabel)
|
||||
: `${seriesLabel} ${assignment.ordinal}세트 토너먼트 코드 만료됨`
|
||||
}
|
||||
disabled={!presentation.canCopy || copyingSlotId !== null}
|
||||
onClick={() => void handleCopy(assignment)}
|
||||
>
|
||||
{!presentation.canCopy ? null : isCopying ? (
|
||||
<LoaderCircle
|
||||
className="h-4 w-4 animate-spin motion-reduce:animate-none"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
) : copied ? (
|
||||
<Check className="h-4 w-4" aria-hidden="true" />
|
||||
) : (
|
||||
<Copy className="h-4 w-4" aria-hidden="true" />
|
||||
)}
|
||||
{!presentation.canCopy
|
||||
? "복사 불가"
|
||||
: isCopying
|
||||
? "복사 중"
|
||||
: copied
|
||||
? "복사됨"
|
||||
: "복사"}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ol>
|
||||
|
||||
{feedback && (
|
||||
<p
|
||||
className={`border-t px-4 py-2.5 text-sm sm:px-5 ${
|
||||
feedback.kind === "error"
|
||||
? "border-error/30 bg-error/10 text-base-content"
|
||||
: "border-success/30 bg-success/10 text-base-content"
|
||||
}`}
|
||||
role={feedback.kind === "error" ? "alert" : "status"}
|
||||
aria-live={feedback.kind === "error" ? "assertive" : "polite"}
|
||||
aria-atomic="true"
|
||||
>
|
||||
{feedback.message}
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function readCurrentTime(): number {
|
||||
return Date.now();
|
||||
}
|
||||
|
||||
function AutoSizingCodeField({
|
||||
label,
|
||||
value,
|
||||
}: {
|
||||
label: string;
|
||||
value: string;
|
||||
}) {
|
||||
const fieldRef = useRef<HTMLTextAreaElement>(null);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const resizeToContent = () => {
|
||||
const field = fieldRef.current;
|
||||
if (!field) return;
|
||||
field.style.height = "auto";
|
||||
const borderHeight = field.offsetHeight - field.clientHeight;
|
||||
field.style.height = `${field.scrollHeight + borderHeight}px`;
|
||||
};
|
||||
|
||||
resizeToContent();
|
||||
window.addEventListener("resize", resizeToContent);
|
||||
return () => window.removeEventListener("resize", resizeToContent);
|
||||
}, [value]);
|
||||
|
||||
return (
|
||||
<textarea
|
||||
ref={fieldRef}
|
||||
aria-label={label}
|
||||
className="block min-h-11 w-full resize-none overflow-hidden border border-base-content/15 bg-base-100 px-3 py-2 font-mono text-sm font-bold leading-5 text-base-content focus-visible:ring-2 focus-visible:ring-primary"
|
||||
onClick={(event) => event.currentTarget.select()}
|
||||
onFocus={(event) => event.currentTarget.select()}
|
||||
readOnly
|
||||
rows={1}
|
||||
spellCheck={false}
|
||||
value={value}
|
||||
wrap="soft"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -103,20 +103,41 @@ export function getSeriesHistoryStatusLabel(
|
||||
series: CompetitionSeriesHistorySeries,
|
||||
): string {
|
||||
if (series.status === "in-progress") return "진행 중";
|
||||
return "최종";
|
||||
}
|
||||
|
||||
export function getSeriesHistoryResultLabel(
|
||||
series: CompetitionSeriesHistorySeries,
|
||||
): string | null {
|
||||
if (series.status === "in-progress") return null;
|
||||
switch (series.outcome.type) {
|
||||
case "played":
|
||||
return "종료";
|
||||
return null;
|
||||
case "draw":
|
||||
return "무승부";
|
||||
return series.outcome.basis.type === "played"
|
||||
? "무승부"
|
||||
: "판정 무승부";
|
||||
case "walkover":
|
||||
return "부전승";
|
||||
case "forfeit":
|
||||
return "기권승";
|
||||
case "administrative":
|
||||
return "판정";
|
||||
return "판정승";
|
||||
}
|
||||
}
|
||||
|
||||
export function getSeriesHistoryRecordLabel(
|
||||
series: CompetitionSeriesHistorySeries,
|
||||
gameCount: number,
|
||||
expanded: boolean,
|
||||
): string {
|
||||
if (gameCount > 0) {
|
||||
return expanded ? "게임 상세 접기" : `게임 상세 (${gameCount})`;
|
||||
}
|
||||
if (isGameLessDecision(series)) return "경기 없이 결정";
|
||||
return "게임 기록 미등록";
|
||||
}
|
||||
|
||||
export function shouldDisplaySeriesHistoryScore(
|
||||
series: CompetitionSeriesHistorySeries,
|
||||
): boolean {
|
||||
@@ -155,7 +176,14 @@ export function formatCompetitionHistoryDate(dateKey: string): string {
|
||||
) {
|
||||
return "일시 정보 없음";
|
||||
}
|
||||
return `${padNumber(month)}월 ${padNumber(day)}일 (${KOREAN_WEEKDAYS[date.getUTCDay()]})`;
|
||||
return `${month}월 ${day}일 (${KOREAN_WEEKDAYS[date.getUTCDay()]})`;
|
||||
}
|
||||
|
||||
export function formatCompetitionHistoryDayHeading(
|
||||
dateKey: string,
|
||||
gameCount: number,
|
||||
): string {
|
||||
return `${formatCompetitionHistoryDate(dateKey)} · ${gameCount}경기`;
|
||||
}
|
||||
|
||||
export function formatCompetitionHistoryTime(
|
||||
@@ -233,6 +261,16 @@ function timestampValue(value: IsoDateTime): number {
|
||||
return Number.isNaN(timestamp) ? Number.POSITIVE_INFINITY : timestamp;
|
||||
}
|
||||
|
||||
function isGameLessDecision(
|
||||
series: CompetitionSeriesHistorySeries,
|
||||
): boolean {
|
||||
if (series.status === "in-progress") return false;
|
||||
if (series.outcome.type === "draw") {
|
||||
return series.outcome.basis.type !== "played";
|
||||
}
|
||||
return series.outcome.type !== "played";
|
||||
}
|
||||
|
||||
function padNumber(value: number): string {
|
||||
return value.toString().padStart(2, "0");
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import type {
|
||||
SeriesConnectorView,
|
||||
SeriesId,
|
||||
SeriesSlot,
|
||||
} from "@lolympus/contracts";
|
||||
import type { BracketConnectorKind } from "./double-elimination-bracket-layout";
|
||||
|
||||
export interface BracketFocusConnector {
|
||||
fromSeriesId: SeriesId;
|
||||
select: SeriesConnectorView["from"]["select"];
|
||||
toSeriesId: SeriesId;
|
||||
toSlot: SeriesSlot;
|
||||
}
|
||||
|
||||
export interface BracketFocusState {
|
||||
seriesIds: ReadonlySet<SeriesId>;
|
||||
connectorKeys: ReadonlySet<string>;
|
||||
}
|
||||
|
||||
export interface HorizontalScrollMetrics {
|
||||
scrollLeft: number;
|
||||
scrollWidth: number;
|
||||
clientWidth: number;
|
||||
}
|
||||
|
||||
export interface HorizontalOverflowCues {
|
||||
showStart: boolean;
|
||||
showEnd: boolean;
|
||||
}
|
||||
|
||||
export function bracketConnectorKey(connector: BracketFocusConnector): string {
|
||||
return `${connector.fromSeriesId}:${connector.select}:${connector.toSeriesId}:${connector.toSlot}`;
|
||||
}
|
||||
|
||||
export function getBracketConnectorColorClass(
|
||||
kind: BracketConnectorKind,
|
||||
focused = false,
|
||||
): string {
|
||||
if (kind === "winner") return "text-bracket-winner";
|
||||
return focused ? "text-base-content" : "text-base-content/55";
|
||||
}
|
||||
|
||||
export function getBracketFocusState(
|
||||
connectors: readonly BracketFocusConnector[],
|
||||
activeSeriesId: SeriesId | null,
|
||||
): BracketFocusState {
|
||||
if (!activeSeriesId) {
|
||||
return {
|
||||
seriesIds: new Set(),
|
||||
connectorKeys: new Set(),
|
||||
};
|
||||
}
|
||||
|
||||
const seriesIds = new Set<SeriesId>([activeSeriesId]);
|
||||
const connectorKeys = new Set<string>();
|
||||
for (const connector of connectors) {
|
||||
if (
|
||||
connector.fromSeriesId !== activeSeriesId &&
|
||||
connector.toSeriesId !== activeSeriesId
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
seriesIds.add(connector.fromSeriesId);
|
||||
seriesIds.add(connector.toSeriesId);
|
||||
connectorKeys.add(bracketConnectorKey(connector));
|
||||
}
|
||||
|
||||
return { seriesIds, connectorKeys };
|
||||
}
|
||||
|
||||
export function getHorizontalOverflowCues({
|
||||
scrollLeft,
|
||||
scrollWidth,
|
||||
clientWidth,
|
||||
}: HorizontalScrollMetrics): HorizontalOverflowCues {
|
||||
const threshold = 1;
|
||||
const maxScrollLeft = Math.max(0, scrollWidth - clientWidth);
|
||||
if (maxScrollLeft <= threshold) {
|
||||
return { showStart: false, showEnd: false };
|
||||
}
|
||||
return {
|
||||
showStart: scrollLeft > threshold,
|
||||
showEnd: scrollLeft < maxScrollLeft - threshold,
|
||||
};
|
||||
}
|
||||
@@ -16,7 +16,7 @@ export type BracketConnectorKind = "winner" | "loser" | "reset";
|
||||
export const DOUBLE_ELIMINATION_BRACKET_GEOMETRY = {
|
||||
boardPadding: 12,
|
||||
columnWidth: 228,
|
||||
columnGap: 32,
|
||||
columnGap: 40,
|
||||
cardBorderWidth: SERIES_SCORE_CARD_GEOMETRY.borderWidth,
|
||||
cardHeight: SERIES_SCORE_CARD_GEOMETRY.height,
|
||||
cardHeaderHeight: SERIES_SCORE_CARD_GEOMETRY.headerHeight,
|
||||
@@ -29,6 +29,7 @@ export const DOUBLE_ELIMINATION_BRACKET_GEOMETRY = {
|
||||
export interface BracketNodeLayout {
|
||||
seriesId: SeriesId;
|
||||
label: string;
|
||||
accessibleLabel: string;
|
||||
stage: BracketStage;
|
||||
roundNumber: number;
|
||||
lane: BracketLane;
|
||||
@@ -52,6 +53,7 @@ export interface BracketConnectorLayout {
|
||||
targetY: number;
|
||||
path: string;
|
||||
label: string;
|
||||
accessibleLabel: string;
|
||||
}
|
||||
|
||||
export interface DoubleEliminationBracketConfiguration {
|
||||
@@ -63,6 +65,7 @@ export interface BracketRoundLayout {
|
||||
stage: BracketStage;
|
||||
roundNumber: number;
|
||||
label: string;
|
||||
accessibleLabel: string;
|
||||
lane: BracketLane;
|
||||
column: number;
|
||||
x: number;
|
||||
@@ -74,6 +77,7 @@ export interface MobileBracketGroup {
|
||||
stage: BracketStage;
|
||||
roundNumber: number;
|
||||
label: string;
|
||||
accessibleLabel: string;
|
||||
seriesIds: SeriesId[];
|
||||
}
|
||||
|
||||
@@ -101,6 +105,7 @@ interface NormalizedRound {
|
||||
stage: BracketStage;
|
||||
roundNumber: number;
|
||||
label: string;
|
||||
accessibleLabel: string;
|
||||
seriesIds: SeriesId[];
|
||||
}
|
||||
|
||||
@@ -170,11 +175,29 @@ export function bracketRoundLabel(
|
||||
stage: SeriesStageType,
|
||||
roundNumber?: number,
|
||||
): string {
|
||||
return formatBracketRoundLabel(stage, roundNumber, "R");
|
||||
}
|
||||
|
||||
export function bracketRoundAccessibleLabel(
|
||||
stage: SeriesStageType,
|
||||
roundNumber?: number,
|
||||
): string {
|
||||
return formatBracketRoundLabel(stage, roundNumber, "라운드");
|
||||
}
|
||||
|
||||
function formatBracketRoundLabel(
|
||||
stage: SeriesStageType,
|
||||
roundNumber: number | undefined,
|
||||
roundUnit: "R" | "라운드",
|
||||
): string {
|
||||
const round = roundNumber ?? 1;
|
||||
switch (stage) {
|
||||
case "upper":
|
||||
return `승자조 ${roundNumber ?? 1}라운드`;
|
||||
return round === 1
|
||||
? `브래킷 1${roundUnit}`
|
||||
: `브래킷 상위 ${round}${roundUnit}`;
|
||||
case "lower":
|
||||
return `패자조 ${roundNumber ?? 1}라운드`;
|
||||
return `브래킷 하위 ${round}${roundUnit}`;
|
||||
case "grand-final":
|
||||
return "그랜드 파이널";
|
||||
case "reset-final":
|
||||
@@ -182,7 +205,7 @@ export function bracketRoundLabel(
|
||||
case "pair":
|
||||
return "대진";
|
||||
case "round-robin":
|
||||
return `${roundNumber ?? 1}라운드`;
|
||||
return `${round}라운드`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,6 +333,10 @@ function normalizeRounds(
|
||||
stage: round.stage,
|
||||
roundNumber: round.roundNumber,
|
||||
label: bracketRoundLabel(round.stage, round.roundNumber),
|
||||
accessibleLabel: bracketRoundAccessibleLabel(
|
||||
round.stage,
|
||||
round.roundNumber,
|
||||
),
|
||||
seriesIds: ids,
|
||||
});
|
||||
}
|
||||
@@ -460,7 +487,12 @@ function buildNodes(
|
||||
(laneGeometry.height * (index + 0.5)) / round.seriesIds.length;
|
||||
result.push({
|
||||
seriesId,
|
||||
label: seriesName(graph.seriesById.get(seriesId), round),
|
||||
label: seriesDisplayName(round, seriesId, round.label),
|
||||
accessibleLabel: seriesDisplayName(
|
||||
round,
|
||||
seriesId,
|
||||
round.accessibleLabel,
|
||||
),
|
||||
stage: round.stage,
|
||||
roundNumber: round.roundNumber,
|
||||
lane,
|
||||
@@ -570,7 +602,8 @@ function buildConnectors(
|
||||
targetX,
|
||||
targetY,
|
||||
path: `M ${number(sourceX)} ${number(sourceY)} H ${number(verticalX)} V ${number(targetY)} H ${number(targetX)}`,
|
||||
label: connectorLabel(connector, graph),
|
||||
label: connectorLabel(connector, graph, "label"),
|
||||
accessibleLabel: connectorLabel(connector, graph, "accessibleLabel"),
|
||||
});
|
||||
}
|
||||
return result.sort(
|
||||
@@ -592,13 +625,20 @@ function buildConnectors(
|
||||
function connectorLabel(
|
||||
connector: SeriesConnectorView,
|
||||
graph: ValidatedGraph,
|
||||
labelKey: "label" | "accessibleLabel",
|
||||
): string {
|
||||
const source = graph.seriesById.get(connector.from.seriesId);
|
||||
const target = graph.seriesById.get(connector.to.seriesId);
|
||||
const sourceRound = graph.roundBySeriesId.get(connector.from.seriesId);
|
||||
const targetRound = graph.roundBySeriesId.get(connector.to.seriesId);
|
||||
const sourceName = seriesName(source, sourceRound);
|
||||
const targetName = seriesName(target, targetRound);
|
||||
const sourceName = seriesDisplayName(
|
||||
sourceRound,
|
||||
connector.from.seriesId,
|
||||
sourceRound?.[labelKey],
|
||||
);
|
||||
const targetName = seriesDisplayName(
|
||||
targetRound,
|
||||
connector.to.seriesId,
|
||||
targetRound?.[labelKey],
|
||||
);
|
||||
const selection =
|
||||
connector.from.select === "winner"
|
||||
? "승자"
|
||||
@@ -610,16 +650,16 @@ function connectorLabel(
|
||||
return `${sourceName} ${selection} → ${targetName} ${connector.to.slot} 슬롯`;
|
||||
}
|
||||
|
||||
function seriesName(
|
||||
series: DoubleEliminationCompetitionProjection["series"][number] | undefined,
|
||||
function seriesDisplayName(
|
||||
round: NormalizedRound | undefined,
|
||||
seriesId: SeriesId,
|
||||
roundLabel: string | undefined,
|
||||
): string {
|
||||
if (series?.code) return series.code;
|
||||
if (!series || !round) return "알 수 없는 경기";
|
||||
const index = round.seriesIds.indexOf(series.seriesId);
|
||||
if (!round || !roundLabel) return "알 수 없는 경기";
|
||||
const index = round.seriesIds.indexOf(seriesId);
|
||||
return round.seriesIds.length > 1
|
||||
? `${round.label} ${index + 1}경기`
|
||||
: round.label;
|
||||
? `${roundLabel} · ${index + 1}경기`
|
||||
: roundLabel;
|
||||
}
|
||||
|
||||
function connectorAnchorY(
|
||||
|
||||
@@ -1,5 +1,80 @@
|
||||
import type { SeriesProjection, TeamId } from "@lolympus/contracts";
|
||||
|
||||
export type SeriesScoreCardTone =
|
||||
| "muted"
|
||||
| "ready"
|
||||
| "live"
|
||||
| "completed"
|
||||
| "adjudicated";
|
||||
|
||||
export interface SeriesScoreCardPresentation {
|
||||
label: string;
|
||||
tone: SeriesScoreCardTone;
|
||||
showScore: boolean;
|
||||
}
|
||||
|
||||
export function getSeriesScoreCardIdentity(
|
||||
series: SeriesProjection,
|
||||
displayLabel?: string,
|
||||
): { label: string; code: string | undefined } {
|
||||
const label = displayLabel ?? series.code ?? "Series";
|
||||
return {
|
||||
label,
|
||||
code: series.code && series.code !== label ? series.code : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
export function getSeriesScoreCardPresentation(
|
||||
series: SeriesProjection,
|
||||
): SeriesScoreCardPresentation {
|
||||
switch (series.status) {
|
||||
case "inactive":
|
||||
return { label: "비활성", tone: "muted", showScore: false };
|
||||
case "waiting":
|
||||
return { label: "대진 대기", tone: "muted", showScore: false };
|
||||
case "ready":
|
||||
return { label: "경기 가능", tone: "ready", showScore: false };
|
||||
case "in-progress":
|
||||
return { label: "진행 중", tone: "live", showScore: true };
|
||||
case "completed":
|
||||
return completedSeriesPresentation(series);
|
||||
}
|
||||
}
|
||||
|
||||
export function formatSeriesScore(
|
||||
series: SeriesProjection,
|
||||
gameWins: number,
|
||||
): string {
|
||||
return getSeriesScoreCardPresentation(series).showScore
|
||||
? String(gameWins)
|
||||
: "—";
|
||||
}
|
||||
|
||||
export function getSeriesScoreCardAccessibleLabel(
|
||||
series: SeriesProjection,
|
||||
displayLabel: string | undefined,
|
||||
teamById: ReadonlyMap<TeamId, { readonly name: string }>,
|
||||
): string {
|
||||
const identity = getSeriesScoreCardIdentity(series, displayLabel);
|
||||
const presentation = getSeriesScoreCardPresentation(series);
|
||||
const identityLabel = identity.code
|
||||
? `${identity.label}, 코드 ${identity.code}`
|
||||
: identity.label;
|
||||
const entries = series.entries.map((entry) => {
|
||||
const teamName = entry.teamId
|
||||
? (teamById.get(entry.teamId)?.name ?? "알 수 없는 팀")
|
||||
: "대기 중";
|
||||
const score = formatSeriesScore(series, entry.gameWins);
|
||||
const scoreLabel = score === "—" ? "점수 없음" : `${score}승`;
|
||||
const winnerLabel = isSeriesEntryWinner(series, entry.teamId)
|
||||
? ", 승리"
|
||||
: "";
|
||||
return `${entry.slot} ${teamName}, ${scoreLabel}${winnerLabel}.`;
|
||||
});
|
||||
|
||||
return `${identityLabel}, ${presentation.label}. ${entries.join(" ")}`;
|
||||
}
|
||||
|
||||
export function isSeriesEntryWinner(
|
||||
series: SeriesProjection,
|
||||
teamId: TeamId | null,
|
||||
@@ -11,3 +86,26 @@ export function isSeriesEntryWinner(
|
||||
series.outcome.winnerTeamId === teamId
|
||||
);
|
||||
}
|
||||
|
||||
function completedSeriesPresentation(
|
||||
series: Extract<SeriesProjection, { status: "completed" }>,
|
||||
): SeriesScoreCardPresentation {
|
||||
switch (series.outcome.type) {
|
||||
case "played":
|
||||
return { label: "종료", tone: "completed", showScore: true };
|
||||
case "draw": {
|
||||
const played = series.outcome.basis.type === "played";
|
||||
return {
|
||||
label: "무승부",
|
||||
tone: played ? "completed" : "adjudicated",
|
||||
showScore: played,
|
||||
};
|
||||
}
|
||||
case "walkover":
|
||||
return { label: "부전승", tone: "adjudicated", showScore: false };
|
||||
case "forfeit":
|
||||
return { label: "기권승", tone: "adjudicated", showScore: false };
|
||||
case "administrative":
|
||||
return { label: "판정", tone: "adjudicated", showScore: false };
|
||||
}
|
||||
}
|
||||
+16
-10
@@ -8,6 +8,15 @@
|
||||
dark;
|
||||
}
|
||||
|
||||
/* ── 브랜드 원색 ──
|
||||
실제 색상값은 이곳에서만 관리하고, 화면에서는 아래의 의미 토큰을 사용한다. */
|
||||
@theme static {
|
||||
--color-brand-coral: oklch(0.708008 0.234375 24);
|
||||
--color-brand-violet: oklch(0.481934 0.285938 285);
|
||||
--color-brand-gold: oklch(0.853027 0.2 90);
|
||||
--color-brand-cyan: oklch(70% 0.14523 200);
|
||||
}
|
||||
|
||||
html {
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
@@ -68,6 +77,7 @@ body {
|
||||
--color-content-subtle: var(--lts-content-subtle);
|
||||
--color-content-muted: var(--lts-content-muted);
|
||||
--color-content-disabled: var(--lts-content-disabled);
|
||||
--color-bracket-winner: var(--color-brand-coral);
|
||||
}
|
||||
|
||||
@layer utilities {
|
||||
@@ -89,28 +99,24 @@ body {
|
||||
}
|
||||
}
|
||||
|
||||
/* ════════════════════════════════════════════════════════════
|
||||
🎛️ 튜닝 패널 (실험용) — 값만 바꾸면 dev에서 즉시 반영(HMR).
|
||||
확정되면 element로 전환한 뒤 이 블록을 통째로 제거할 것.
|
||||
색은 oklch(밝기% 채도 색상) 형식.
|
||||
════════════════════════════════════════════════════════════ */
|
||||
/* ── 라이트 테마 의미 색상 ── */
|
||||
[data-theme="light"] {
|
||||
/* ── 포인트 4색 (primary 주 액션 / secondary 강조 / accent 하이라이트 / info 정보·보조) ── */
|
||||
|
||||
/* 코랄레드 — primary 117곳 즉시 반영 */
|
||||
--color-primary: oklch(0.708008 0.234375 24);
|
||||
--color-primary: var(--color-brand-coral);
|
||||
--color-primary-content: oklch(98% 0 0); /* 흰 글자 */
|
||||
|
||||
/* 바이올렛 — 버튼·뱃지·보더용 */
|
||||
--color-secondary: oklch(0.481934 0.285938 285);
|
||||
--color-secondary: var(--color-brand-violet);
|
||||
--color-secondary-content: oklch(98% 0 0); /* 흰 글자 */
|
||||
|
||||
/* 골드 — 배경·보더·아이콘만. 텍스트색(text-accent)으론 쓰지 말 것 */
|
||||
--color-accent: oklch(0.853027 0.2 90);
|
||||
--color-accent: var(--color-brand-gold);
|
||||
--color-accent-content: oklch(22% 0.03 80); /* 어두운 글자 */
|
||||
|
||||
/* 시안 — 정보·링크·보조 강조. L70이라 흰배경 텍스트는 약함 → 배경/보더 위주 */
|
||||
--color-info: oklch(70% 0.14523 200);
|
||||
--color-info: var(--color-brand-cyan);
|
||||
--color-info-content: oklch(24% 0.03 215); /* 어두운 글자 */
|
||||
|
||||
/* 텍스트 기본 진하기 (회색 알파의 기준색). 낮출수록 전체가 진해짐 */
|
||||
@@ -125,7 +131,7 @@ body {
|
||||
/* 경기 결과 기록의 링크 강조는 양쪽 테마에서 같은 브랜드 코랄을 쓴다.
|
||||
전역 dark primary는 유지해 다른 화면의 기존 색상 의미를 바꾸지 않는다. */
|
||||
.competition-series-history {
|
||||
--color-primary: oklch(0.708008 0.234375 24);
|
||||
--color-primary: var(--color-brand-coral);
|
||||
}
|
||||
|
||||
/* ── 실시간 입찰 피드백 모션 ──
|
||||
|
||||
@@ -1,15 +1,27 @@
|
||||
import type { CompetitionDetailResponse } from "@lolympus/contracts";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import type {
|
||||
CompetitionDetailResponse,
|
||||
SeriesProjection,
|
||||
} from "@lolympus/contracts";
|
||||
import { ArrowLeft, ChevronDown, UsersRound } from "lucide-react";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { Link, useParams, useSearchParams } from "react-router";
|
||||
import { useCompetition, useTeamCompetition } from "../api/hooks";
|
||||
import { SeriesScoreCard } from "../components/competition/SeriesScoreCard";
|
||||
import { TeamSeriesCard } from "../components/competition/TeamSeriesCard";
|
||||
import { TeamTournamentCodes } from "../components/competition/TeamTournamentCodes";
|
||||
import { DEFAULT_COMMUNITY_ID } from "../config";
|
||||
import { positionLabel } from "../lib/league";
|
||||
import {
|
||||
getTeamProgressErrorContent,
|
||||
isConsistentTeamProgressSnapshot,
|
||||
shouldOfferTeamSelection,
|
||||
type TeamProgressErrorContent,
|
||||
} from "./match-team-progress-state";
|
||||
import {
|
||||
createTeamSeriesGroups,
|
||||
getTeamSeriesDisplayLabel,
|
||||
sortCompletedTeamSeries,
|
||||
sortTeamMembersForRoster,
|
||||
} from "./match-team-progress-view";
|
||||
|
||||
export default function MatchTeamProgressPage() {
|
||||
const { id } = useParams();
|
||||
@@ -24,10 +36,11 @@ export default function MatchTeamProgressPage() {
|
||||
);
|
||||
const refetchCompetition = competitionQuery.refetch;
|
||||
const refetchTeam = teamQuery.refetch;
|
||||
const [copiedSlotId, setCopiedSlotId] = useState<string | null>(null);
|
||||
const lastAutoRefetchedMismatchRef = useRef<string | null>(null);
|
||||
const contentHeadingRef = useRef<HTMLHeadingElement>(null);
|
||||
const competition = competitionQuery.data;
|
||||
const teamView = teamQuery.data;
|
||||
const teamViewId = teamView?.teamId;
|
||||
const hasQueryError = Boolean(
|
||||
competitionQuery.error || teamQuery.error,
|
||||
);
|
||||
@@ -66,6 +79,11 @@ export default function MatchTeamProgressPage() {
|
||||
revisionMismatchKey,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isSelectingTeam || !teamViewId || !revisionsMatch) return;
|
||||
contentHeadingRef.current?.focus({ preventScroll: true });
|
||||
}, [isSelectingTeam, revisionsMatch, teamViewId]);
|
||||
|
||||
function retryBoth() {
|
||||
void Promise.all([refetchCompetition(), refetchTeam()]).catch(
|
||||
() => undefined,
|
||||
@@ -136,179 +154,191 @@ export default function MatchTeamProgressPage() {
|
||||
competition.teams.map((team) => [team.teamId, team]),
|
||||
);
|
||||
const team = teamById.get(teamView.teamId);
|
||||
const completedSeries = competition.projection.series.filter(
|
||||
(series) =>
|
||||
series.status === "completed" &&
|
||||
series.entries.some((entry) => entry.teamId === teamView.teamId),
|
||||
const activeSeriesGroups = createTeamSeriesGroups(
|
||||
teamView.activeSeries,
|
||||
teamView.tournamentCodes,
|
||||
);
|
||||
|
||||
async function copyCode(gameSlotId: string, code: string | null) {
|
||||
if (!code) return;
|
||||
try {
|
||||
await navigator.clipboard.writeText(code);
|
||||
setCopiedSlotId(gameSlotId);
|
||||
window.setTimeout(() => setCopiedSlotId(null), 1500);
|
||||
} catch {
|
||||
setCopiedSlotId(null);
|
||||
}
|
||||
}
|
||||
const completedSeries = sortCompletedTeamSeries(
|
||||
competition.projection.series.filter(
|
||||
(
|
||||
series,
|
||||
): series is Extract<SeriesProjection, { status: "completed" }> =>
|
||||
series.status === "completed" &&
|
||||
series.entries.some((entry) => entry.teamId === teamView.teamId),
|
||||
),
|
||||
);
|
||||
const recentSeries = completedSeries.slice(0, 2);
|
||||
const olderSeries = completedSeries.slice(2);
|
||||
const rounds = competition.projection.rounds;
|
||||
|
||||
return (
|
||||
<main className="mx-auto max-w-5xl px-4 py-6 sm:px-6">
|
||||
<Link
|
||||
to={`/match/${id}`}
|
||||
className="mb-5 inline-flex text-xs text-base-content/40 hover:text-base-content"
|
||||
className="mb-5 inline-flex min-h-11 items-center gap-1.5 text-sm font-bold text-content-muted hover:text-base-content focus-visible:ring-2 focus-visible:ring-primary"
|
||||
>
|
||||
← 내전 상세로
|
||||
<ArrowLeft className="h-4 w-4" aria-hidden="true" />
|
||||
내전 상세로
|
||||
</Link>
|
||||
|
||||
<header className="mb-6 border-b border-base-content/10 pb-5">
|
||||
<p className="text-[11px] font-bold uppercase tracking-wider text-base-content/35">
|
||||
{selectedTeamId ? "Team Competition" : "My Competition"}
|
||||
</p>
|
||||
<h1 className="mt-1 text-2xl font-black">
|
||||
{team?.name ?? (selectedTeamId ? "팀" : "내 팀")}
|
||||
</h1>
|
||||
<p className="mt-1 text-sm text-base-content/45">
|
||||
해당 팀의 공식 대진과 토너먼트 코드가 표시됩니다.
|
||||
</p>
|
||||
<header className="mb-8 flex flex-col gap-4 border-b border-base-content/10 pb-6 sm:flex-row sm:items-end sm:justify-between">
|
||||
<div className="min-w-0">
|
||||
<p className="text-xs font-bold text-content-muted">팀 경기 현황</p>
|
||||
<h1
|
||||
ref={contentHeadingRef}
|
||||
className="mt-1 min-w-0 break-words text-2xl font-black sm:text-3xl"
|
||||
tabIndex={-1}
|
||||
>
|
||||
{team?.name ?? (selectedTeamId ? "팀" : "내 팀")}
|
||||
</h1>
|
||||
<p className="mt-2 max-w-2xl text-sm text-content-muted">
|
||||
다음 상대와 세트별 토너먼트 코드를 한곳에서 확인할 수 있습니다.
|
||||
</p>
|
||||
</div>
|
||||
<Link
|
||||
to={`/match/${id}/team?select=1`}
|
||||
className="mt-2 inline-flex text-xs text-base-content/40 hover:text-primary"
|
||||
className="inline-flex min-h-11 shrink-0 items-center justify-center gap-2 border border-base-content/20 bg-base-100 px-3 text-sm font-bold text-base-content hover:border-primary/40 hover:bg-primary/5 focus-visible:ring-2 focus-visible:ring-primary"
|
||||
>
|
||||
다른 팀 보기
|
||||
<UsersRound className="h-4 w-4" aria-hidden="true" />
|
||||
팀 변경
|
||||
</Link>
|
||||
</header>
|
||||
|
||||
<section className="mb-6" aria-labelledby="active-series-heading">
|
||||
<h2
|
||||
<section className="mb-8" aria-labelledby="active-series-heading">
|
||||
<SectionHeading
|
||||
id="active-series-heading"
|
||||
className="mb-3 text-xs font-bold uppercase tracking-wider text-base-content/40"
|
||||
>
|
||||
진행할 Series
|
||||
</h2>
|
||||
{teamView.activeSeries.length > 0 ? (
|
||||
<div className="grid gap-3 md:grid-cols-2">
|
||||
{teamView.activeSeries.map((series) => (
|
||||
<SeriesScoreCard
|
||||
key={series.seriesId}
|
||||
series={series}
|
||||
teamById={teamById}
|
||||
/>
|
||||
))}
|
||||
title="다음 경기"
|
||||
description="현재 팀이 준비하거나 진행해야 하는 공식 대진입니다."
|
||||
/>
|
||||
{activeSeriesGroups.length > 0 ? (
|
||||
<div className="space-y-4">
|
||||
{activeSeriesGroups.map(({ series, codes }) => {
|
||||
const displayLabel = getTeamSeriesDisplayLabel(series, rounds);
|
||||
return (
|
||||
<TeamSeriesCard
|
||||
key={series.seriesId}
|
||||
series={series}
|
||||
displayLabel={displayLabel}
|
||||
teamById={teamById}
|
||||
highlightedTeamId={teamView.teamId}
|
||||
emphasized
|
||||
>
|
||||
<TeamTournamentCodes
|
||||
assignments={codes}
|
||||
seriesLabel={displayLabel}
|
||||
/>
|
||||
</TeamSeriesCard>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
) : (
|
||||
<EmptyState message="현재 진행할 대진이 없습니다." />
|
||||
)}
|
||||
</section>
|
||||
|
||||
<section className="mb-6" aria-labelledby="codes-heading">
|
||||
<h2
|
||||
id="codes-heading"
|
||||
className="mb-3 text-xs font-bold uppercase tracking-wider text-base-content/40"
|
||||
>
|
||||
토너먼트 코드
|
||||
</h2>
|
||||
{teamView.tournamentCodes.length > 0 ? (
|
||||
<ul className="grid gap-3 sm:grid-cols-2">
|
||||
{teamView.tournamentCodes.map((assignment) => (
|
||||
<li
|
||||
key={assignment.gameSlotId}
|
||||
className="border border-base-content/10 bg-base-100 p-4"
|
||||
>
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<span className="text-xs font-bold text-base-content/45">
|
||||
Game {assignment.displayNumber}
|
||||
</span>
|
||||
<span className="text-[11px] text-base-content/35">
|
||||
{assignment.state === "used"
|
||||
? "사용됨"
|
||||
: assignment.state === "reserved"
|
||||
? "사용 가능"
|
||||
: "발급 대기"}
|
||||
</span>
|
||||
</div>
|
||||
<div className="mt-3 flex items-center gap-2">
|
||||
<code className="min-w-0 flex-1 truncate font-mono text-sm font-bold text-primary">
|
||||
{assignment.code ?? "발급 대기"}
|
||||
</code>
|
||||
{assignment.code && assignment.state !== "used" && (
|
||||
<button
|
||||
type="button"
|
||||
className="border border-base-content/10 px-2 py-1 text-xs font-bold hover:border-primary/30 hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"
|
||||
onClick={() =>
|
||||
void copyCode(assignment.gameSlotId, assignment.code)
|
||||
}
|
||||
>
|
||||
{copiedSlotId === assignment.gameSlotId
|
||||
? "복사됨"
|
||||
: "복사"}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<EmptyState message="배정된 토너먼트 코드가 없습니다." />
|
||||
)}
|
||||
</section>
|
||||
|
||||
<section className="mb-6" aria-labelledby="completed-heading">
|
||||
<h2
|
||||
id="completed-heading"
|
||||
className="mb-3 text-xs font-bold uppercase tracking-wider text-base-content/40"
|
||||
>
|
||||
종료된 Series
|
||||
</h2>
|
||||
{completedSeries.length > 0 ? (
|
||||
<div className="grid gap-3 md:grid-cols-2">
|
||||
{completedSeries.map((series) => (
|
||||
<SeriesScoreCard
|
||||
key={series.seriesId}
|
||||
series={series}
|
||||
teamById={teamById}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<EmptyState message="아직 종료된 대진이 없습니다." />
|
||||
<EmptyState message="현재 준비하거나 진행할 대진이 없습니다." />
|
||||
)}
|
||||
</section>
|
||||
|
||||
{team && (
|
||||
<section className="border border-base-content/10 bg-base-100">
|
||||
<h2 className="border-b border-base-content/10 bg-base-200/40 px-4 py-2 text-xs font-bold uppercase tracking-wider text-base-content/40">
|
||||
팀 구성
|
||||
</h2>
|
||||
<ul className="divide-y divide-base-content/8">
|
||||
{team.members.map((member) => (
|
||||
<section className="mb-8" aria-labelledby="roster-heading">
|
||||
<SectionHeading
|
||||
id="roster-heading"
|
||||
title="팀 구성"
|
||||
description={`${team.members.length}명의 라인업을 포지션 순서로 보여줍니다.`}
|
||||
/>
|
||||
<ul className="divide-y divide-base-content/10 border border-base-content/10 bg-base-100">
|
||||
{sortTeamMembersForRoster(team.members).map((member) => (
|
||||
<li
|
||||
key={member.userId}
|
||||
className="flex items-center gap-3 px-4 py-3"
|
||||
className="grid min-h-12 grid-cols-[4.5rem_minmax(0,1fr)] items-center gap-3 px-4 py-2 sm:px-5"
|
||||
>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="truncate text-sm font-bold">
|
||||
<span className="text-xs font-bold text-content-muted">
|
||||
{member.assignedPosition
|
||||
? positionLabel[member.assignedPosition]
|
||||
: "미정"}
|
||||
</span>
|
||||
<div className="flex min-w-0 flex-wrap items-center gap-2">
|
||||
<span className="min-w-0 break-words text-sm font-bold text-base-content">
|
||||
{member.displayName}
|
||||
</p>
|
||||
{member.assignedPosition && (
|
||||
<p className="mt-0.5 text-xs text-base-content/35">
|
||||
{member.assignedPosition}
|
||||
</p>
|
||||
</span>
|
||||
{member.userId === team.captainUserId && (
|
||||
<span className="border-l-2 border-warning bg-warning/15 px-1.5 py-0.5 text-[11px] font-bold text-base-content">
|
||||
팀장
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{member.userId === team.captainUserId && (
|
||||
<span className="text-xs font-bold text-warning">팀장</span>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
)}
|
||||
|
||||
<section className="mb-6" aria-labelledby="completed-heading">
|
||||
<SectionHeading
|
||||
id="completed-heading"
|
||||
title="지난 경기"
|
||||
description="최근 결과를 먼저 보여주며, 오래된 결과는 펼쳐서 확인할 수 있습니다."
|
||||
/>
|
||||
{completedSeries.length > 0 ? (
|
||||
<>
|
||||
<div className="grid gap-3 md:grid-cols-2">
|
||||
{recentSeries.map((series) => (
|
||||
<TeamSeriesCard
|
||||
key={series.seriesId}
|
||||
series={series}
|
||||
displayLabel={getTeamSeriesDisplayLabel(series, rounds)}
|
||||
teamById={teamById}
|
||||
highlightedTeamId={teamView.teamId}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
{olderSeries.length > 0 && (
|
||||
<details className="group mt-3 border border-base-content/10 bg-base-100">
|
||||
<summary className="flex min-h-11 cursor-pointer list-none items-center justify-between gap-3 px-4 text-sm font-bold text-base-content hover:bg-base-200/50 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary [&::-webkit-details-marker]:hidden">
|
||||
<span>이전 경기 {olderSeries.length}개 더 보기</span>
|
||||
<ChevronDown
|
||||
className="h-4 w-4 transition-transform group-open:rotate-180 motion-reduce:transition-none"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</summary>
|
||||
<div className="grid gap-3 border-t border-base-content/10 p-3 md:grid-cols-2">
|
||||
{olderSeries.map((series) => (
|
||||
<TeamSeriesCard
|
||||
key={series.seriesId}
|
||||
series={series}
|
||||
displayLabel={getTeamSeriesDisplayLabel(series, rounds)}
|
||||
teamById={teamById}
|
||||
highlightedTeamId={teamView.teamId}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</details>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<EmptyState message="아직 종료된 대진이 없습니다." />
|
||||
)}
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
function SectionHeading({
|
||||
id,
|
||||
title,
|
||||
description,
|
||||
}: {
|
||||
id: string;
|
||||
title: string;
|
||||
description: string;
|
||||
}) {
|
||||
return (
|
||||
<div className="mb-3 border-b border-base-content/10 pb-2">
|
||||
<h2 id={id} className="text-base font-black text-base-content">
|
||||
{title}
|
||||
</h2>
|
||||
<p className="mt-0.5 text-xs text-content-muted">{description}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function TeamSelectionState({
|
||||
competition,
|
||||
matchId,
|
||||
@@ -316,21 +346,28 @@ function TeamSelectionState({
|
||||
competition: CompetitionDetailResponse;
|
||||
matchId: string | undefined;
|
||||
}) {
|
||||
const headingRef = useRef<HTMLHeadingElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
headingRef.current?.focus({ preventScroll: true });
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<main className="mx-auto max-w-5xl px-4 py-6 sm:px-6">
|
||||
<Link
|
||||
to={`/match/${matchId}`}
|
||||
className="mb-5 inline-flex text-xs text-base-content/40 hover:text-base-content"
|
||||
className="mb-5 inline-flex min-h-11 items-center gap-1.5 text-sm font-bold text-content-muted hover:text-base-content focus-visible:ring-2 focus-visible:ring-primary"
|
||||
>
|
||||
← 내전 상세로
|
||||
<ArrowLeft className="h-4 w-4" aria-hidden="true" />
|
||||
내전 상세로
|
||||
</Link>
|
||||
|
||||
<header className="mb-6 border-b border-base-content/10 pb-5">
|
||||
<p className="text-[11px] font-bold uppercase tracking-wider text-base-content/35">
|
||||
Team Competition
|
||||
</p>
|
||||
<h1 className="mt-1 text-2xl font-black">팀 선택</h1>
|
||||
<p className="mt-1 text-sm text-base-content/45">
|
||||
<p className="text-xs font-bold text-content-muted">팀 경기 현황</p>
|
||||
<h1 ref={headingRef} className="mt-1 text-2xl font-black" tabIndex={-1}>
|
||||
팀 선택
|
||||
</h1>
|
||||
<p className="mt-1 text-sm text-content-muted">
|
||||
진행 상황과 토너먼트 코드를 확인할 팀을 선택해 주세요.
|
||||
</p>
|
||||
</header>
|
||||
@@ -341,12 +378,12 @@ function TeamSelectionState({
|
||||
<li key={team.teamId}>
|
||||
<Link
|
||||
to={`/match/${matchId}/team?teamId=${team.teamId}`}
|
||||
className="flex items-center justify-between gap-3 border border-base-content/10 bg-base-100 px-4 py-4 hover:border-primary/30 hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"
|
||||
className="flex min-h-12 items-center justify-between gap-3 border border-base-content/10 bg-base-100 px-4 py-3 text-base-content hover:border-primary/40 hover:bg-primary/5 focus-visible:ring-2 focus-visible:ring-primary"
|
||||
>
|
||||
<span className="min-w-0 truncate text-sm font-bold">
|
||||
<span className="min-w-0 break-words text-sm font-bold">
|
||||
{team.name}
|
||||
</span>
|
||||
<span className="shrink-0 text-xs text-base-content/35">
|
||||
<span className="shrink-0 text-xs text-content-muted">
|
||||
{team.members.length}명
|
||||
</span>
|
||||
</Link>
|
||||
@@ -366,9 +403,11 @@ function TeamProgressLoadingState() {
|
||||
className="mx-auto max-w-5xl space-y-3 px-4 py-12 sm:px-6"
|
||||
aria-busy="true"
|
||||
aria-label="팀 진행 정보를 불러오는 중"
|
||||
role="status"
|
||||
>
|
||||
<div className="h-7 w-48 animate-pulse bg-base-200" />
|
||||
<div className="h-32 animate-pulse bg-base-200/70" />
|
||||
<span className="sr-only">팀 진행 정보를 불러오는 중입니다.</span>
|
||||
<div className="h-7 w-48 animate-pulse bg-base-200 motion-reduce:animate-none" />
|
||||
<div className="h-32 animate-pulse bg-base-200/70 motion-reduce:animate-none" />
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -384,6 +423,12 @@ function TeamProgressProblemState({
|
||||
matchId: string | undefined;
|
||||
onRetry: () => void;
|
||||
}) {
|
||||
const headingRef = useRef<HTMLHeadingElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
headingRef.current?.focus({ preventScroll: true });
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<main className="mx-auto max-w-5xl px-4 py-20 sm:px-6">
|
||||
<section
|
||||
@@ -391,20 +436,25 @@ function TeamProgressProblemState({
|
||||
aria-busy={isRetrying}
|
||||
className="border border-base-content/10 bg-base-100 px-5 py-8 text-center"
|
||||
>
|
||||
<h1 className="text-lg font-bold">{content.title}</h1>
|
||||
<p className="mt-2 text-sm text-base-content/45">
|
||||
<h1 ref={headingRef} className="text-lg font-bold" tabIndex={-1}>
|
||||
{content.title}
|
||||
</h1>
|
||||
<p className="mt-2 text-sm text-content-muted">
|
||||
{content.description}
|
||||
</p>
|
||||
<div className="mt-5 flex flex-wrap justify-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary btn-sm"
|
||||
className="inline-flex min-h-11 items-center justify-center border border-primary/50 bg-primary/10 px-4 text-sm font-bold text-base-content hover:bg-primary/15 focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-wait disabled:opacity-70"
|
||||
disabled={isRetrying}
|
||||
onClick={onRetry}
|
||||
>
|
||||
{isRetrying ? "다시 불러오는 중..." : "다시 시도"}
|
||||
</button>
|
||||
<Link to={`/match/${matchId}`} className="btn btn-ghost btn-sm">
|
||||
<Link
|
||||
to={`/match/${matchId}`}
|
||||
className="inline-flex min-h-11 items-center justify-center border border-base-content/20 bg-base-100 px-4 text-sm font-bold text-base-content hover:bg-base-200 focus-visible:ring-2 focus-visible:ring-primary"
|
||||
>
|
||||
내전 상세로
|
||||
</Link>
|
||||
</div>
|
||||
@@ -417,7 +467,7 @@ function EmptyState({ message }: { message: string }) {
|
||||
return (
|
||||
<p
|
||||
role="status"
|
||||
className="border border-dashed border-base-content/10 px-4 py-8 text-center text-sm text-base-content/40"
|
||||
className="border border-dashed border-base-content/10 px-4 py-8 text-center text-sm text-content-muted"
|
||||
>
|
||||
{message}
|
||||
</p>
|
||||
|
||||
@@ -0,0 +1,274 @@
|
||||
import type {
|
||||
BracketRoundView,
|
||||
CompetitionTeamMemberView,
|
||||
SeriesProjection,
|
||||
TeamTournamentCodeView,
|
||||
} from "@lolympus/contracts";
|
||||
import { bracketRoundLabel } from "../components/competition/double-elimination-bracket-layout.ts";
|
||||
|
||||
export interface TeamSeriesGroup {
|
||||
series: SeriesProjection;
|
||||
codes: TeamTournamentCodeView[];
|
||||
}
|
||||
|
||||
export type TeamSeriesTone =
|
||||
| "muted"
|
||||
| "ready"
|
||||
| "live"
|
||||
| "completed"
|
||||
| "adjudicated";
|
||||
|
||||
export interface TeamSeriesPresentation {
|
||||
label: string;
|
||||
tone: TeamSeriesTone;
|
||||
showScore: boolean;
|
||||
}
|
||||
|
||||
export type TournamentCodeTone =
|
||||
| "pending"
|
||||
| "available"
|
||||
| "expired"
|
||||
| "used";
|
||||
|
||||
export interface TournamentCodePresentation {
|
||||
label: string;
|
||||
tone: TournamentCodeTone;
|
||||
canCopy: boolean;
|
||||
}
|
||||
|
||||
export type TournamentCodeCopyFeedback =
|
||||
| { kind: "success"; message: string }
|
||||
| { kind: "error"; message: string };
|
||||
|
||||
type ClipboardWriter = ((value: string) => Promise<void>) | undefined;
|
||||
|
||||
const POSITION_RANK = new Map(
|
||||
(["TOP", "JGL", "MID", "ADC", "SUP"] as const).map(
|
||||
(position, index) => [position, index],
|
||||
),
|
||||
);
|
||||
|
||||
export function createTeamSeriesGroups(
|
||||
activeSeries: readonly SeriesProjection[],
|
||||
tournamentCodes: readonly TeamTournamentCodeView[],
|
||||
): TeamSeriesGroup[] {
|
||||
const codesBySeriesId = new Map<string, TeamTournamentCodeView[]>();
|
||||
for (const assignment of tournamentCodes) {
|
||||
const seriesId = String(assignment.seriesId);
|
||||
const existing = codesBySeriesId.get(seriesId) ?? [];
|
||||
existing.push(assignment);
|
||||
codesBySeriesId.set(seriesId, existing);
|
||||
}
|
||||
|
||||
return [...activeSeries]
|
||||
.sort(compareSeriesDisplayOrder)
|
||||
.map((series) => ({
|
||||
series,
|
||||
codes: [...(codesBySeriesId.get(String(series.seriesId)) ?? [])].sort(
|
||||
compareTournamentCodes,
|
||||
),
|
||||
}));
|
||||
}
|
||||
|
||||
export function getTeamSeriesDisplayLabel(
|
||||
series: SeriesProjection,
|
||||
rounds: readonly BracketRoundView[],
|
||||
): string {
|
||||
const round = rounds.find(({ seriesIds }) =>
|
||||
seriesIds.some((seriesId) => seriesId === series.seriesId),
|
||||
);
|
||||
const stage = round?.stage ?? series.stage.type;
|
||||
const roundNumber = round?.roundNumber ?? series.stage.roundNumber ?? 1;
|
||||
const baseLabel = bracketRoundLabel(stage, roundNumber);
|
||||
|
||||
if (!round || round.seriesIds.length <= 1) return baseLabel;
|
||||
const matchIndex = round.seriesIds.findIndex(
|
||||
(seriesId) => seriesId === series.seriesId,
|
||||
);
|
||||
return matchIndex >= 0
|
||||
? `${baseLabel} · ${matchIndex + 1}경기`
|
||||
: baseLabel;
|
||||
}
|
||||
|
||||
export function getTeamSeriesPresentation(
|
||||
series: SeriesProjection,
|
||||
): TeamSeriesPresentation {
|
||||
switch (series.status) {
|
||||
case "inactive":
|
||||
return { label: "비활성", tone: "muted", showScore: false };
|
||||
case "waiting":
|
||||
return { label: "대진 대기", tone: "muted", showScore: false };
|
||||
case "ready":
|
||||
return { label: "경기 가능", tone: "ready", showScore: false };
|
||||
case "in-progress":
|
||||
return { label: "진행 중", tone: "live", showScore: true };
|
||||
case "completed":
|
||||
switch (series.outcome.type) {
|
||||
case "played":
|
||||
return { label: "종료", tone: "completed", showScore: true };
|
||||
case "draw":
|
||||
return {
|
||||
label: "무승부",
|
||||
tone:
|
||||
series.outcome.basis.type === "played"
|
||||
? "completed"
|
||||
: "adjudicated",
|
||||
showScore: series.outcome.basis.type === "played",
|
||||
};
|
||||
case "walkover":
|
||||
return { label: "부전승", tone: "adjudicated", showScore: false };
|
||||
case "forfeit":
|
||||
return { label: "기권승", tone: "adjudicated", showScore: false };
|
||||
case "administrative":
|
||||
return { label: "판정승", tone: "adjudicated", showScore: false };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getTournamentCodePresentation(
|
||||
assignment: TeamTournamentCodeView,
|
||||
now = Date.now(),
|
||||
): TournamentCodePresentation {
|
||||
if (assignment.state === "used") {
|
||||
return { label: "사용 완료", tone: "used", canCopy: false };
|
||||
}
|
||||
if (assignment.state === "pending" || !assignment.code) {
|
||||
return { label: "발급 대기", tone: "pending", canCopy: false };
|
||||
}
|
||||
if (
|
||||
assignment.expiresAt &&
|
||||
!Number.isFinite(Date.parse(assignment.expiresAt))
|
||||
) {
|
||||
return { label: "만료 정보 오류", tone: "expired", canCopy: false };
|
||||
}
|
||||
if (isExpired(assignment.expiresAt, now)) {
|
||||
return { label: "만료", tone: "expired", canCopy: false };
|
||||
}
|
||||
return { label: "사용 가능", tone: "available", canCopy: true };
|
||||
}
|
||||
|
||||
export function getTournamentCodeExpiryLabel(
|
||||
expiresAt: string,
|
||||
now: number,
|
||||
): string {
|
||||
const date = new Date(expiresAt);
|
||||
if (Number.isNaN(date.getTime())) return "만료 시각 정보 없음";
|
||||
|
||||
const formatted = new Intl.DateTimeFormat("ko-KR", {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
timeZone: "Asia/Seoul",
|
||||
timeZoneName: "short",
|
||||
}).format(date);
|
||||
return date.getTime() <= now
|
||||
? `${formatted}에 만료됨`
|
||||
: `${formatted}까지 사용 가능`;
|
||||
}
|
||||
|
||||
export function getNextTournamentCodeExpiryDelay(
|
||||
assignments: readonly TeamTournamentCodeView[],
|
||||
now: number,
|
||||
): number | null {
|
||||
let nearestExpiry = Number.POSITIVE_INFINITY;
|
||||
for (const assignment of assignments) {
|
||||
if (assignment.state !== "reserved" || !assignment.code) continue;
|
||||
const expiry = assignment.expiresAt
|
||||
? Date.parse(assignment.expiresAt)
|
||||
: Number.NaN;
|
||||
if (Number.isFinite(expiry) && expiry > now) {
|
||||
nearestExpiry = Math.min(nearestExpiry, expiry);
|
||||
}
|
||||
}
|
||||
|
||||
if (!Number.isFinite(nearestExpiry)) return null;
|
||||
return Math.min(nearestExpiry - now, 2_147_483_647);
|
||||
}
|
||||
|
||||
export function getTournamentCodeCopyLabel(
|
||||
assignment: TeamTournamentCodeView,
|
||||
seriesLabel: string,
|
||||
): string {
|
||||
return `${seriesLabel} ${assignment.ordinal}세트 토너먼트 코드 복사 (전체 ${assignment.displayNumber}번 게임)`;
|
||||
}
|
||||
|
||||
export async function copyTournamentCode(
|
||||
writeText: ClipboardWriter,
|
||||
code: string,
|
||||
gameLabel: string,
|
||||
): Promise<TournamentCodeCopyFeedback> {
|
||||
try {
|
||||
if (!writeText) throw new Error("Clipboard API unavailable");
|
||||
await writeText(code);
|
||||
return {
|
||||
kind: "success",
|
||||
message: `${gameLabel} 코드를 복사했습니다.`,
|
||||
};
|
||||
} catch {
|
||||
return {
|
||||
kind: "error",
|
||||
message: `${gameLabel} 코드를 복사하지 못했습니다. 코드를 직접 선택해 복사해 주세요.`,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function sortCompletedTeamSeries(
|
||||
series: readonly Extract<SeriesProjection, { status: "completed" }>[],
|
||||
): Array<Extract<SeriesProjection, { status: "completed" }>> {
|
||||
return [...series].sort(
|
||||
(left, right) =>
|
||||
timestampValue(right.outcome.completedAt) -
|
||||
timestampValue(left.outcome.completedAt) ||
|
||||
right.stage.displayOrder - left.stage.displayOrder ||
|
||||
String(left.seriesId).localeCompare(String(right.seriesId)),
|
||||
);
|
||||
}
|
||||
|
||||
export function sortTeamMembersForRoster(
|
||||
members: readonly CompetitionTeamMemberView[],
|
||||
): CompetitionTeamMemberView[] {
|
||||
return [...members].sort(
|
||||
(left, right) =>
|
||||
(left.assignedPosition
|
||||
? (POSITION_RANK.get(left.assignedPosition) ?? POSITION_RANK.size)
|
||||
: POSITION_RANK.size) -
|
||||
(right.assignedPosition
|
||||
? (POSITION_RANK.get(right.assignedPosition) ?? POSITION_RANK.size)
|
||||
: POSITION_RANK.size) ||
|
||||
left.displayName.localeCompare(right.displayName, "ko"),
|
||||
);
|
||||
}
|
||||
|
||||
function compareSeriesDisplayOrder(
|
||||
left: SeriesProjection,
|
||||
right: SeriesProjection,
|
||||
): number {
|
||||
return (
|
||||
left.stage.displayOrder - right.stage.displayOrder ||
|
||||
String(left.seriesId).localeCompare(String(right.seriesId))
|
||||
);
|
||||
}
|
||||
|
||||
function compareTournamentCodes(
|
||||
left: TeamTournamentCodeView,
|
||||
right: TeamTournamentCodeView,
|
||||
): number {
|
||||
return (
|
||||
left.ordinal - right.ordinal ||
|
||||
left.displayNumber - right.displayNumber ||
|
||||
String(left.gameSlotId).localeCompare(String(right.gameSlotId))
|
||||
);
|
||||
}
|
||||
|
||||
function isExpired(expiresAt: string | null, now: number): boolean {
|
||||
if (!expiresAt) return false;
|
||||
const timestamp = Date.parse(expiresAt);
|
||||
return Number.isFinite(timestamp) && timestamp <= now;
|
||||
}
|
||||
|
||||
function timestampValue(value: string): number {
|
||||
const timestamp = Date.parse(value);
|
||||
return Number.isFinite(timestamp) ? timestamp : Number.NEGATIVE_INFINITY;
|
||||
}
|
||||
@@ -12,8 +12,11 @@ import {
|
||||
competitionHistoryGameDetailPath,
|
||||
createCompetitionSeriesHistory,
|
||||
formatCompetitionHistoryDate,
|
||||
formatCompetitionHistoryDayHeading,
|
||||
formatCompetitionHistoryTime,
|
||||
formatSeriesGameDuration,
|
||||
getSeriesHistoryRecordLabel,
|
||||
getSeriesHistoryResultLabel,
|
||||
getSeriesHistoryStatusLabel,
|
||||
shouldDisplaySeriesHistoryScore,
|
||||
} from "../src/components/competition/competition-series-history.ts";
|
||||
@@ -234,74 +237,108 @@ test("sorts tied timestamps deterministically and ignores orphan Games", () => {
|
||||
assert.equal(rows.every(({ games }) => games.length === 0), true);
|
||||
});
|
||||
|
||||
test("returns explicit status labels for played and adjudicated outcomes", () => {
|
||||
test("separates lifecycle status from played and adjudicated result labels", () => {
|
||||
const teamA = teamId("team-a");
|
||||
const teamB = teamId("team-b");
|
||||
const running = inProgressSeries("running", teamA, teamB, 1, 0);
|
||||
const played = completedSeries({
|
||||
id: "played",
|
||||
teamA,
|
||||
teamB,
|
||||
scoreA: 2,
|
||||
scoreB: 1,
|
||||
});
|
||||
const playedDraw = completedSeries({
|
||||
id: "played-draw",
|
||||
teamA,
|
||||
teamB,
|
||||
scoreA: 1,
|
||||
scoreB: 1,
|
||||
outcome: "draw",
|
||||
});
|
||||
const administrativeDraw = {
|
||||
...playedDraw,
|
||||
seriesId: seriesId("administrative-draw-label"),
|
||||
outcome: {
|
||||
...playedDraw.outcome,
|
||||
basis: {
|
||||
type: "administrative" as const,
|
||||
decisionFactId: "draw-label-fact" as never,
|
||||
},
|
||||
},
|
||||
};
|
||||
const walkover = completedSeries({
|
||||
id: "walkover",
|
||||
teamA,
|
||||
teamB,
|
||||
scoreA: 0,
|
||||
scoreB: 0,
|
||||
outcome: "walkover",
|
||||
});
|
||||
const forfeit = completedSeries({
|
||||
id: "forfeit",
|
||||
teamA,
|
||||
teamB,
|
||||
scoreA: 1,
|
||||
scoreB: 1,
|
||||
outcome: "forfeit",
|
||||
});
|
||||
const administrative = completedSeries({
|
||||
id: "administrative",
|
||||
teamA,
|
||||
teamB,
|
||||
scoreA: 0,
|
||||
scoreB: 0,
|
||||
outcome: "administrative",
|
||||
});
|
||||
|
||||
assert.equal(getSeriesHistoryStatusLabel(running), "진행 중");
|
||||
for (const completed of [
|
||||
played,
|
||||
playedDraw,
|
||||
administrativeDraw,
|
||||
walkover,
|
||||
forfeit,
|
||||
administrative,
|
||||
]) {
|
||||
assert.equal(getSeriesHistoryStatusLabel(completed), "최종");
|
||||
}
|
||||
|
||||
assert.equal(getSeriesHistoryResultLabel(running), null);
|
||||
assert.equal(getSeriesHistoryResultLabel(played), null);
|
||||
assert.equal(getSeriesHistoryResultLabel(playedDraw), "무승부");
|
||||
assert.equal(
|
||||
getSeriesHistoryStatusLabel(
|
||||
inProgressSeries("running", teamA, teamB, 1, 0),
|
||||
),
|
||||
"진행 중",
|
||||
);
|
||||
assert.equal(
|
||||
getSeriesHistoryStatusLabel(
|
||||
completedSeries({ id: "played", teamA, teamB, scoreA: 2, scoreB: 1 }),
|
||||
),
|
||||
"종료",
|
||||
);
|
||||
assert.equal(
|
||||
getSeriesHistoryStatusLabel(
|
||||
completedSeries({
|
||||
id: "draw",
|
||||
teamA,
|
||||
teamB,
|
||||
scoreA: 1,
|
||||
scoreB: 1,
|
||||
outcome: "draw",
|
||||
}),
|
||||
),
|
||||
"무승부",
|
||||
);
|
||||
assert.equal(
|
||||
getSeriesHistoryStatusLabel(
|
||||
completedSeries({
|
||||
id: "walkover",
|
||||
teamA,
|
||||
teamB,
|
||||
scoreA: 0,
|
||||
scoreB: 0,
|
||||
outcome: "walkover",
|
||||
}),
|
||||
),
|
||||
"부전승",
|
||||
);
|
||||
assert.equal(
|
||||
getSeriesHistoryStatusLabel(
|
||||
completedSeries({
|
||||
id: "forfeit",
|
||||
teamA,
|
||||
teamB,
|
||||
scoreA: 1,
|
||||
scoreB: 1,
|
||||
outcome: "forfeit",
|
||||
}),
|
||||
),
|
||||
"기권승",
|
||||
);
|
||||
assert.equal(
|
||||
getSeriesHistoryStatusLabel(
|
||||
completedSeries({
|
||||
id: "administrative",
|
||||
teamA,
|
||||
teamB,
|
||||
scoreA: 0,
|
||||
scoreB: 0,
|
||||
outcome: "administrative",
|
||||
}),
|
||||
),
|
||||
"판정",
|
||||
getSeriesHistoryResultLabel(administrativeDraw),
|
||||
"판정 무승부",
|
||||
);
|
||||
assert.equal(getSeriesHistoryResultLabel(walkover), "부전승");
|
||||
assert.equal(getSeriesHistoryResultLabel(forfeit), "기권승");
|
||||
assert.equal(getSeriesHistoryResultLabel(administrative), "판정승");
|
||||
});
|
||||
|
||||
test("describes recorded Games, decisions, and legacy missing records", () => {
|
||||
const teamA = teamId("record-team-a");
|
||||
const teamB = teamId("record-team-b");
|
||||
const played = completedSeries({
|
||||
id: "recorded-played",
|
||||
teamA,
|
||||
teamB,
|
||||
scoreA: 2,
|
||||
scoreB: 0,
|
||||
});
|
||||
const decision = completedSeries({
|
||||
id: "recorded-decision",
|
||||
teamA,
|
||||
teamB,
|
||||
scoreA: 0,
|
||||
scoreB: 0,
|
||||
outcome: "walkover",
|
||||
});
|
||||
|
||||
assert.equal(getSeriesHistoryRecordLabel(played, 2, false), "게임 상세 (2)");
|
||||
assert.equal(getSeriesHistoryRecordLabel(played, 2, true), "게임 상세 접기");
|
||||
assert.equal(getSeriesHistoryRecordLabel(decision, 0, false), "경기 없이 결정");
|
||||
assert.equal(getSeriesHistoryRecordLabel(played, 0, false), "게임 기록 미등록");
|
||||
});
|
||||
|
||||
test("shows a numeric score only for played records", () => {
|
||||
@@ -386,12 +423,25 @@ test("formats recorded Game duration and omits unknown legacy zero values", () =
|
||||
});
|
||||
|
||||
test("formats history dates and times explicitly in Asia/Seoul", () => {
|
||||
assert.equal(formatCompetitionHistoryDate("2026-07-13"), "07월 13일 (월)");
|
||||
assert.equal(formatCompetitionHistoryDate("2026-07-05"), "7월 5일 (일)");
|
||||
assert.equal(formatCompetitionHistoryDate("2026-07-13"), "7월 13일 (월)");
|
||||
assert.equal(
|
||||
formatCompetitionHistoryDayHeading("2026-07-05", 1),
|
||||
"7월 5일 (일) · 1경기",
|
||||
);
|
||||
assert.equal(
|
||||
formatCompetitionHistoryDayHeading("2026-07-13", 2),
|
||||
"7월 13일 (월) · 2경기",
|
||||
);
|
||||
assert.equal(
|
||||
formatCompetitionHistoryTime("2026-07-12T15:05:00.000Z"),
|
||||
"00:05",
|
||||
);
|
||||
assert.equal(formatCompetitionHistoryDate("unknown"), "일시 정보 없음");
|
||||
assert.equal(
|
||||
formatCompetitionHistoryDayHeading("unknown", 1),
|
||||
"일시 정보 없음 · 1경기",
|
||||
);
|
||||
});
|
||||
|
||||
function playedSeriesWithGame({
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import test from "node:test";
|
||||
|
||||
const stylesheet = await readFile(
|
||||
new URL("../src/index.css", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
const BRAND_COLORS = {
|
||||
coral: "oklch(0.708008 0.234375 24)",
|
||||
violet: "oklch(0.481934 0.285938 285)",
|
||||
gold: "oklch(0.853027 0.2 90)",
|
||||
cyan: "oklch(70% 0.14523 200)",
|
||||
} as const;
|
||||
|
||||
test("defines each brand color once as a primitive token", () => {
|
||||
for (const [name, value] of Object.entries(BRAND_COLORS)) {
|
||||
assert.match(
|
||||
stylesheet,
|
||||
new RegExp(`--color-brand-${name}: ${escapeRegExp(value)};`),
|
||||
);
|
||||
assert.equal(
|
||||
stylesheet.split(value).length - 1,
|
||||
1,
|
||||
`${name} should have one literal source`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("maps the light theme semantic roles to the brand primitives", () => {
|
||||
const lightTheme = cssBlocksForSelector('[data-theme="light"]');
|
||||
const mappings = [
|
||||
["--color-primary", "--color-brand-coral"],
|
||||
["--color-secondary", "--color-brand-violet"],
|
||||
["--color-accent", "--color-brand-gold"],
|
||||
["--color-info", "--color-brand-cyan"],
|
||||
] as const;
|
||||
|
||||
for (const [semanticToken, primitiveToken] of mappings) {
|
||||
assert.match(
|
||||
lightTheme,
|
||||
new RegExp(
|
||||
`${escapeRegExp(semanticToken)}: var\\(${escapeRegExp(primitiveToken)}\\);`,
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("keeps coral scopes without overriding the global dark primary", () => {
|
||||
assert.match(
|
||||
stylesheet,
|
||||
/--color-bracket-winner: var\(--color-brand-coral\);/,
|
||||
);
|
||||
assert.match(
|
||||
stylesheet,
|
||||
/\.competition-series-history\s*{\s*--color-primary: var\(--color-brand-coral\);\s*}/,
|
||||
);
|
||||
|
||||
const darkTheme = cssBlocksForSelector('[data-theme="dark"]');
|
||||
assert.doesNotMatch(darkTheme, /--color-primary/);
|
||||
});
|
||||
|
||||
function cssBlocksForSelector(selector: string): string {
|
||||
const blocks = stylesheet.matchAll(
|
||||
new RegExp(`${escapeRegExp(selector)}\\s*{([^}]*)}`, "g"),
|
||||
);
|
||||
const contents = [...blocks].map((match) => match[1] ?? "").join("\n");
|
||||
assert.notEqual(contents, "", `${selector} should have a CSS block`);
|
||||
return contents;
|
||||
}
|
||||
|
||||
function escapeRegExp(value: string): string {
|
||||
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import type { SeriesId } from "@lolympus/contracts";
|
||||
import {
|
||||
bracketConnectorKey,
|
||||
getBracketConnectorColorClass,
|
||||
getBracketFocusState,
|
||||
getHorizontalOverflowCues,
|
||||
type BracketFocusConnector,
|
||||
} from "../src/components/competition/double-elimination-bracket-interaction.ts";
|
||||
|
||||
const A = seriesId("a");
|
||||
const B = seriesId("b");
|
||||
const C = seriesId("c");
|
||||
const D = seriesId("d");
|
||||
const E = seriesId("e");
|
||||
|
||||
const CONNECTORS: BracketFocusConnector[] = [
|
||||
connector(A, "winner", B, "A"),
|
||||
connector(B, "winner", C, "A"),
|
||||
connector(B, "loser", D, "B"),
|
||||
connector(D, "winner", E, "A"),
|
||||
];
|
||||
|
||||
test("focuses directly incoming and outgoing routes plus adjacent matches", () => {
|
||||
const focus = getBracketFocusState(CONNECTORS, B);
|
||||
|
||||
assert.deepEqual([...focus.seriesIds].sort(), [A, B, C, D].sort());
|
||||
assert.deepEqual(
|
||||
[...focus.connectorKeys].sort(),
|
||||
CONNECTORS.slice(0, 3).map(bracketConnectorKey).sort(),
|
||||
);
|
||||
assert.equal(focus.connectorKeys.has(bracketConnectorKey(CONNECTORS[3])), false);
|
||||
});
|
||||
|
||||
test("returns a neutral focus state when no match is active", () => {
|
||||
const focus = getBracketFocusState(CONNECTORS, null);
|
||||
|
||||
assert.equal(focus.seriesIds.size, 0);
|
||||
assert.equal(focus.connectorKeys.size, 0);
|
||||
});
|
||||
|
||||
test("keeps both grand-final carry-over routes focused", () => {
|
||||
const grandFinal = seriesId("grand-final");
|
||||
const resetFinal = seriesId("reset-final");
|
||||
const resetConnectors = [
|
||||
connector(grandFinal, "slot-a", resetFinal, "A"),
|
||||
connector(grandFinal, "slot-b", resetFinal, "B"),
|
||||
];
|
||||
|
||||
const focus = getBracketFocusState(resetConnectors, grandFinal);
|
||||
|
||||
assert.deepEqual([...focus.seriesIds].sort(), [grandFinal, resetFinal].sort());
|
||||
assert.equal(focus.connectorKeys.size, 2);
|
||||
});
|
||||
|
||||
test("keeps both grand-final carry-over routes focused from the reset final", () => {
|
||||
const grandFinal = seriesId("grand-final");
|
||||
const resetFinal = seriesId("reset-final");
|
||||
const resetConnectors = [
|
||||
connector(grandFinal, "slot-b", resetFinal, "B"),
|
||||
connector(grandFinal, "slot-a", resetFinal, "A"),
|
||||
];
|
||||
|
||||
const focus = getBracketFocusState(resetConnectors, resetFinal);
|
||||
|
||||
assert.deepEqual([...focus.seriesIds].sort(), [grandFinal, resetFinal].sort());
|
||||
assert.deepEqual(
|
||||
[...focus.connectorKeys].sort(),
|
||||
resetConnectors.map(bracketConnectorKey).sort(),
|
||||
);
|
||||
});
|
||||
|
||||
test("uses the brand coral for winner routes without losing patterned route semantics", () => {
|
||||
assert.equal(getBracketConnectorColorClass("winner"), "text-bracket-winner");
|
||||
assert.equal(
|
||||
getBracketConnectorColorClass("winner", true),
|
||||
"text-bracket-winner",
|
||||
);
|
||||
assert.equal(getBracketConnectorColorClass("loser"), "text-base-content/55");
|
||||
assert.equal(
|
||||
getBracketConnectorColorClass("loser", true),
|
||||
"text-base-content",
|
||||
);
|
||||
assert.equal(getBracketConnectorColorClass("reset"), "text-base-content/55");
|
||||
});
|
||||
|
||||
test("derives truthful horizontal overflow cues at each scroll position", () => {
|
||||
assert.deepEqual(
|
||||
getHorizontalOverflowCues({ scrollLeft: 0, scrollWidth: 1600, clientWidth: 1200 }),
|
||||
{ showStart: false, showEnd: true },
|
||||
);
|
||||
assert.deepEqual(
|
||||
getHorizontalOverflowCues({
|
||||
scrollLeft: 200,
|
||||
scrollWidth: 1600,
|
||||
clientWidth: 1200,
|
||||
}),
|
||||
{ showStart: true, showEnd: true },
|
||||
);
|
||||
assert.deepEqual(
|
||||
getHorizontalOverflowCues({
|
||||
scrollLeft: 400,
|
||||
scrollWidth: 1600,
|
||||
clientWidth: 1200,
|
||||
}),
|
||||
{ showStart: true, showEnd: false },
|
||||
);
|
||||
assert.deepEqual(
|
||||
getHorizontalOverflowCues({ scrollLeft: 0, scrollWidth: 1200, clientWidth: 1200 }),
|
||||
{ showStart: false, showEnd: false },
|
||||
);
|
||||
assert.deepEqual(
|
||||
getHorizontalOverflowCues({ scrollLeft: 1, scrollWidth: 1600, clientWidth: 1200 }),
|
||||
{ showStart: false, showEnd: true },
|
||||
);
|
||||
assert.deepEqual(
|
||||
getHorizontalOverflowCues({ scrollLeft: 1.01, scrollWidth: 1600, clientWidth: 1200 }),
|
||||
{ showStart: true, showEnd: true },
|
||||
);
|
||||
assert.deepEqual(
|
||||
getHorizontalOverflowCues({ scrollLeft: 399, scrollWidth: 1600, clientWidth: 1200 }),
|
||||
{ showStart: true, showEnd: false },
|
||||
);
|
||||
assert.deepEqual(
|
||||
getHorizontalOverflowCues({ scrollLeft: 398.99, scrollWidth: 1600, clientWidth: 1200 }),
|
||||
{ showStart: true, showEnd: true },
|
||||
);
|
||||
assert.deepEqual(
|
||||
getHorizontalOverflowCues({ scrollLeft: 0, scrollWidth: 1201, clientWidth: 1200 }),
|
||||
{ showStart: false, showEnd: false },
|
||||
);
|
||||
});
|
||||
|
||||
function connector(
|
||||
fromSeriesId: SeriesId,
|
||||
select: BracketFocusConnector["select"],
|
||||
toSeriesId: SeriesId,
|
||||
toSlot: BracketFocusConnector["toSlot"],
|
||||
): BracketFocusConnector {
|
||||
return { fromSeriesId, select, toSeriesId, toSlot };
|
||||
}
|
||||
|
||||
function seriesId(value: string): SeriesId {
|
||||
return value as SeriesId;
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
@@ -0,0 +1,448 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import type {
|
||||
BracketRoundView,
|
||||
CompetitionTeamMemberView,
|
||||
CompetitionFactId,
|
||||
GameSlotId,
|
||||
SeriesId,
|
||||
SeriesProjection,
|
||||
TeamId,
|
||||
TeamTournamentCodeView,
|
||||
} from "@lolympus/contracts";
|
||||
import {
|
||||
copyTournamentCode,
|
||||
createTeamSeriesGroups,
|
||||
getTeamSeriesDisplayLabel,
|
||||
getTeamSeriesPresentation,
|
||||
getNextTournamentCodeExpiryDelay,
|
||||
getTournamentCodeExpiryLabel,
|
||||
getTournamentCodeCopyLabel,
|
||||
getTournamentCodePresentation,
|
||||
sortCompletedTeamSeries,
|
||||
sortTeamMembersForRoster,
|
||||
} from "../src/pages/match-team-progress-view.ts";
|
||||
|
||||
const TEAM_A = "team-a" as TeamId;
|
||||
const TEAM_B = "team-b" as TeamId;
|
||||
|
||||
test("groups only matching tournament codes under each active Series", () => {
|
||||
const earlier = readySeries("series-earlier", 1);
|
||||
const later = readySeries("series-later", 2);
|
||||
const groups = createTeamSeriesGroups(
|
||||
[later, earlier],
|
||||
[
|
||||
tournamentCode("later-2", later.seriesId, 2, 20),
|
||||
tournamentCode("orphan", "series-orphan" as SeriesId, 1, 99),
|
||||
tournamentCode("earlier-1", earlier.seriesId, 1, 17),
|
||||
tournamentCode("later-1", later.seriesId, 1, 19),
|
||||
],
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
groups.map(({ series, codes }) => ({
|
||||
seriesId: series.seriesId,
|
||||
gameSlotIds: codes.map(({ gameSlotId }) => gameSlotId),
|
||||
})),
|
||||
[
|
||||
{ seriesId: earlier.seriesId, gameSlotIds: ["earlier-1"] },
|
||||
{ seriesId: later.seriesId, gameSlotIds: ["later-1", "later-2"] },
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
test("uses bracket match names while keeping global game numbers secondary", () => {
|
||||
const opening = readySeries("upper-opening-2", 1, "WB_R1_M2");
|
||||
const upperLater = readySeries("upper-final", 3, "WB_FINAL");
|
||||
const lower: SeriesProjection = {
|
||||
...readySeries("lower-opening", 4, "LB_R1_M1"),
|
||||
stage: { type: "lower", roundNumber: 1, displayOrder: 4 },
|
||||
};
|
||||
const rounds: BracketRoundView[] = [
|
||||
round("upper", 1, 1, ["upper-opening-1", opening.seriesId]),
|
||||
round("upper", 3, 3, [upperLater.seriesId]),
|
||||
round("lower", 1, 4, [lower.seriesId]),
|
||||
];
|
||||
|
||||
assert.equal(
|
||||
getTeamSeriesDisplayLabel(opening, rounds),
|
||||
"브래킷 1R · 2경기",
|
||||
);
|
||||
assert.equal(
|
||||
getTeamSeriesDisplayLabel(upperLater, rounds),
|
||||
"브래킷 상위 3R",
|
||||
);
|
||||
assert.equal(getTeamSeriesDisplayLabel(lower, rounds), "브래킷 하위 1R");
|
||||
|
||||
const assignment = tournamentCode(
|
||||
"final-1",
|
||||
upperLater.seriesId,
|
||||
1,
|
||||
19,
|
||||
);
|
||||
assert.equal(
|
||||
getTournamentCodeCopyLabel(assignment, "브래킷 상위 3R"),
|
||||
"브래킷 상위 3R 1세트 토너먼트 코드 복사 (전체 19번 게임)",
|
||||
);
|
||||
});
|
||||
|
||||
test("hides misleading scores before play and for adjudicated outcomes", () => {
|
||||
const ready = readySeries("ready", 1);
|
||||
const walkover = completedSeries(
|
||||
"walkover",
|
||||
"2026-07-13T10:00:00.000Z",
|
||||
2,
|
||||
);
|
||||
const played: Extract<SeriesProjection, { status: "completed" }> = {
|
||||
...walkover,
|
||||
code: "PLAYED",
|
||||
entries: [
|
||||
{ slot: "A", teamId: TEAM_A, gameWins: 2 },
|
||||
{ slot: "B", teamId: TEAM_B, gameWins: 1 },
|
||||
],
|
||||
outcome: {
|
||||
type: "played",
|
||||
winnerTeamId: TEAM_A,
|
||||
loserTeamId: TEAM_B,
|
||||
decidedByGameIds: [],
|
||||
completedAt: "2026-07-13T11:00:00.000Z",
|
||||
},
|
||||
};
|
||||
|
||||
assert.deepEqual(getTeamSeriesPresentation(ready), {
|
||||
label: "경기 가능",
|
||||
tone: "ready",
|
||||
showScore: false,
|
||||
});
|
||||
for (const [status, expected] of [
|
||||
["inactive", { label: "비활성", tone: "muted", showScore: false }],
|
||||
["waiting", { label: "대진 대기", tone: "muted", showScore: false }],
|
||||
["in-progress", { label: "진행 중", tone: "live", showScore: true }],
|
||||
] as const) {
|
||||
assert.deepEqual(
|
||||
getTeamSeriesPresentation({ ...ready, status } as SeriesProjection),
|
||||
expected,
|
||||
);
|
||||
}
|
||||
assert.deepEqual(getTeamSeriesPresentation(walkover), {
|
||||
label: "부전승",
|
||||
tone: "adjudicated",
|
||||
showScore: false,
|
||||
});
|
||||
assert.deepEqual(getTeamSeriesPresentation(played), {
|
||||
label: "종료",
|
||||
tone: "completed",
|
||||
showScore: true,
|
||||
});
|
||||
|
||||
const adjudicatedOutcomes = [
|
||||
["forfeit", "기권승"],
|
||||
["administrative", "판정승"],
|
||||
] as const;
|
||||
for (const [type, label] of adjudicatedOutcomes) {
|
||||
const series: Extract<SeriesProjection, { status: "completed" }> = {
|
||||
...walkover,
|
||||
outcome: {
|
||||
...walkover.outcome,
|
||||
type,
|
||||
},
|
||||
};
|
||||
assert.deepEqual(getTeamSeriesPresentation(series), {
|
||||
label,
|
||||
tone: "adjudicated",
|
||||
showScore: false,
|
||||
});
|
||||
}
|
||||
|
||||
for (const basis of ["played", "administrative"] as const) {
|
||||
const draw: Extract<SeriesProjection, { status: "completed" }> = {
|
||||
...walkover,
|
||||
entries: [
|
||||
{ slot: "A", teamId: TEAM_A, gameWins: 1 },
|
||||
{ slot: "B", teamId: TEAM_B, gameWins: 1 },
|
||||
],
|
||||
outcome: {
|
||||
type: "draw",
|
||||
basis:
|
||||
basis === "played"
|
||||
? { type: basis, decidedByGameIds: [] }
|
||||
: {
|
||||
type: basis,
|
||||
decisionFactId: "draw-fact" as CompetitionFactId,
|
||||
},
|
||||
completedAt: "2026-07-13T12:00:00.000Z",
|
||||
},
|
||||
};
|
||||
assert.deepEqual(getTeamSeriesPresentation(draw), {
|
||||
label: "무승부",
|
||||
tone: basis === "played" ? "completed" : "adjudicated",
|
||||
showScore: basis === "played",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
test("distinguishes pending, available, expired, and used code states", () => {
|
||||
const now = Date.parse("2026-07-13T12:00:00.000Z");
|
||||
const pending = tournamentCode("pending", "series-a" as SeriesId, 1, 1, {
|
||||
state: "pending",
|
||||
code: null,
|
||||
});
|
||||
const available = tournamentCode(
|
||||
"available",
|
||||
"series-a" as SeriesId,
|
||||
2,
|
||||
2,
|
||||
{ expiresAt: "2026-07-13T13:00:00.000Z" },
|
||||
);
|
||||
const expired = tournamentCode(
|
||||
"expired",
|
||||
"series-a" as SeriesId,
|
||||
3,
|
||||
3,
|
||||
{ expiresAt: "2026-07-13T11:00:00.000Z" },
|
||||
);
|
||||
const used = tournamentCode("used", "series-a" as SeriesId, 4, 4, {
|
||||
state: "used",
|
||||
expiresAt: "2026-07-13T11:00:00.000Z",
|
||||
});
|
||||
const expiresNow = tournamentCode(
|
||||
"expires-now",
|
||||
"series-a" as SeriesId,
|
||||
5,
|
||||
5,
|
||||
{ expiresAt: "2026-07-13T12:00:00.000Z" },
|
||||
);
|
||||
const noExpiry = tournamentCode(
|
||||
"no-expiry",
|
||||
"series-a" as SeriesId,
|
||||
6,
|
||||
6,
|
||||
);
|
||||
const invalidExpiry = tournamentCode(
|
||||
"invalid-expiry",
|
||||
"series-a" as SeriesId,
|
||||
7,
|
||||
7,
|
||||
{ expiresAt: "not-a-date" },
|
||||
);
|
||||
|
||||
assert.deepEqual(getTournamentCodePresentation(pending, now), {
|
||||
label: "발급 대기",
|
||||
tone: "pending",
|
||||
canCopy: false,
|
||||
});
|
||||
assert.deepEqual(getTournamentCodePresentation(available, now), {
|
||||
label: "사용 가능",
|
||||
tone: "available",
|
||||
canCopy: true,
|
||||
});
|
||||
assert.deepEqual(getTournamentCodePresentation(expired, now), {
|
||||
label: "만료",
|
||||
tone: "expired",
|
||||
canCopy: false,
|
||||
});
|
||||
assert.deepEqual(getTournamentCodePresentation(used, now), {
|
||||
label: "사용 완료",
|
||||
tone: "used",
|
||||
canCopy: false,
|
||||
});
|
||||
assert.deepEqual(getTournamentCodePresentation(expiresNow, now), {
|
||||
label: "만료",
|
||||
tone: "expired",
|
||||
canCopy: false,
|
||||
});
|
||||
assert.deepEqual(getTournamentCodePresentation(noExpiry, now), {
|
||||
label: "사용 가능",
|
||||
tone: "available",
|
||||
canCopy: true,
|
||||
});
|
||||
assert.deepEqual(getTournamentCodePresentation(invalidExpiry, now), {
|
||||
label: "만료 정보 오류",
|
||||
tone: "expired",
|
||||
canCopy: false,
|
||||
});
|
||||
});
|
||||
|
||||
test("describes tournament-code expiry according to its current state", () => {
|
||||
const beforeExpiry = Date.parse("2026-07-13T12:00:00.000Z");
|
||||
const atExpiry = Date.parse("2026-07-13T13:00:00.000Z");
|
||||
const expiresAt = "2026-07-13T13:00:00.000Z";
|
||||
const formatter = new Intl.DateTimeFormat("ko-KR", {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
timeZone: "Asia/Seoul",
|
||||
timeZoneName: "short",
|
||||
});
|
||||
const formatted = formatter.format(new Date(expiresAt));
|
||||
|
||||
assert.equal(
|
||||
getTournamentCodeExpiryLabel(expiresAt, beforeExpiry),
|
||||
`${formatted}까지 사용 가능`,
|
||||
);
|
||||
assert.equal(
|
||||
getTournamentCodeExpiryLabel(expiresAt, atExpiry),
|
||||
`${formatted}에 만료됨`,
|
||||
);
|
||||
assert.equal(
|
||||
getTournamentCodeExpiryLabel("not-a-date", beforeExpiry),
|
||||
"만료 시각 정보 없음",
|
||||
);
|
||||
});
|
||||
|
||||
test("schedules the next code-state refresh at the nearest future expiry", () => {
|
||||
const now = Date.parse("2026-07-13T12:00:00.000Z");
|
||||
const first = tournamentCode("first", "series-a" as SeriesId, 1, 1, {
|
||||
expiresAt: "2026-07-13T12:01:00.000Z",
|
||||
});
|
||||
const later = tournamentCode("later", "series-a" as SeriesId, 2, 2, {
|
||||
expiresAt: "2026-07-13T13:00:00.000Z",
|
||||
});
|
||||
const alreadyExpired = tournamentCode(
|
||||
"expired",
|
||||
"series-a" as SeriesId,
|
||||
3,
|
||||
3,
|
||||
{ expiresAt: "2026-07-13T11:00:00.000Z" },
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
getNextTournamentCodeExpiryDelay([later, alreadyExpired, first], now),
|
||||
60_000,
|
||||
);
|
||||
assert.equal(
|
||||
getNextTournamentCodeExpiryDelay([alreadyExpired], now),
|
||||
null,
|
||||
);
|
||||
});
|
||||
|
||||
test("returns explicit game-specific clipboard success and failure feedback", async () => {
|
||||
const writes: string[] = [];
|
||||
const success = await copyTournamentCode(
|
||||
async (value) => {
|
||||
writes.push(value);
|
||||
},
|
||||
"KR-CODE-19",
|
||||
"승자조 결승 1세트",
|
||||
);
|
||||
const failure = await copyTournamentCode(
|
||||
async () => {
|
||||
throw new Error("clipboard denied");
|
||||
},
|
||||
"KR-CODE-20",
|
||||
"승자조 결승 2세트",
|
||||
);
|
||||
|
||||
assert.deepEqual(writes, ["KR-CODE-19"]);
|
||||
assert.deepEqual(success, {
|
||||
kind: "success",
|
||||
message: "승자조 결승 1세트 코드를 복사했습니다.",
|
||||
});
|
||||
assert.deepEqual(failure, {
|
||||
kind: "error",
|
||||
message:
|
||||
"승자조 결승 2세트 코드를 복사하지 못했습니다. 코드를 직접 선택해 복사해 주세요.",
|
||||
});
|
||||
});
|
||||
|
||||
test("sorts completed Series by most recent decision time", () => {
|
||||
const older = completedSeries("older", "2026-07-12T10:00:00.000Z", 1);
|
||||
const newer = completedSeries("newer", "2026-07-13T10:00:00.000Z", 2);
|
||||
|
||||
assert.deepEqual(
|
||||
sortCompletedTeamSeries([older, newer]).map(({ seriesId }) => seriesId),
|
||||
[newer.seriesId, older.seriesId],
|
||||
);
|
||||
});
|
||||
|
||||
test("orders the roster by the canonical League positions", () => {
|
||||
const members: CompetitionTeamMemberView[] = [
|
||||
{ userId: "support" as never, displayName: "Support", assignedPosition: "SUP" },
|
||||
{ userId: "top" as never, displayName: "Top", assignedPosition: "TOP" },
|
||||
{ userId: "unknown" as never, displayName: "Unknown" },
|
||||
{ userId: "mid" as never, displayName: "Mid", assignedPosition: "MID" },
|
||||
{ userId: "jungle" as never, displayName: "Jungle", assignedPosition: "JGL" },
|
||||
{ userId: "adc" as never, displayName: "Adc", assignedPosition: "ADC" },
|
||||
];
|
||||
|
||||
assert.deepEqual(
|
||||
sortTeamMembersForRoster(members).map(({ displayName }) => displayName),
|
||||
["Top", "Jungle", "Mid", "Adc", "Support", "Unknown"],
|
||||
);
|
||||
});
|
||||
|
||||
function readySeries(
|
||||
id: string,
|
||||
displayOrder: number,
|
||||
code = id.toUpperCase(),
|
||||
): SeriesProjection {
|
||||
return {
|
||||
seriesId: id as SeriesId,
|
||||
code,
|
||||
stage: { type: "upper", roundNumber: displayOrder, displayOrder },
|
||||
rule: { type: "first-to", winsRequired: 2, maxGames: 3 },
|
||||
status: "ready",
|
||||
entries: [
|
||||
{ slot: "A", teamId: TEAM_A, gameWins: 0 },
|
||||
{ slot: "B", teamId: TEAM_B, gameWins: 0 },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
function completedSeries(
|
||||
id: string,
|
||||
completedAt: string,
|
||||
displayOrder: number,
|
||||
): Extract<SeriesProjection, { status: "completed" }> {
|
||||
return {
|
||||
...readySeries(id, displayOrder),
|
||||
status: "completed",
|
||||
entries: [
|
||||
{ slot: "A", teamId: TEAM_A, gameWins: 0 },
|
||||
{ slot: "B", teamId: TEAM_B, gameWins: 0 },
|
||||
],
|
||||
outcome: {
|
||||
type: "walkover",
|
||||
winnerTeamId: TEAM_A,
|
||||
loserTeamId: TEAM_B,
|
||||
decisionFactId: `${id}-fact` as CompetitionFactId,
|
||||
completedAt,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function tournamentCode(
|
||||
id: string,
|
||||
seriesId: SeriesId,
|
||||
ordinal: number,
|
||||
displayNumber: number,
|
||||
overrides: Partial<TeamTournamentCodeView> = {},
|
||||
): TeamTournamentCodeView {
|
||||
return {
|
||||
gameSlotId: id as GameSlotId,
|
||||
seriesId,
|
||||
ordinal,
|
||||
displayNumber,
|
||||
state: "reserved",
|
||||
code: `KR-${id}`,
|
||||
expiresAt: null,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
function round(
|
||||
stage: BracketRoundView["stage"],
|
||||
roundNumber: number,
|
||||
displayOrder: number,
|
||||
seriesIds: Array<string | SeriesId>,
|
||||
): BracketRoundView {
|
||||
return {
|
||||
stage,
|
||||
roundNumber,
|
||||
displayOrder,
|
||||
label: `${stage}-${roundNumber}`,
|
||||
seriesIds: seriesIds.map((id) => id as SeriesId),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import type {
|
||||
CompetitionFactId,
|
||||
SeriesId,
|
||||
SeriesProjection,
|
||||
TeamId,
|
||||
} from "@lolympus/contracts";
|
||||
import {
|
||||
formatSeriesScore,
|
||||
getSeriesScoreCardAccessibleLabel,
|
||||
getSeriesScoreCardIdentity,
|
||||
getSeriesScoreCardPresentation,
|
||||
} from "../src/components/competition/series-score-card-model.ts";
|
||||
|
||||
const TEAM_A = "team-a" as TeamId;
|
||||
const TEAM_B = "team-b" as TeamId;
|
||||
|
||||
test("presents future and active Series with distinct status hierarchy", () => {
|
||||
const inactive = pendingSeries("inactive", "inactive");
|
||||
const waiting = pendingSeries("waiting", "waiting");
|
||||
const ready = readySeries("ready");
|
||||
const inProgress = inProgressSeries("running", 1, 0);
|
||||
|
||||
assert.deepEqual(getSeriesScoreCardPresentation(inactive), {
|
||||
label: "비활성",
|
||||
tone: "muted",
|
||||
showScore: false,
|
||||
});
|
||||
assert.deepEqual(getSeriesScoreCardPresentation(waiting), {
|
||||
label: "대진 대기",
|
||||
tone: "muted",
|
||||
showScore: false,
|
||||
});
|
||||
assert.deepEqual(getSeriesScoreCardPresentation(ready), {
|
||||
label: "경기 가능",
|
||||
tone: "ready",
|
||||
showScore: false,
|
||||
});
|
||||
assert.deepEqual(getSeriesScoreCardPresentation(inProgress), {
|
||||
label: "진행 중",
|
||||
tone: "live",
|
||||
showScore: true,
|
||||
});
|
||||
assert.equal(formatSeriesScore(waiting, 0), "—");
|
||||
assert.equal(formatSeriesScore(ready, 0), "—");
|
||||
assert.equal(formatSeriesScore(inProgress, 0), "0");
|
||||
});
|
||||
|
||||
test("prioritizes a human-readable match name and keeps the code as metadata", () => {
|
||||
const series = readySeries("WB_R2_M2");
|
||||
|
||||
assert.deepEqual(
|
||||
getSeriesScoreCardIdentity(series, "브래킷 상위 2R · 2경기"),
|
||||
{
|
||||
label: "브래킷 상위 2R · 2경기",
|
||||
code: "WB_R2_M2",
|
||||
},
|
||||
);
|
||||
assert.deepEqual(getSeriesScoreCardIdentity(series), {
|
||||
label: "WB_R2_M2",
|
||||
code: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
test("shows numeric scores only for played completed outcomes", () => {
|
||||
const played = completedSeries("played", 2, 1);
|
||||
const playedDraw = completedDraw("played", 1, 1);
|
||||
const administrativeDraw = completedDraw("administrative", 0, 0);
|
||||
|
||||
assert.deepEqual(getSeriesScoreCardPresentation(played), {
|
||||
label: "종료",
|
||||
tone: "completed",
|
||||
showScore: true,
|
||||
});
|
||||
assert.deepEqual(getSeriesScoreCardPresentation(playedDraw), {
|
||||
label: "무승부",
|
||||
tone: "completed",
|
||||
showScore: true,
|
||||
});
|
||||
assert.deepEqual(getSeriesScoreCardPresentation(administrativeDraw), {
|
||||
label: "무승부",
|
||||
tone: "adjudicated",
|
||||
showScore: false,
|
||||
});
|
||||
assert.equal(formatSeriesScore(played, 2), "2");
|
||||
assert.equal(formatSeriesScore(playedDraw, 1), "1");
|
||||
assert.equal(formatSeriesScore(administrativeDraw, 0), "—");
|
||||
});
|
||||
|
||||
test("names adjudicated outcomes without inferring from their scores", () => {
|
||||
const walkover = completedSeries("walkover", 0, 0);
|
||||
const forfeit = completedSeries("forfeit", 0, 1);
|
||||
const administrative = completedSeries("administrative", 1, 0);
|
||||
|
||||
assert.deepEqual(getSeriesScoreCardPresentation(walkover), {
|
||||
label: "부전승",
|
||||
tone: "adjudicated",
|
||||
showScore: false,
|
||||
});
|
||||
assert.deepEqual(getSeriesScoreCardPresentation(forfeit), {
|
||||
label: "기권승",
|
||||
tone: "adjudicated",
|
||||
showScore: false,
|
||||
});
|
||||
assert.deepEqual(getSeriesScoreCardPresentation(administrative), {
|
||||
label: "판정",
|
||||
tone: "adjudicated",
|
||||
showScore: false,
|
||||
});
|
||||
assert.equal(getSeriesScoreCardPresentation(walkover).showScore, false);
|
||||
assert.equal(getSeriesScoreCardPresentation(forfeit).showScore, false);
|
||||
assert.equal(getSeriesScoreCardPresentation(administrative).showScore, false);
|
||||
assert.equal(formatSeriesScore(walkover, 0), "—");
|
||||
assert.equal(formatSeriesScore(forfeit, 1), "—");
|
||||
assert.equal(formatSeriesScore(administrative, 1), "—");
|
||||
});
|
||||
|
||||
test("summarizes status, teams, scores, and winner for a focus target", () => {
|
||||
const series = completedSeries("played", 2, 1);
|
||||
const teamById = new Map([
|
||||
[TEAM_A, { name: "나물장수" }],
|
||||
[TEAM_B, { name: "원딜미아요" }],
|
||||
]);
|
||||
|
||||
assert.equal(
|
||||
getSeriesScoreCardAccessibleLabel(
|
||||
series,
|
||||
"브래킷 1라운드 · 1경기",
|
||||
teamById,
|
||||
),
|
||||
"브래킷 1라운드 · 1경기, 코드 PLAYED, 종료. A 나물장수, 2승, 승리. B 원딜미아요, 1승.",
|
||||
);
|
||||
});
|
||||
|
||||
test("announces an adjudicated official winner without a numeric score", () => {
|
||||
const series = completedSeries("forfeit", 0, 1);
|
||||
const teamById = new Map([
|
||||
[TEAM_A, { name: "나물장수" }],
|
||||
[TEAM_B, { name: "원딜미아요" }],
|
||||
]);
|
||||
|
||||
assert.equal(
|
||||
getSeriesScoreCardAccessibleLabel(
|
||||
series,
|
||||
"브래킷 1라운드 · 1경기",
|
||||
teamById,
|
||||
),
|
||||
"브래킷 1라운드 · 1경기, 코드 FORFEIT, 기권승. A 나물장수, 점수 없음, 승리. B 원딜미아요, 점수 없음.",
|
||||
);
|
||||
});
|
||||
|
||||
function baseSeries(id: string) {
|
||||
return {
|
||||
seriesId: id as SeriesId,
|
||||
code: id.toUpperCase(),
|
||||
stage: { type: "upper" as const, roundNumber: 1, displayOrder: 1 },
|
||||
rule: { type: "first-to" as const, winsRequired: 2, maxGames: 3 },
|
||||
};
|
||||
}
|
||||
|
||||
function pendingSeries(
|
||||
id: string,
|
||||
status: "inactive" | "waiting",
|
||||
): SeriesProjection {
|
||||
return {
|
||||
...baseSeries(id),
|
||||
status,
|
||||
entries: [
|
||||
{ slot: "A", teamId: null, gameWins: 0 },
|
||||
{ slot: "B", teamId: null, gameWins: 0 },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
function readySeries(id: string): SeriesProjection {
|
||||
return {
|
||||
...baseSeries(id),
|
||||
status: "ready",
|
||||
entries: [
|
||||
{ slot: "A", teamId: TEAM_A, gameWins: 0 },
|
||||
{ slot: "B", teamId: TEAM_B, gameWins: 0 },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
function inProgressSeries(
|
||||
id: string,
|
||||
scoreA: number,
|
||||
scoreB: number,
|
||||
): SeriesProjection {
|
||||
return {
|
||||
...baseSeries(id),
|
||||
status: "in-progress",
|
||||
entries: [
|
||||
{ slot: "A", teamId: TEAM_A, gameWins: scoreA },
|
||||
{ slot: "B", teamId: TEAM_B, gameWins: scoreB },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
function completedSeries(
|
||||
outcome: "played" | "walkover" | "forfeit" | "administrative",
|
||||
scoreA: number,
|
||||
scoreB: number,
|
||||
): SeriesProjection {
|
||||
const sharedOutcome = {
|
||||
winnerTeamId: TEAM_A,
|
||||
loserTeamId: TEAM_B,
|
||||
completedAt: "2026-07-13T00:00:00.000Z",
|
||||
};
|
||||
return {
|
||||
...baseSeries(outcome),
|
||||
status: "completed",
|
||||
entries: [
|
||||
{ slot: "A", teamId: TEAM_A, gameWins: scoreA },
|
||||
{ slot: "B", teamId: TEAM_B, gameWins: scoreB },
|
||||
],
|
||||
outcome:
|
||||
outcome === "played"
|
||||
? { ...sharedOutcome, type: outcome, decidedByGameIds: [] }
|
||||
: {
|
||||
...sharedOutcome,
|
||||
type: outcome,
|
||||
decisionFactId: `${outcome}-fact` as CompetitionFactId,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function completedDraw(
|
||||
basis: "played" | "administrative",
|
||||
scoreA: number,
|
||||
scoreB: number,
|
||||
): SeriesProjection {
|
||||
return {
|
||||
...baseSeries(`${basis}-draw`),
|
||||
status: "completed",
|
||||
entries: [
|
||||
{ slot: "A", teamId: TEAM_A, gameWins: scoreA },
|
||||
{ slot: "B", teamId: TEAM_B, gameWins: scoreB },
|
||||
],
|
||||
outcome: {
|
||||
type: "draw",
|
||||
basis:
|
||||
basis === "played"
|
||||
? { type: basis, decidedByGameIds: [] }
|
||||
: {
|
||||
type: basis,
|
||||
decisionFactId: "draw-fact" as CompetitionFactId,
|
||||
},
|
||||
completedAt: "2026-07-13T00:00:00.000Z",
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
# Implementation Plan: Team Progress Page UX Refresh
|
||||
|
||||
## Overview
|
||||
|
||||
Deliver the redesign in three verifiable slices: tested presentation rules, shared
|
||||
Series semantics, and the integrated page/copy experience. No API or dependency
|
||||
change is required because the team view already exposes `seriesId`, ordinal, round
|
||||
metadata, outcome categories, and code expiry.
|
||||
|
||||
## Architecture Decisions
|
||||
|
||||
- Keep API/query ownership in the page and move deterministic presentation logic
|
||||
into a pure module that the existing Node test runner can exercise.
|
||||
- Compose the active-Series card with code rows instead of maintaining a separate
|
||||
page-wide code grid.
|
||||
- Keep the team page's Series presentation in a page-specific card so shared
|
||||
bracket/history layouts are unaffected; exhaustively test its outcome mapping.
|
||||
- Reuse the bracket's canonical round-label helper so the bracket and team detail
|
||||
cannot drift to different visible match names.
|
||||
- Use one responsive layout and native disclosure/table semantics rather than
|
||||
separate desktop and mobile component trees.
|
||||
|
||||
## Task List
|
||||
|
||||
### Phase 1: Tested View Model
|
||||
|
||||
- [x] Add failing tests for Series/code grouping, stable ordering, Korean round
|
||||
labels, code availability/expiry, unique copy labels, and explicit clipboard
|
||||
results.
|
||||
- Acceptance: the new focused test fails because the behavior is not implemented.
|
||||
- Verify: `pnpm --filter web exec node --test --experimental-strip-types test/match-team-progress-view.test.ts`
|
||||
- Files: `apps/web/test/match-team-progress-view.test.ts`
|
||||
- [x] Implement the minimal pure view helpers.
|
||||
- Acceptance: all focused assertions pass without React or DOM mocks.
|
||||
- Verify: rerun the focused command once after implementation.
|
||||
- Files: `apps/web/src/pages/match-team-progress-view.ts`
|
||||
|
||||
### Checkpoint: View Model
|
||||
|
||||
- [x] Focused tests pass and no API/contract file changed.
|
||||
|
||||
### Phase 2: Series Semantics and Code Interaction
|
||||
|
||||
- [x] Add a page-specific Series card that prefers supplied human labels, shows
|
||||
technical codes secondarily, and hides misleading pre-start/adjudicated scores.
|
||||
- Acceptance: ready and adjudicated cards show `—`; result categories remain
|
||||
text-visible; bracket geometry stays unchanged.
|
||||
- Verify: `pnpm --filter web test`
|
||||
- Files: `apps/web/src/components/competition/TeamSeriesCard.tsx`
|
||||
- [x] Add the responsive tournament-code list with accessible clipboard feedback.
|
||||
- Acceptance: code rows show local set number first, full selectable codes,
|
||||
unique 44px copy controls, expiry/state text, and success/failure announcements.
|
||||
- Verify: TypeScript build plus runtime keyboard/copy check.
|
||||
- Files: `apps/web/src/components/competition/TeamTournamentCodes.tsx`
|
||||
|
||||
### Checkpoint: Interaction
|
||||
|
||||
- [x] Full web tests pass and the web build succeeds.
|
||||
|
||||
### Phase 3: Page Hierarchy and Polish
|
||||
|
||||
- [x] Reorder the page and integrate code rows with matching active Series.
|
||||
- Acceptance: order is next match, roster, recent results; every code appears
|
||||
under exactly one matching Series; empty states remain meaningful.
|
||||
- Verify: desktop and mobile runtime screenshots.
|
||||
- Files: `apps/web/src/pages/MatchTeamProgressPage.tsx`
|
||||
|
||||
- [x] Compact and order the roster, and collapse results beyond the newest two.
|
||||
- Acceptance: position labels are Korean and role-ordered, captain is adjacent,
|
||||
and older results remain keyboard-accessible.
|
||||
- Verify: 320/768/1024/1440px reflow and keyboard traversal.
|
||||
- Files: `apps/web/src/pages/MatchTeamProgressPage.tsx`
|
||||
|
||||
### Phase 4: Bracket Naming Alignment
|
||||
|
||||
- [x] Reuse canonical bracket round labels in the team-detail view model.
|
||||
- Acceptance: upper round 1 displays `브래킷 1R`, later upper rounds display
|
||||
`브래킷 상위 nR`, lower rounds display `브래킷 하위 nR`, and multi-match
|
||||
rounds keep the `· n경기` suffix.
|
||||
- Verify: focused view-model test, full web suite, scoped lint, and build.
|
||||
- Files: `apps/web/src/components/competition/double-elimination-bracket-layout.ts`,
|
||||
`apps/web/src/pages/match-team-progress-view.ts`, and
|
||||
`apps/web/test/match-team-progress-view.test.ts`
|
||||
|
||||
### Checkpoint: Complete
|
||||
|
||||
- [x] Focused (9) and full web tests (88) pass without skips.
|
||||
- [x] Scoped lint and the production build pass.
|
||||
- [ ] Full repository lint passes. It is currently blocked by pre-existing errors
|
||||
outside the team-progress scope.
|
||||
- [ ] Runtime review confirms no console errors or horizontal overflow. The
|
||||
required in-app browser was unavailable in this session.
|
||||
- [x] The scoped implementation contains only the spec, plan, focused tests, and
|
||||
team-progress UI; unrelated concurrent worktree changes are excluded.
|
||||
|
||||
## Risks and Mitigations
|
||||
|
||||
| Risk | Impact | Mitigation |
|
||||
|---|---|---|
|
||||
| A code appears under the wrong Series | High | Join only on exact `seriesId` and cover opponent/other-Series codes in tests. |
|
||||
| Global and local game numbers are confused | High | Lead with `ordinal` as set number and demote `displayNumber`. |
|
||||
| Adjudication looks like a played 0–0 | High | Reuse tested outcome/score helpers from Competition history. |
|
||||
| Clipboard permissions fail silently | Medium | Return a typed result and render an alert with manual-selection guidance. |
|
||||
| Long codes overflow at mobile widths | Medium | Use `minmax(0,1fr)`, `break-all`, selectable text, and a stacked mobile row. |
|
||||
| Page-specific result semantics drift | Medium | Cover every lifecycle/outcome branch in the pure presentation tests. |
|
||||
|
||||
## Dependencies
|
||||
|
||||
```text
|
||||
View-model tests -> view helpers -> code component -> page composition
|
||||
Exhaustive Series outcome tests -> page-specific score semantics -> recent results
|
||||
```
|
||||
|
||||
## Open Questions
|
||||
|
||||
None.
|
||||
@@ -0,0 +1,150 @@
|
||||
# Spec: Team Progress Page UX Refresh
|
||||
|
||||
## Objective
|
||||
|
||||
Reorganize the team progress page around the participant's primary task: identify
|
||||
the next opponent, understand the Series state, and copy the correct tournament
|
||||
code without cross-referencing separate sections. Keep the existing Competition
|
||||
API and visual language while making status, adjudicated results, copy feedback,
|
||||
the roster, and past results clearer on desktop and mobile.
|
||||
|
||||
The primary user is a team participant preparing to join an official internal-match
|
||||
game. Success means every active Series and its codes form one understandable work
|
||||
area, human-facing Korean labels lead internal identifiers, and the copy flow is
|
||||
accessible and explicit.
|
||||
|
||||
## Approved Product Decisions
|
||||
|
||||
- Group tournament codes under their matching active Series using `seriesId`.
|
||||
- Label a Series-local game as `1세트`, `2세트`, and so on; retain global
|
||||
`Game 19`-style numbers only as secondary metadata.
|
||||
- Use the bracket's canonical visible round names from Competition round metadata:
|
||||
upper round 1 is `브래킷 1R`, later upper rounds are `브래킷 상위 nR`, and
|
||||
lower rounds are `브래킷 하위 nR`. Retain raw Series codes such as `WB_FINAL`
|
||||
as secondary diagnostic text.
|
||||
- Show pre-start and adjudicated Series without misleading `0–0` scores.
|
||||
- Distinguish `부전승`, `기권승`, `판정승`, and `무승부` using the existing
|
||||
outcome discriminator. Do not invent a free-form reason that is not public data.
|
||||
- Make copy targets at least 44 CSS pixels high, uniquely label each button, keep
|
||||
the complete code visible/selectable, and announce copy success or failure.
|
||||
- Order the page as header, next matches with codes, compact roster, then recent
|
||||
results. Show two recent results and collapse older entries.
|
||||
- Preserve existing loading, selection, empty, error, revision-consistency, and
|
||||
authorization behavior.
|
||||
|
||||
## Tech Stack
|
||||
|
||||
- React 19 and TypeScript 6 under `apps/web`
|
||||
- Tailwind CSS 4 and daisyUI 5 using the repository's square bordered surfaces
|
||||
- Node's built-in test runner for pure view-model behavior
|
||||
- Existing `lucide-react` icon set; no new dependency
|
||||
|
||||
## Commands
|
||||
|
||||
- Focused tests: `pnpm --filter web exec node --test --experimental-strip-types test/match-team-progress-view.test.ts`
|
||||
- Full web tests: `pnpm --filter web test`
|
||||
- Web lint: `pnpm --filter web lint`
|
||||
- Web build: `pnpm --filter web build`
|
||||
- Development server: `pnpm --filter web start:dev`
|
||||
|
||||
## Project Structure
|
||||
|
||||
- `apps/web/src/pages/MatchTeamProgressPage.tsx` owns queries, snapshot guards,
|
||||
page ordering, and top-level team navigation.
|
||||
- `apps/web/src/pages/match-team-progress-view.ts` owns pure grouping, ordering,
|
||||
labels, code state, and copy-result behavior.
|
||||
- `apps/web/src/components/competition/double-elimination-bracket-layout.ts`
|
||||
remains the canonical source for visible bracket round names.
|
||||
- `apps/web/src/components/competition/TeamTournamentCodes.tsx` owns code rows and
|
||||
clipboard feedback.
|
||||
- `apps/web/src/components/competition/TeamSeriesCard.tsx` owns the page-specific
|
||||
Series summary, leaving bracket/history card geometry and behavior unchanged.
|
||||
- `apps/web/test/match-team-progress-view.test.ts` specifies the new pure behavior.
|
||||
|
||||
## Code Style
|
||||
|
||||
Keep data transformation outside React and render semantic native controls:
|
||||
|
||||
```ts
|
||||
const seriesCodes = tournamentCodesForSeries(
|
||||
teamView.tournamentCodes,
|
||||
series.seriesId,
|
||||
);
|
||||
|
||||
<button aria-label={`${setLabel} 토너먼트 코드 복사`}>
|
||||
복사
|
||||
</button>
|
||||
```
|
||||
|
||||
Use `text-content-subtle` and `text-content-muted` for secondary text. Semantic
|
||||
colors may provide a border or background accent, while normal-size text remains a
|
||||
high-contrast base-content color.
|
||||
|
||||
## Testing Strategy
|
||||
|
||||
- Test code-to-Series association by exact `seriesId` and deterministic ordinal
|
||||
ordering before adding the UI.
|
||||
- Test bracket-aligned round labels, code availability/expiry state, unique copy
|
||||
labels, and explicit clipboard success/failure results as pure functions.
|
||||
- Test every page-specific Series lifecycle/outcome branch, including played and
|
||||
administrative draws, so the local summary cannot drift silently.
|
||||
- Run the complete web suite, lint, and build after the focused tests pass.
|
||||
- When the in-app browser is available, runtime verification covers 320px, 768px,
|
||||
1024px, and 1440px; keyboard focus, copy announcements, long-code reflow, and
|
||||
console output are checked manually.
|
||||
|
||||
## Boundaries
|
||||
|
||||
### Always
|
||||
|
||||
- Join assignments to active Series only by the contract's `seriesId`.
|
||||
- Keep the full tournament code selectable and copy the unmodified string.
|
||||
- Preserve native link, button, list, table, heading, and disclosure semantics.
|
||||
- Use the existing design tokens and icon dependency.
|
||||
|
||||
### Ask First
|
||||
|
||||
- Change the API or public contract.
|
||||
- Add a dependency or browser-test framework.
|
||||
- Change tournament-code authorization or visibility policy.
|
||||
- Deploy, push, or alter CI.
|
||||
|
||||
### Never
|
||||
|
||||
- Infer a Series association from global game numbers.
|
||||
- Display an adjudicated `0–0` as if it were a played result.
|
||||
- Expose private facts or fabricate an adjudication reason.
|
||||
- Hide copy failure or rely on color alone for state.
|
||||
- Modify unrelated Competition, bracket, or theme behavior.
|
||||
|
||||
## Success Criteria
|
||||
|
||||
- Each active Series appears as a full-width next-match panel containing only its
|
||||
own ordered code rows.
|
||||
- Bracket-aligned labels lead raw Series codes, and Series-local set numbers lead
|
||||
global game numbers.
|
||||
- Ready Series show a pending score, while adjudicated results show their result
|
||||
category instead of a numeric score.
|
||||
- Copy buttons have unique accessible names, 44px targets, visible/live feedback,
|
||||
and an explicit failure path.
|
||||
- The roster uses Korean position labels in canonical role order, with the captain
|
||||
marker close to the player name.
|
||||
- At most two recent results are expanded by default; older results are available
|
||||
through a keyboard-accessible disclosure.
|
||||
- Focused and full tests, scoped lint, and build pass. Responsive runtime review is
|
||||
recorded separately when the in-app browser is available.
|
||||
|
||||
## Verification Record
|
||||
|
||||
- Focused view-model tests: 9 passed.
|
||||
- Full web suite: 88 passed without skips.
|
||||
- Scoped ESLint for all team-progress files: passed.
|
||||
- Production TypeScript/Vite build: passed; only the existing large-chunk warning
|
||||
remains.
|
||||
- Full repository lint remains blocked by pre-existing errors in unrelated files.
|
||||
- Runtime screenshot/keyboard verification was not claimed because the required
|
||||
in-app browser was unavailable in this session.
|
||||
|
||||
## Open Questions
|
||||
|
||||
None. The user approved the audit recommendations and requested implementation.
|
||||
Reference in new issue
Block a user