feat: enhance auction interactions and player statistics UI
This commit is contained in:
1 parent
6c582ba3cf
commit
be4de61bb7
115 files changed
+13292
-2871
No files matched your search
@@ -0,0 +1,288 @@
|
||||
import {
|
||||
ArrowRight,
|
||||
CalendarDays,
|
||||
ChevronRight,
|
||||
Clock3,
|
||||
Info,
|
||||
Users,
|
||||
} from "lucide-react";
|
||||
import type { SeriesProjection } from "@lolympus/contracts";
|
||||
import type { ApiInternalMatchCard } from "../../api/types";
|
||||
import pixelMedal from "../../assets/pixel-medal-first.svg";
|
||||
import { formatOfficialMatchResult } from "../../lib/internal-stats-presentation";
|
||||
import {
|
||||
getSeriesHistoryResultLabel,
|
||||
shouldDisplaySeriesHistoryScore,
|
||||
} from "../competition/competition-series-history";
|
||||
import { StatsLink } from "./StatsShared";
|
||||
import { statsDate, statsDuration } from "./stats-navigation";
|
||||
import { statsGroups } from "./stats-model";
|
||||
|
||||
function statsFormat(match: ApiInternalMatchCard) {
|
||||
const result = match.resultPresentation;
|
||||
if (result?.type !== "official")
|
||||
return match.teams.length === 2 ? "두 팀 내전" : "내전 기록";
|
||||
return {
|
||||
"paired-series": "두 팀 내전",
|
||||
"double-elimination": "더블 엘리미네이션",
|
||||
"round-robin": "리그전",
|
||||
}[result.formatType];
|
||||
}
|
||||
function seriesLabel(series: SeriesProjection | undefined) {
|
||||
if (!series) return "공식 시리즈 정보 없음";
|
||||
if (series.stage.type === "pair")
|
||||
return series.rule.type === "first-to"
|
||||
? `${series.rule.winsRequired}선승 시리즈`
|
||||
: `${series.rule.gameCount}세트 시리즈`;
|
||||
return `${{ upper: "승자조", lower: "패자조", "grand-final": "최종 결승", "reset-final": "결승 재경기", "round-robin": "리그" }[series.stage.type]}${series.stage.roundNumber ? ` ${series.stage.roundNumber}라운드` : ""}`;
|
||||
}
|
||||
export function StatsEventOverview({ match }: { match: ApiInternalMatchCard }) {
|
||||
const analyzed = match.games.every(
|
||||
(g) => g.analysisAvailability !== undefined,
|
||||
)
|
||||
? match.games.filter((g) => g.analysisAvailability === "available").length
|
||||
: "—";
|
||||
return (
|
||||
<div className="is-event-overview">
|
||||
<div className="is-event-meta">
|
||||
<span>
|
||||
<CalendarDays size={14} />
|
||||
<time dateTime={match.scheduledAt}>
|
||||
{statsDate(match.scheduledAt)}{" "}
|
||||
{new Intl.DateTimeFormat("ko-KR", {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
hour12: false,
|
||||
timeZone: "Asia/Seoul",
|
||||
}).format(new Date(match.scheduledAt))}
|
||||
</time>
|
||||
</span>
|
||||
<span>
|
||||
<Users size={14} />
|
||||
{match.teams.length}팀 ·{" "}
|
||||
{match.teams.reduce((n, t) => n + t.members.length, 0)}명
|
||||
</span>
|
||||
<span>{match.games.length}세트 결과</span>
|
||||
<span className="is-analysis-count">{analyzed}세트 분석 가능</span>
|
||||
</div>
|
||||
<span className="is-champion-label">
|
||||
<img src={pixelMedal} alt="" className="size-4 shrink-0 [image-rendering:pixelated]" />
|
||||
<strong>{formatOfficialMatchResult(match.resultPresentation)}</strong>
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export function StatsSeries({
|
||||
match,
|
||||
gameHref,
|
||||
}: {
|
||||
match: ApiInternalMatchCard;
|
||||
gameHref: (number: number) => string;
|
||||
}) {
|
||||
const team = (index: number) =>
|
||||
match.teams.find((t) => t.teamIndex === index)?.name ?? `${index}팀`;
|
||||
const officialTeam = (id: string | null) =>
|
||||
match.teams.find((t) => t.teamId === id)?.name ??
|
||||
(id ? "팀 미확인" : "상대 미정");
|
||||
return (
|
||||
<div className="is-series-grid">
|
||||
{statsGroups(match).map(({ id, series, games }) => {
|
||||
const first = games[0],
|
||||
label = seriesLabel(series);
|
||||
const [a, b] = series?.entries ?? [];
|
||||
const score = series && shouldDisplaySeriesHistoryScore(series);
|
||||
const winner =
|
||||
series?.status === "completed" && series.outcome.type !== "draw"
|
||||
? series.outcome.winnerTeamId
|
||||
: null;
|
||||
return (
|
||||
<section className="is-series-group" key={id} aria-label={label}>
|
||||
<header>
|
||||
<span>{label}</span>
|
||||
<span>
|
||||
{games.length}세트
|
||||
{series &&
|
||||
score &&
|
||||
games.length !== (a?.gameWins ?? 0) + (b?.gameWins ?? 0)
|
||||
? " · 기간 내 기록"
|
||||
: ""}
|
||||
</span>
|
||||
</header>
|
||||
<div className="is-matchup">
|
||||
<strong
|
||||
className={winner && winner === a?.teamId ? "is-winner" : ""}
|
||||
>
|
||||
{a
|
||||
? officialTeam(a.teamId)
|
||||
: first
|
||||
? team(first.blueTeamIndex)
|
||||
: "팀 미확인"}
|
||||
</strong>
|
||||
<span className="is-score">
|
||||
{score ? (
|
||||
<>
|
||||
<b>{a?.gameWins}</b>
|
||||
<i>:</i>
|
||||
<b>{b?.gameWins}</b>
|
||||
</>
|
||||
) : series ? (
|
||||
(getSeriesHistoryResultLabel(series) ?? "VS")
|
||||
) : (
|
||||
"VS"
|
||||
)}
|
||||
</span>
|
||||
<strong
|
||||
className={winner && winner === b?.teamId ? "is-winner" : ""}
|
||||
>
|
||||
{b
|
||||
? officialTeam(b.teamId)
|
||||
: first
|
||||
? team(first.redTeamIndex)
|
||||
: "팀 미확인"}
|
||||
</strong>
|
||||
</div>
|
||||
<ul>
|
||||
{games.map((game) => (
|
||||
<li key={game.gameNumber}>
|
||||
<span className="is-set-number">
|
||||
{game.ordinal ?? game.gameNumber}세트
|
||||
<small>전체 #{game.gameNumber}</small>
|
||||
</span>
|
||||
<span className="is-set-winner">
|
||||
{game.winnerTeamIndex !== null ? (
|
||||
<>
|
||||
<span className="is-win-badge">승</span>
|
||||
{team(game.winnerTeamIndex)}
|
||||
</>
|
||||
) : (
|
||||
"결과 미확정"
|
||||
)}
|
||||
</span>
|
||||
<span className="is-duration">
|
||||
<Clock3 size={12} />
|
||||
{statsDuration(game.gameDuration)}
|
||||
</span>
|
||||
<StatsLink
|
||||
className={`is-analysis-link ${game.analysisAvailability !== "available" ? "is-unavailable" : ""}`}
|
||||
to={gameHref(game.gameNumber)}
|
||||
data-return-id={`set-${match.matchId}-${game.gameNumber}`}
|
||||
aria-label={`${match.title} 전체 ${game.gameNumber}세트 ${game.analysisAvailability === "missing" ? "원본 상태 확인" : "상세 분석"}`}
|
||||
>
|
||||
{game.analysisAvailability === "missing"
|
||||
? "원본 없음"
|
||||
: game.analysisAvailability === "pending"
|
||||
? "준비 중"
|
||||
: "분석"}
|
||||
{game.analysisAvailability === "missing" ? (
|
||||
<Info size={12} />
|
||||
) : (
|
||||
<ChevronRight size={13} />
|
||||
)}
|
||||
</StatsLink>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{games.length === 0 && (
|
||||
<p className="is-muted">
|
||||
{series && getSeriesHistoryResultLabel(series)} · 기록된 세트
|
||||
없음
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export function StatsEvent({
|
||||
match,
|
||||
eventHref,
|
||||
gameHref,
|
||||
}: {
|
||||
match: ApiInternalMatchCard;
|
||||
eventHref: string;
|
||||
gameHref: (number: number) => string;
|
||||
}) {
|
||||
return (
|
||||
<article className="is-event-section" id={`event-${match.matchId}`}>
|
||||
<header>
|
||||
<div>
|
||||
<div className="is-event-kicker">
|
||||
<span>{statsFormat(match)}</span>
|
||||
{Boolean(match.series?.length) && (
|
||||
<span>{match.series!.length}개 시리즈</span>
|
||||
)}
|
||||
</div>
|
||||
<h3>
|
||||
<StatsLink to={eventHref} data-return-id={`event-${match.matchId}`}>
|
||||
{match.title}
|
||||
<ChevronRight size={18} />
|
||||
</StatsLink>
|
||||
</h3>
|
||||
</div>
|
||||
<StatsLink
|
||||
className="is-text-link is-event-detail-link"
|
||||
to={eventHref}
|
||||
data-return-id={`event-detail-${match.matchId}`}
|
||||
>
|
||||
전체 기록
|
||||
<ArrowRight size={15} />
|
||||
</StatsLink>
|
||||
</header>
|
||||
<StatsEventOverview match={match} />
|
||||
<StatsSeries match={match} gameHref={gameHref} />
|
||||
{match.games.length === 0 && (
|
||||
<p className="is-event-empty is-muted">
|
||||
기록된 세트가 없습니다. 전체 기록에서 공식 결과를 확인할 수 있습니다.
|
||||
</p>
|
||||
)}
|
||||
</article>
|
||||
);
|
||||
}
|
||||
export function StatsEventJump({
|
||||
matches,
|
||||
}: {
|
||||
matches: ApiInternalMatchCard[];
|
||||
}) {
|
||||
return (
|
||||
<nav className="is-event-jump" aria-label="내전 바로가기">
|
||||
<div className="is-jump-desktop">
|
||||
<p>
|
||||
<CalendarDays size={15} /> 내전 바로가기
|
||||
</p>
|
||||
{matches.map((m) => (
|
||||
<a href={`#event-${m.matchId}`} key={m.matchId}>
|
||||
<span>{statsDate(m.scheduledAt)}</span>
|
||||
<strong>{m.title}</strong>
|
||||
<small>{statsFormat(m)}</small>
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
<label className="is-jump-mobile">
|
||||
<CalendarDays size={16} />
|
||||
<span>내전 이동</span>
|
||||
<select
|
||||
aria-label="내전 바로가기"
|
||||
defaultValue=""
|
||||
onChange={(e) =>
|
||||
document.getElementById(`event-${e.target.value}`)?.scrollIntoView({
|
||||
behavior: matchMedia("(prefers-reduced-motion: reduce)").matches
|
||||
? "instant"
|
||||
: "smooth",
|
||||
block: "start",
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="" disabled>
|
||||
날짜로 바로가기
|
||||
</option>
|
||||
{matches.map((m) => (
|
||||
<option key={m.matchId} value={m.matchId}>
|
||||
{statsDate(m.scheduledAt)} · {m.title}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user