Files
lolympus-tournament-support/apps/web/src/components/competition/TeamSeriesCard.tsx
T
dahyeon 664af15255 feat: refresh the home page and separate match event types
Add an inhouse hero, Hall of Fame, rankings, and event-specific schedules. Carry the event type through the API and admin tools, and improve results and player history displays.
2026-11-10 22:13:55 +09:00

136 lines
4.6 KiB
TypeScript

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">
<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}선승`;
}