release/86 #2

Merged
dahyeon merged 108 commits from release/86 into main 2026-07-15 08:56:05 +00:00
5 changed files with 335 additions and 143 deletions
Showing only changes of commit 43c25c05cd - Show all commits

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}`;
}
@@ -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"
}`}
>
@@ -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");
}
+114 -64
View File
@@ -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({