feat: improve series score card presentation

Show outcome-aware labels and scores, prioritize readable match names, and provide complete accessible summaries for bracket cards.
This commit is contained in:
dahyeon committed 2026-07-13 23:16:43 -07:00
1 parent 43c25c05cd
commit 03e88a03bc
3 files changed
+437 -25

No files matched your search

@@ -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>
);
}
@@ -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 };
}
}