feat(web): redesign team progress experience
This commit is contained in:
1 parent
81b951889f
commit
bb32c26694
7 files changed
+973
-183
No files matched your search
@@ -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}선승`;
|
||||
}
|
||||
Reference in new issue
Block a user