feat: polish match history UI
This commit is contained in:
1 parent
68afaf0cb8
commit
4906f665fd
4 files changed
+1403
-1074
No files matched your search
@@ -17,7 +17,6 @@ import { DEFAULT_COMMUNITY_ID } from "../config";
|
||||
import {
|
||||
championDisplayName,
|
||||
championIconUrl,
|
||||
runeIconUrl,
|
||||
runeKeystoneIconUrl,
|
||||
runeStyleIconUrl,
|
||||
summonerSpellIconUrl,
|
||||
@@ -32,14 +31,16 @@ import {
|
||||
internalMatchGamePath,
|
||||
} from "../lib/internal-match-routes";
|
||||
import { LANE_LABELS } from "../lib/riot-history";
|
||||
import {
|
||||
InternalGameAnalysisPanel,
|
||||
InternalGameDetailTabBar,
|
||||
type InternalGameDetailTab,
|
||||
} from "../components/InternalGameAnalysisTabs";
|
||||
import { ItemIcon } from "../components/ItemTooltip";
|
||||
|
||||
type MatchGameDetail = ApiInternalMatchDetailResponse["games"][number];
|
||||
type MatchGameTeam = MatchGameDetail["teams"][number];
|
||||
type MatchGameParticipant = MatchGameTeam["participants"][number];
|
||||
type DdragonManifestData = ReturnType<typeof useDdragonManifest>["data"];
|
||||
type RuneStyleEntry = NonNullable<DdragonManifestData>["runesReforged"][number];
|
||||
type DetailTab = "scoreboard" | "matchup" | "build";
|
||||
type TimelineMetric = "gold" | "xp";
|
||||
type MatchGameBackTarget = {
|
||||
to: string;
|
||||
@@ -50,12 +51,6 @@ type MatchGameNavigationState = {
|
||||
backLabel: string;
|
||||
};
|
||||
|
||||
const DETAIL_TABS: Array<{ id: DetailTab; label: string }> = [
|
||||
{ id: "scoreboard", label: "스코어보드" },
|
||||
{ id: "matchup", label: "라인전" },
|
||||
{ id: "build", label: "룬 / 빌드" },
|
||||
];
|
||||
|
||||
const TIMELINE_METRICS: Array<{ id: TimelineMetric; label: string }> = [
|
||||
{ id: "gold", label: "골드" },
|
||||
{ id: "xp", label: "경험치" },
|
||||
@@ -101,28 +96,6 @@ function createNavigationState(
|
||||
};
|
||||
}
|
||||
|
||||
const SKILL_ROWS: Array<{
|
||||
slot: 1 | 2 | 3 | 4;
|
||||
label: string;
|
||||
className: string;
|
||||
}> = [
|
||||
{ slot: 1, label: "Q", className: "bg-blue-500 text-white" },
|
||||
{ slot: 2, label: "W", className: "bg-cyan-500 text-white" },
|
||||
{ slot: 3, label: "E", className: "bg-amber-500 text-black" },
|
||||
{ slot: 4, label: "R", className: "bg-red-500 text-white" },
|
||||
];
|
||||
|
||||
const STAT_PERK_LABELS: Record<number, string> = {
|
||||
5001: "체력",
|
||||
5002: "방어",
|
||||
5003: "마저",
|
||||
5005: "공속",
|
||||
5007: "가속",
|
||||
5008: "적응",
|
||||
5010: "이속",
|
||||
5011: "체력",
|
||||
};
|
||||
|
||||
function formatDateTime(value: string | number) {
|
||||
return new Intl.DateTimeFormat("ko-KR", {
|
||||
month: "long",
|
||||
@@ -236,35 +209,6 @@ function resolveSelectedSeries(
|
||||
);
|
||||
}
|
||||
|
||||
function participantBuildKey(participant: MatchGameParticipant) {
|
||||
return `${participant.side}-${participant.userId ?? participant.summonerName}-${participant.championId}`;
|
||||
}
|
||||
|
||||
function findRuneStyle(
|
||||
manifest: DdragonManifestData,
|
||||
styleId: number | undefined,
|
||||
) {
|
||||
return manifest?.runesReforged.find((style) => style.id === styleId) ?? null;
|
||||
}
|
||||
|
||||
function selectedRuneIds(participant: MatchGameParticipant) {
|
||||
const explicit = participant.perks.selectedPerkIds ?? [];
|
||||
const fromStyles =
|
||||
participant.perks.styles?.flatMap((style) => style.perkIds) ?? [];
|
||||
return new Set([
|
||||
...explicit,
|
||||
...fromStyles,
|
||||
...(participant.perks.keystone ? [participant.perks.keystone] : []),
|
||||
]);
|
||||
}
|
||||
|
||||
function runeStyleSelection(
|
||||
participant: MatchGameParticipant,
|
||||
styleId: number | undefined,
|
||||
) {
|
||||
return participant.perks.styles?.find((style) => style.styleId === styleId);
|
||||
}
|
||||
|
||||
function WinBadge({ win }: { win: boolean }) {
|
||||
return win ? (
|
||||
<span className="inline-flex items-center border border-accent/60 bg-accent px-2 py-0.5 text-xs font-black text-accent-content">
|
||||
@@ -277,41 +221,33 @@ function WinBadge({ win }: { win: boolean }) {
|
||||
);
|
||||
}
|
||||
|
||||
function ChampionCell({
|
||||
function ChampionAvatar({
|
||||
participant,
|
||||
manifest,
|
||||
size = "h-9 w-9",
|
||||
}: {
|
||||
participant: MatchGameParticipant;
|
||||
manifest: ReturnType<typeof useDdragonManifest>["data"];
|
||||
size?: string;
|
||||
}) {
|
||||
const icon = championIconUrl(manifest, participant.championId);
|
||||
const name =
|
||||
championDisplayName(manifest, participant.championId) ??
|
||||
String(participant.championId);
|
||||
|
||||
return (
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<span className="relative h-10 w-10 shrink-0 overflow-hidden bg-base-content/10">
|
||||
{icon ? (
|
||||
<img src={icon} alt={name} className="h-full w-full object-cover" />
|
||||
) : null}
|
||||
{participant.championLevel > 0 && (
|
||||
<span className="absolute bottom-0 right-0 min-w-4 bg-base-300 px-1 text-center text-[10px] font-black leading-4 text-base-content">
|
||||
{participant.championLevel}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<div className="min-w-0">
|
||||
<span className="block truncate text-sm font-bold text-base-content">
|
||||
{name}
|
||||
<span
|
||||
className={`relative ${size} shrink-0 overflow-hidden bg-base-content/10`}
|
||||
title={name}
|
||||
>
|
||||
{icon ? (
|
||||
<img src={icon} alt={name} className="h-full w-full object-cover" />
|
||||
) : null}
|
||||
{participant.championLevel > 0 ? (
|
||||
<span className="absolute bottom-0 right-0 min-w-4 bg-base-300 px-1 text-center text-[10px] font-black leading-4 text-base-content">
|
||||
{participant.championLevel}
|
||||
</span>
|
||||
<span className="text-xs text-base-content/35">
|
||||
{LANE_LABELS[participant.teamPosition] ??
|
||||
participant.teamPosition ??
|
||||
"-"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1151,758 +1087,6 @@ function TeamTable({
|
||||
);
|
||||
}
|
||||
|
||||
function DetailTabBar({
|
||||
activeTab,
|
||||
onChange,
|
||||
}: {
|
||||
activeTab: DetailTab;
|
||||
onChange: (tab: DetailTab) => void;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex overflow-x-auto border border-base-content/10 bg-base-100">
|
||||
{DETAIL_TABS.map((tab) => (
|
||||
<button
|
||||
key={tab.id}
|
||||
type="button"
|
||||
onClick={() => onChange(tab.id)}
|
||||
className={`min-w-[7.5rem] border-r border-base-content/8 px-4 py-3 text-xs font-black transition-colors last:border-r-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary ${
|
||||
activeTab === tab.id
|
||||
? "bg-primary text-primary-content"
|
||||
: "text-base-content/45 hover:bg-base-content/[0.03] hover:text-base-content"
|
||||
}`}
|
||||
>
|
||||
{tab.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function RuneBuildPanel({
|
||||
selectedGame,
|
||||
detail,
|
||||
manifest,
|
||||
}: {
|
||||
selectedGame: MatchGameDetail;
|
||||
detail: ApiInternalMatchDetailResponse;
|
||||
manifest: DdragonManifestData;
|
||||
}) {
|
||||
const orderedTeams = [...selectedGame.teams].sort((left, right) =>
|
||||
left.side === right.side ? 0 : left.side === "blue" ? -1 : 1,
|
||||
);
|
||||
const participants = orderedTeams.flatMap((team) => team.participants);
|
||||
const defaultKey = participants[0]
|
||||
? participantBuildKey(participants[0])
|
||||
: "";
|
||||
const [selectedKey, setSelectedKey] = useState(defaultKey);
|
||||
const effectiveSelectedKey = participants.some(
|
||||
(participant) => participantBuildKey(participant) === selectedKey,
|
||||
)
|
||||
? selectedKey
|
||||
: defaultKey;
|
||||
const selectedParticipant =
|
||||
participants.find(
|
||||
(participant) =>
|
||||
participantBuildKey(participant) === effectiveSelectedKey,
|
||||
) ?? participants[0];
|
||||
|
||||
if (!selectedParticipant) {
|
||||
return (
|
||||
<section className="border border-base-content/10 bg-base-100 px-4 py-12 text-center text-sm font-bold text-base-content/35">
|
||||
빌드 데이터가 없습니다
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="overflow-hidden border border-base-content/10 bg-base-100">
|
||||
<BuildChampionSelector
|
||||
selectedGame={selectedGame}
|
||||
detail={detail}
|
||||
manifest={manifest}
|
||||
selectedKey={participantBuildKey(selectedParticipant)}
|
||||
onSelect={setSelectedKey}
|
||||
/>
|
||||
<div className="grid border-t border-base-content/8 lg:grid-cols-[minmax(0,1.05fr)_minmax(0,1fr)]">
|
||||
<RunesPanel participant={selectedParticipant} manifest={manifest} />
|
||||
<div className="border-t border-base-content/8 lg:border-l lg:border-t-0">
|
||||
<ItemBuildPanel
|
||||
participant={selectedParticipant}
|
||||
manifest={manifest}
|
||||
/>
|
||||
<SkillBuildPanel participant={selectedParticipant} />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function BuildChampionSelector({
|
||||
selectedGame,
|
||||
detail,
|
||||
manifest,
|
||||
selectedKey,
|
||||
onSelect,
|
||||
}: {
|
||||
selectedGame: MatchGameDetail;
|
||||
detail: ApiInternalMatchDetailResponse;
|
||||
manifest: DdragonManifestData;
|
||||
selectedKey: string;
|
||||
onSelect: (key: string) => void;
|
||||
}) {
|
||||
const orderedTeams = [...selectedGame.teams].sort((left, right) =>
|
||||
left.side === right.side ? 0 : left.side === "blue" ? -1 : 1,
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="grid gap-4 bg-base-content/[0.015] p-4 lg:grid-cols-2">
|
||||
{orderedTeams.map((team) => {
|
||||
const tone = sideTone(team.side);
|
||||
return (
|
||||
<div key={`build-selector-${team.side}`} className="min-w-0">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div className={`text-sm font-black ${tone.text}`}>
|
||||
{sideLabel(team.side)} Side
|
||||
</div>
|
||||
<div className="truncate text-xs font-bold text-base-content/40">
|
||||
{getTeamName(detail, team.teamIndex)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-2 flex flex-wrap gap-1.5">
|
||||
{team.participants.map((participant) => (
|
||||
<BuildChampionButton
|
||||
key={`build-select-${participantBuildKey(participant)}`}
|
||||
participant={participant}
|
||||
manifest={manifest}
|
||||
selected={participantBuildKey(participant) === selectedKey}
|
||||
onClick={() => onSelect(participantBuildKey(participant))}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function BuildChampionButton({
|
||||
participant,
|
||||
manifest,
|
||||
selected,
|
||||
onClick,
|
||||
}: {
|
||||
participant: MatchGameParticipant;
|
||||
manifest: DdragonManifestData;
|
||||
selected: boolean;
|
||||
onClick: () => void;
|
||||
}) {
|
||||
const icon = championIconUrl(manifest, participant.championId);
|
||||
const championName =
|
||||
championDisplayName(manifest, participant.championId) ??
|
||||
String(participant.championId);
|
||||
const tone = sideTone(participant.side);
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClick}
|
||||
title={`${participant.summonerName} · ${championName}`}
|
||||
className={`relative h-11 w-11 overflow-hidden border bg-base-content/10 transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary ${
|
||||
selected
|
||||
? `${tone.border} opacity-100 ring-2 ring-current ${tone.text}`
|
||||
: "border-base-content/5 opacity-35 hover:opacity-75"
|
||||
}`}
|
||||
>
|
||||
{icon ? (
|
||||
<img src={icon} alt="" className="h-full w-full object-cover" />
|
||||
) : null}
|
||||
{participant.championLevel > 0 ? (
|
||||
<span className="absolute bottom-0 right-0 min-w-4 bg-base-300 px-1 text-center text-[10px] font-black leading-4 text-base-content">
|
||||
{participant.championLevel}
|
||||
</span>
|
||||
) : null}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
function RunesPanel({
|
||||
participant,
|
||||
manifest,
|
||||
}: {
|
||||
participant: MatchGameParticipant;
|
||||
manifest: DdragonManifestData;
|
||||
}) {
|
||||
const selectedIds = selectedRuneIds(participant);
|
||||
const primaryStyleId =
|
||||
participant.perks.primaryStyle ?? participant.perks.styles?.[0]?.styleId;
|
||||
const subStyleId =
|
||||
participant.perks.subStyle ?? participant.perks.styles?.[1]?.styleId;
|
||||
const primaryStyle = findRuneStyle(manifest, primaryStyleId);
|
||||
const subStyle = findRuneStyle(manifest, subStyleId);
|
||||
|
||||
return (
|
||||
<div className="p-4">
|
||||
<div className="mb-4 flex min-w-0 items-center justify-between gap-3">
|
||||
<div>
|
||||
<div className="text-sm font-black text-base-content">Runes</div>
|
||||
<div className="mt-0.5 truncate text-xs text-base-content/40">
|
||||
{participant.summonerName}
|
||||
</div>
|
||||
</div>
|
||||
<ChampionCell participant={participant} manifest={manifest} />
|
||||
</div>
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
<RuneTreeColumn
|
||||
label="주 룬"
|
||||
runeStyle={primaryStyle}
|
||||
selection={runeStyleSelection(participant, primaryStyleId)}
|
||||
selectedIds={selectedIds}
|
||||
manifest={manifest}
|
||||
/>
|
||||
<RuneTreeColumn
|
||||
label="보조 룬"
|
||||
runeStyle={subStyle}
|
||||
selection={runeStyleSelection(participant, subStyleId)}
|
||||
selectedIds={selectedIds}
|
||||
manifest={manifest}
|
||||
/>
|
||||
</div>
|
||||
<RuneShardRows participant={participant} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function RuneTreeColumn({
|
||||
label,
|
||||
runeStyle,
|
||||
selection,
|
||||
selectedIds,
|
||||
manifest,
|
||||
}: {
|
||||
label: string;
|
||||
runeStyle: RuneStyleEntry | null;
|
||||
selection: ReturnType<typeof runeStyleSelection>;
|
||||
selectedIds: Set<number>;
|
||||
manifest: DdragonManifestData;
|
||||
}) {
|
||||
if (!runeStyle) {
|
||||
return (
|
||||
<div className="border border-base-content/8 bg-base-content/[0.02] p-3">
|
||||
<div className="text-xs font-black text-base-content/35">{label}</div>
|
||||
<div className="mt-8 text-center text-xs font-bold text-base-content/35">
|
||||
룬 데이터 없음
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const styleIcon = runeStyleIconUrl(manifest, runeStyle.id);
|
||||
const selectionIds = new Set(selection?.perkIds ?? []);
|
||||
|
||||
return (
|
||||
<div className="border border-base-content/8 bg-base-content/[0.02] p-3">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="h-7 w-7 overflow-hidden bg-base-content/10">
|
||||
{styleIcon ? (
|
||||
<img
|
||||
src={styleIcon}
|
||||
alt=""
|
||||
className="h-full w-full object-cover"
|
||||
/>
|
||||
) : null}
|
||||
</span>
|
||||
<div className="min-w-0">
|
||||
<div className="text-xs font-black text-base-content/35">{label}</div>
|
||||
<div className="truncate text-sm font-black text-base-content">
|
||||
{runeStyle.name}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-4 space-y-3">
|
||||
{runeStyle.slots.map((slot, slotIndex) => (
|
||||
<div
|
||||
key={`${runeStyle.id}-${slotIndex}`}
|
||||
className="grid justify-start gap-2 border-b border-base-content/8 pb-3 last:border-b-0 last:pb-0"
|
||||
style={{
|
||||
gridTemplateColumns: `repeat(${slot.runes.length}, minmax(0, 2.25rem))`,
|
||||
}}
|
||||
>
|
||||
{slot.runes.map((rune) => {
|
||||
const selected =
|
||||
selectedIds.has(rune.id) || selectionIds.has(rune.id);
|
||||
const icon = runeIconUrl(manifest, rune.id);
|
||||
return (
|
||||
<span
|
||||
key={rune.id}
|
||||
title={rune.name}
|
||||
className={`h-9 w-9 overflow-hidden border bg-base-content/10 transition ${
|
||||
selected
|
||||
? "border-base-content/20 opacity-100 ring-2 ring-base-content/20"
|
||||
: "border-transparent opacity-20 grayscale"
|
||||
}`}
|
||||
>
|
||||
{icon ? (
|
||||
<img
|
||||
src={icon}
|
||||
alt=""
|
||||
className="h-full w-full object-cover"
|
||||
/>
|
||||
) : null}
|
||||
</span>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function RuneShardRows({ participant }: { participant: MatchGameParticipant }) {
|
||||
const statPerks = participant.perks.statPerks;
|
||||
const shards = [
|
||||
{ label: "공격", value: statPerks?.offense },
|
||||
{ label: "보조", value: statPerks?.flex },
|
||||
{ label: "방어", value: statPerks?.defense },
|
||||
].filter((shard) => typeof shard.value === "number" && shard.value > 0);
|
||||
|
||||
if (shards.length === 0) return null;
|
||||
|
||||
return (
|
||||
<div className="mt-4 border border-base-content/8 bg-base-content/[0.02] px-3 py-2">
|
||||
<div className="text-xs font-black text-base-content/35">스탯 파편</div>
|
||||
<div className="mt-2 flex flex-wrap gap-2">
|
||||
{shards.map((shard) => (
|
||||
<span
|
||||
key={`${shard.label}-${shard.value}`}
|
||||
className="inline-flex items-center gap-1 border border-base-content/8 bg-base-100 px-2 py-1 text-xs font-bold text-base-content/60"
|
||||
>
|
||||
<span className="text-base-content/35">{shard.label}</span>
|
||||
{STAT_PERK_LABELS[shard.value ?? 0] ?? shard.value}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ItemBuildPanel({
|
||||
participant,
|
||||
manifest,
|
||||
}: {
|
||||
participant: MatchGameParticipant;
|
||||
manifest: DdragonManifestData;
|
||||
}) {
|
||||
const buildEvents = (participant.itemBuild ?? []).filter(
|
||||
(event) => event.itemId > 0 && event.type === "purchased",
|
||||
);
|
||||
const fallbackItems = [
|
||||
...participant.items.filter((itemId) => itemId > 0),
|
||||
participant.trinket,
|
||||
].filter((itemId) => itemId > 0);
|
||||
|
||||
return (
|
||||
<div className="p-4">
|
||||
<div className="text-sm font-black text-base-content">Item Build</div>
|
||||
{buildEvents.length > 0 ? (
|
||||
<div className="mt-3 flex flex-wrap items-start gap-x-2 gap-y-4">
|
||||
{buildEvents.map((event, index) => (
|
||||
<div
|
||||
key={`${event.timestamp}-${event.itemId}-${event.type}-${index}`}
|
||||
className="flex items-start gap-2"
|
||||
>
|
||||
<ItemBuildNode
|
||||
itemId={event.itemId}
|
||||
timestamp={event.timestamp}
|
||||
manifest={manifest}
|
||||
/>
|
||||
{index < buildEvents.length - 1 ? (
|
||||
<span className="pt-2 text-xs font-black text-base-content/25">
|
||||
>
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : fallbackItems.length > 0 ? (
|
||||
<div className="mt-3 flex flex-wrap gap-1.5">
|
||||
{fallbackItems.map((itemId, index) => {
|
||||
const icon = itemIconUrl(manifest, itemId);
|
||||
return (
|
||||
<span
|
||||
key={`fallback-item-${itemId}-${index}`}
|
||||
className="h-9 w-9 overflow-hidden border border-base-content/8 bg-base-content/10"
|
||||
>
|
||||
{icon ? (
|
||||
<img
|
||||
src={icon}
|
||||
alt=""
|
||||
className="h-full w-full object-cover"
|
||||
/>
|
||||
) : null}
|
||||
</span>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
) : (
|
||||
<div className="mt-6 text-center text-xs font-bold text-base-content/35">
|
||||
아이템 빌드 데이터 없음
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ItemBuildNode({
|
||||
itemId,
|
||||
timestamp,
|
||||
manifest,
|
||||
}: {
|
||||
itemId: number;
|
||||
timestamp: number;
|
||||
manifest: DdragonManifestData;
|
||||
}) {
|
||||
const icon = itemIconUrl(manifest, itemId);
|
||||
|
||||
return (
|
||||
<div className="w-11 text-center">
|
||||
<span className="mx-auto block h-9 w-9 overflow-hidden border border-base-content/8 bg-base-content/10">
|
||||
{icon ? (
|
||||
<img src={icon} alt="" className="h-full w-full object-cover" />
|
||||
) : null}
|
||||
</span>
|
||||
<span className="mt-1 block text-[11px] font-bold tabular-nums text-base-content/35">
|
||||
{formatDuration(timestamp)}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function SkillBuildPanel({
|
||||
participant,
|
||||
}: {
|
||||
participant: MatchGameParticipant;
|
||||
}) {
|
||||
const skillEvents = participant.skillBuild ?? [];
|
||||
const skillByLevel = new Map(
|
||||
skillEvents.map((event) => [event.level, event]),
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="border-t border-base-content/8 p-4">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div className="text-sm font-black text-base-content">Skill Build</div>
|
||||
<div className="text-xs font-bold text-base-content/35">
|
||||
Lv. {skillEvents.length || participant.championLevel || "-"}
|
||||
</div>
|
||||
</div>
|
||||
{skillEvents.length > 0 ? (
|
||||
<div className="mt-3 overflow-x-auto">
|
||||
<div className="min-w-[610px] space-y-1">
|
||||
{SKILL_ROWS.map((row) => (
|
||||
<div
|
||||
key={`skill-row-${row.slot}`}
|
||||
className="grid grid-cols-[2rem_repeat(18,minmax(1.45rem,1fr))] gap-1"
|
||||
>
|
||||
<div
|
||||
className={`flex h-7 items-center justify-center text-xs font-black ${row.className}`}
|
||||
>
|
||||
{row.label}
|
||||
</div>
|
||||
{Array.from({ length: 18 }, (_, index) => index + 1).map(
|
||||
(level) => {
|
||||
const event = skillByLevel.get(level);
|
||||
const active = event?.skillSlot === row.slot;
|
||||
return (
|
||||
<div
|
||||
key={`${row.slot}-${level}`}
|
||||
className={`flex h-7 items-center justify-center text-[11px] font-black tabular-nums ${
|
||||
active
|
||||
? row.className
|
||||
: "bg-base-content/[0.045] text-transparent"
|
||||
}`}
|
||||
>
|
||||
{active ? level : ""}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="mt-6 text-center text-xs font-bold text-base-content/35">
|
||||
스킬 빌드 데이터 없음
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const LANE_SORT_ORDER = ["TOP", "JUNGLE", "MIDDLE", "BOTTOM", "UTILITY"];
|
||||
|
||||
function laneSortValue(position: string) {
|
||||
const index = LANE_SORT_ORDER.indexOf(position);
|
||||
return index === -1 ? 99 : index;
|
||||
}
|
||||
|
||||
function ChampionAvatar({
|
||||
participant,
|
||||
manifest,
|
||||
size = "h-9 w-9",
|
||||
}: {
|
||||
participant: MatchGameParticipant;
|
||||
manifest: ReturnType<typeof useDdragonManifest>["data"];
|
||||
size?: string;
|
||||
}) {
|
||||
const icon = championIconUrl(manifest, participant.championId);
|
||||
const name =
|
||||
championDisplayName(manifest, participant.championId) ??
|
||||
String(participant.championId);
|
||||
return (
|
||||
<span
|
||||
className={`relative ${size} shrink-0 overflow-hidden bg-base-content/10`}
|
||||
title={name}
|
||||
>
|
||||
{icon ? (
|
||||
<img src={icon} alt={name} className="h-full w-full object-cover" />
|
||||
) : null}
|
||||
{participant.championLevel > 0 ? (
|
||||
<span className="absolute bottom-0 right-0 min-w-4 bg-base-300 px-1 text-center text-[10px] font-black leading-4 text-base-content">
|
||||
{participant.championLevel}
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function MatchupMetricRow({
|
||||
label,
|
||||
blueLead,
|
||||
redLead,
|
||||
blueText,
|
||||
redText,
|
||||
bluePct,
|
||||
}: {
|
||||
label: string;
|
||||
blueLead: boolean;
|
||||
redLead: boolean;
|
||||
blueText: string;
|
||||
redText: string;
|
||||
bluePct: number;
|
||||
}) {
|
||||
return (
|
||||
<div className="px-3 py-2">
|
||||
<div className="grid grid-cols-[1fr_auto_1fr] items-center gap-2 text-xs">
|
||||
<span
|
||||
className={`text-right tabular-nums ${
|
||||
blueLead
|
||||
? "font-black text-blue-400"
|
||||
: "font-bold text-base-content/55"
|
||||
}`}
|
||||
>
|
||||
{blueText}
|
||||
</span>
|
||||
<span className="text-[10px] font-bold uppercase tracking-wider text-base-content/30">
|
||||
{label}
|
||||
</span>
|
||||
<span
|
||||
className={`tabular-nums ${
|
||||
redLead
|
||||
? "font-black text-red-400"
|
||||
: "font-bold text-base-content/55"
|
||||
}`}
|
||||
>
|
||||
{redText}
|
||||
</span>
|
||||
</div>
|
||||
<div className="mt-1.5 flex h-1.5 overflow-hidden bg-base-content/8">
|
||||
<div
|
||||
className="bg-blue-500/70"
|
||||
style={{ width: `${Math.max(0, Math.min(100, bluePct))}%` }}
|
||||
/>
|
||||
<div
|
||||
className="ml-auto bg-red-500/70"
|
||||
style={{ width: `${Math.max(0, Math.min(100, 100 - bluePct))}%` }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function LaneMatchupCard({
|
||||
blue,
|
||||
red,
|
||||
detail,
|
||||
manifest,
|
||||
}: {
|
||||
blue: MatchGameParticipant;
|
||||
red: MatchGameParticipant;
|
||||
detail: ApiInternalMatchDetailResponse;
|
||||
manifest: ReturnType<typeof useDdragonManifest>["data"];
|
||||
}) {
|
||||
const laneLabel =
|
||||
LANE_LABELS[blue.teamPosition] ??
|
||||
LANE_LABELS[red.teamPosition] ??
|
||||
blue.teamPosition ??
|
||||
"-";
|
||||
|
||||
const metrics = [
|
||||
{
|
||||
key: "kda",
|
||||
label: "KDA",
|
||||
blueValue:
|
||||
blue.deaths === 0
|
||||
? blue.kills + blue.assists
|
||||
: (blue.kills + blue.assists) / blue.deaths,
|
||||
redValue:
|
||||
red.deaths === 0
|
||||
? red.kills + red.assists
|
||||
: (red.kills + red.assists) / red.deaths,
|
||||
blueText: `${blue.kills}/${blue.deaths}/${blue.assists}`,
|
||||
redText: `${red.kills}/${red.deaths}/${red.assists}`,
|
||||
},
|
||||
{
|
||||
key: "gold",
|
||||
label: "골드",
|
||||
blueValue: blue.gold,
|
||||
redValue: red.gold,
|
||||
blueText: formatNumber(blue.gold),
|
||||
redText: formatNumber(red.gold),
|
||||
},
|
||||
{
|
||||
key: "damage",
|
||||
label: "딜량",
|
||||
blueValue: blue.damageDealtToChampions,
|
||||
redValue: red.damageDealtToChampions,
|
||||
blueText: formatNumber(blue.damageDealtToChampions),
|
||||
redText: formatNumber(red.damageDealtToChampions),
|
||||
},
|
||||
{
|
||||
key: "cs",
|
||||
label: "CS",
|
||||
blueValue: blue.cs,
|
||||
redValue: red.cs,
|
||||
blueText: `${blue.cs} (${blue.csPerMin}/m)`,
|
||||
redText: `${red.cs} (${red.csPerMin}/m)`,
|
||||
},
|
||||
];
|
||||
|
||||
const championName = (participant: MatchGameParticipant) =>
|
||||
championDisplayName(manifest, participant.championId) ??
|
||||
String(participant.championId);
|
||||
|
||||
return (
|
||||
<div className="overflow-hidden border border-base-content/10 bg-base-100">
|
||||
<div className="grid grid-cols-[1fr_auto_1fr] items-center gap-2 border-b border-base-content/8 bg-base-content/[0.015] px-3 py-2">
|
||||
<div className="flex min-w-0 items-center justify-end gap-2">
|
||||
<div className="min-w-0 text-right">
|
||||
<div className="truncate text-xs font-bold text-base-content">
|
||||
{blue.summonerName}
|
||||
</div>
|
||||
<div className="truncate text-[11px] text-base-content/40">
|
||||
{championName(blue)}
|
||||
</div>
|
||||
</div>
|
||||
<ChampionAvatar participant={blue} manifest={manifest} />
|
||||
</div>
|
||||
<span className="border border-base-content/10 px-2 py-0.5 text-[10px] font-black uppercase tracking-wider text-base-content/45">
|
||||
{laneLabel}
|
||||
</span>
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<ChampionAvatar participant={red} manifest={manifest} />
|
||||
<div className="min-w-0">
|
||||
<div className="truncate text-xs font-bold text-base-content">
|
||||
{red.summonerName}
|
||||
</div>
|
||||
<div className="truncate text-[11px] text-base-content/40">
|
||||
{championName(red)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="divide-y divide-base-content/5">
|
||||
{metrics.map((metric) => {
|
||||
const total = metric.blueValue + metric.redValue;
|
||||
const bluePct = total > 0 ? (metric.blueValue / total) * 100 : 50;
|
||||
return (
|
||||
<MatchupMetricRow
|
||||
key={`${detail.match.matchId}-${blue.teamPosition}-${metric.key}`}
|
||||
label={metric.label}
|
||||
blueLead={metric.blueValue > metric.redValue}
|
||||
redLead={metric.redValue > metric.blueValue}
|
||||
blueText={metric.blueText}
|
||||
redText={metric.redText}
|
||||
bluePct={bluePct}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function LaneMatchupPanel({
|
||||
selectedGame,
|
||||
detail,
|
||||
manifest,
|
||||
}: {
|
||||
selectedGame: MatchGameDetail;
|
||||
detail: ApiInternalMatchDetailResponse;
|
||||
manifest: ReturnType<typeof useDdragonManifest>["data"];
|
||||
}) {
|
||||
const blueTeam = selectedGame.teams.find((team) => team.side === "blue");
|
||||
const redTeam = selectedGame.teams.find((team) => team.side === "red");
|
||||
|
||||
if (!blueTeam || !redTeam) {
|
||||
return (
|
||||
<section className="border border-base-content/10 bg-base-100 px-4 py-12 text-center text-sm font-bold text-base-content/35">
|
||||
라인전 비교 데이터가 없습니다
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
const blueSorted = [...blueTeam.participants].sort(
|
||||
(left, right) =>
|
||||
laneSortValue(left.teamPosition) - laneSortValue(right.teamPosition),
|
||||
);
|
||||
const redSorted = [...redTeam.participants].sort(
|
||||
(left, right) =>
|
||||
laneSortValue(left.teamPosition) - laneSortValue(right.teamPosition),
|
||||
);
|
||||
const blueTeamName = getTeamName(detail, blueTeam.teamIndex);
|
||||
const redTeamName = getTeamName(detail, redTeam.teamIndex);
|
||||
|
||||
return (
|
||||
<section className="overflow-hidden border border-base-content/10 bg-base-100">
|
||||
<div className="grid grid-cols-[1fr_auto_1fr] items-center gap-3 border-b border-base-content/8 px-4 py-3 text-xs font-black">
|
||||
<span className="truncate text-right text-blue-400">
|
||||
{blueTeamName}
|
||||
</span>
|
||||
<span className="text-base-content/20">VS</span>
|
||||
<span className="truncate text-red-400">{redTeamName}</span>
|
||||
</div>
|
||||
<div className="grid gap-3 p-4 lg:grid-cols-2">
|
||||
{blueSorted.map((blue, index) => {
|
||||
const red = redSorted[index];
|
||||
if (!red) return null;
|
||||
return (
|
||||
<LaneMatchupCard
|
||||
key={`matchup-${blue.teamPosition}-${blue.summonerName}`}
|
||||
blue={blue}
|
||||
red={red}
|
||||
detail={detail}
|
||||
manifest={manifest}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function ScoreboardTables({
|
||||
selectedGame,
|
||||
detail,
|
||||
@@ -1930,46 +1114,6 @@ function ScoreboardTables({
|
||||
);
|
||||
}
|
||||
|
||||
function GameAnalysisPanel({
|
||||
activeTab,
|
||||
selectedGame,
|
||||
detail,
|
||||
manifest,
|
||||
}: {
|
||||
activeTab: DetailTab;
|
||||
selectedGame: MatchGameDetail;
|
||||
detail: ApiInternalMatchDetailResponse;
|
||||
manifest: ReturnType<typeof useDdragonManifest>["data"];
|
||||
}) {
|
||||
if (activeTab === "scoreboard") {
|
||||
return (
|
||||
<ScoreboardTables
|
||||
selectedGame={selectedGame}
|
||||
detail={detail}
|
||||
manifest={manifest}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (activeTab === "build") {
|
||||
return (
|
||||
<RuneBuildPanel
|
||||
selectedGame={selectedGame}
|
||||
detail={detail}
|
||||
manifest={manifest}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<LaneMatchupPanel
|
||||
selectedGame={selectedGame}
|
||||
detail={detail}
|
||||
manifest={manifest}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function GameTabs({
|
||||
detail,
|
||||
communityId,
|
||||
@@ -2117,7 +1261,8 @@ function MatchScoreHero({
|
||||
export default function MatchGameDetailPage() {
|
||||
const { cid, matchId, id, gameNumber } = useParams();
|
||||
const location = useLocation();
|
||||
const [activeTab, setActiveTab] = useState<DetailTab>("scoreboard");
|
||||
const [activeTab, setActiveTab] =
|
||||
useState<InternalGameDetailTab>("scoreboard");
|
||||
const communityId = cid ?? DEFAULT_COMMUNITY_ID;
|
||||
const resolvedMatchId = matchId ?? id;
|
||||
const requestedGameNumber = Number(gameNumber);
|
||||
@@ -2184,12 +1329,22 @@ export default function MatchGameDetailPage() {
|
||||
/>
|
||||
|
||||
<div className="mt-5 space-y-4">
|
||||
<DetailTabBar activeTab={activeTab} onChange={setActiveTab} />
|
||||
<GameAnalysisPanel
|
||||
<InternalGameDetailTabBar
|
||||
activeTab={activeTab}
|
||||
onChange={setActiveTab}
|
||||
/>
|
||||
<InternalGameAnalysisPanel
|
||||
activeTab={activeTab}
|
||||
selectedGame={selectedGame}
|
||||
detail={detail}
|
||||
manifest={ddragon}
|
||||
scoreboard={
|
||||
<ScoreboardTables
|
||||
selectedGame={selectedGame}
|
||||
detail={detail}
|
||||
manifest={ddragon}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ const GAME_MODE_LABEL: Record<MatchGameMode, string> = {
|
||||
|
||||
function resultBadgeClass(won: boolean) {
|
||||
return won
|
||||
? "border-blue-500/20 bg-blue-500/10 text-blue-400"
|
||||
: "border-red-500/20 bg-red-500/10 text-red-400";
|
||||
? "border-info/20 bg-info/10 text-info"
|
||||
: "border-error/20 bg-error/10 text-error";
|
||||
}
|
||||
|
||||
function captainName(
|
||||
@@ -132,7 +132,7 @@ function ParticipantLine({
|
||||
{name}
|
||||
</span>
|
||||
{isCaptain && (
|
||||
<span className="shrink-0 border border-accent/20 bg-accent/10 px-1.5 py-0.5 text-xs font-bold text-amber-500">
|
||||
<span className="shrink-0 border border-accent/20 bg-accent/10 px-1.5 py-0.5 text-xs font-bold text-warning">
|
||||
팀장
|
||||
</span>
|
||||
)}
|
||||
@@ -436,7 +436,7 @@ function TeamGameCardsSection({
|
||||
|
||||
<div className="p-4">
|
||||
{replaceError && (
|
||||
<div className="mb-3 border border-red-500/20 bg-red-500/8 px-3 py-2 text-xs text-red-300">
|
||||
<div className="mb-3 border border-error/20 bg-error/8 px-3 py-2 text-xs text-error">
|
||||
{replaceError}
|
||||
</div>
|
||||
)}
|
||||
@@ -534,7 +534,7 @@ export default function MatchTeamProgressPage() {
|
||||
|
||||
if (!DEFAULT_COMMUNITY_ID) {
|
||||
return (
|
||||
<main className="mx-auto max-w-5xl px-4 py-20 text-center text-sm text-amber-600">
|
||||
<main className="mx-auto max-w-5xl px-4 py-20 text-center text-sm text-warning">
|
||||
`VITE_DEFAULT_COMMUNITY_ID` 설정이 필요합니다.
|
||||
</main>
|
||||
);
|
||||
@@ -704,9 +704,9 @@ export default function MatchTeamProgressPage() {
|
||||
aria-modal="true"
|
||||
aria-labelledby="team-tournament-code-replace-title"
|
||||
>
|
||||
<div className="w-full max-w-md border border-amber-500/25 bg-base-100 p-5 shadow-2xl">
|
||||
<div className="w-full max-w-md border border-warning/25 bg-base-100 p-5 shadow-2xl">
|
||||
<div className="flex items-start gap-3">
|
||||
<span className="inline-flex h-9 w-9 shrink-0 items-center justify-center border border-amber-500/25 bg-amber-500/10 text-amber-400">
|
||||
<span className="inline-flex h-9 w-9 shrink-0 items-center justify-center border border-warning/25 bg-warning/10 text-warning">
|
||||
<AlertTriangle className="h-4 w-4" />
|
||||
</span>
|
||||
<div className="min-w-0">
|
||||
@@ -746,7 +746,7 @@ export default function MatchTeamProgressPage() {
|
||||
handleConfirmReplaceTournamentCode();
|
||||
}
|
||||
}}
|
||||
className="mt-2 h-10 w-full border border-base-content/15 bg-base-100 px-3 text-sm text-base-content outline-none transition-colors focus:border-amber-400/60"
|
||||
className="mt-2 h-10 w-full border border-base-content/15 bg-base-100 px-3 text-sm text-base-content outline-none transition-colors focus:border-warning/60"
|
||||
placeholder="예"
|
||||
/>
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user