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
@@ -0,0 +1,923 @@
|
||||
import { useState, type ReactNode } from "react";
|
||||
import type { ApiInternalMatchDetailResponse, DdragonManifest, TeamSide } from "../api/types";
|
||||
import {
|
||||
championDisplayName,
|
||||
championIconUrl,
|
||||
runeIconUrl,
|
||||
runeStyleIconUrl,
|
||||
} from "../lib/ddragon";
|
||||
import { teamIndexLabel } from "../lib/league";
|
||||
import { LANE_LABELS } from "../lib/riot-history";
|
||||
import { ItemIcon } from "./ItemTooltip";
|
||||
|
||||
export type InternalGameDetailTab = "scoreboard" | "matchup" | "build";
|
||||
|
||||
type InternalGameDetail = ApiInternalMatchDetailResponse["games"][number];
|
||||
type InternalGameTeam = InternalGameDetail["teams"][number];
|
||||
type InternalGameParticipant = InternalGameTeam["participants"][number];
|
||||
type DdragonManifestData = DdragonManifest | null | undefined;
|
||||
type RuneStyleEntry = DdragonManifest["runesReforged"][number];
|
||||
|
||||
const DETAIL_TABS: Array<{ id: InternalGameDetailTab; label: string }> = [
|
||||
{ id: "scoreboard", label: "스코어보드" },
|
||||
{ id: "matchup", label: "라인전" },
|
||||
{ id: "build", label: "룬 / 빌드" },
|
||||
];
|
||||
|
||||
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: "체력",
|
||||
};
|
||||
|
||||
const LANE_SORT_ORDER = ["TOP", "JUNGLE", "MIDDLE", "BOTTOM", "UTILITY"];
|
||||
|
||||
function formatDuration(seconds: number) {
|
||||
const minutes = Math.floor(seconds / 60);
|
||||
const rest = seconds % 60;
|
||||
return `${minutes}:${String(rest).padStart(2, "0")}`;
|
||||
}
|
||||
|
||||
function formatNumber(value: number) {
|
||||
return new Intl.NumberFormat("ko-KR").format(value);
|
||||
}
|
||||
|
||||
function sideTone(side: TeamSide) {
|
||||
return side === "blue"
|
||||
? {
|
||||
border: "border-blue-500/20",
|
||||
bg: "bg-blue-500/5",
|
||||
text: "text-blue-400",
|
||||
bar: "bg-blue-500",
|
||||
}
|
||||
: {
|
||||
border: "border-red-500/20",
|
||||
bg: "bg-red-500/5",
|
||||
text: "text-red-400",
|
||||
bar: "bg-red-500",
|
||||
};
|
||||
}
|
||||
|
||||
function getTeamName(
|
||||
detail: ApiInternalMatchDetailResponse,
|
||||
teamIndex: number,
|
||||
) {
|
||||
return teamIndexLabel(
|
||||
teamIndex,
|
||||
detail.match.teams.find((team) => team.teamIndex === teamIndex)?.name,
|
||||
);
|
||||
}
|
||||
|
||||
function participantBuildKey(participant: InternalGameParticipant) {
|
||||
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: InternalGameParticipant) {
|
||||
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: InternalGameParticipant,
|
||||
styleId: number | undefined,
|
||||
) {
|
||||
return participant.perks.styles?.find((style) => style.styleId === styleId);
|
||||
}
|
||||
|
||||
function laneSortValue(position: string) {
|
||||
const index = LANE_SORT_ORDER.indexOf(position);
|
||||
return index === -1 ? 99 : index;
|
||||
}
|
||||
|
||||
function ChampionCell({
|
||||
participant,
|
||||
manifest,
|
||||
}: {
|
||||
participant: InternalGameParticipant;
|
||||
manifest: DdragonManifestData;
|
||||
}) {
|
||||
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 scale-[1.18]" />
|
||||
) : null}
|
||||
{participant.championLevel > 0 && (
|
||||
<span className="absolute bottom-0 right-0 min-w-4 bg-base-300 px-1 text-center text-[10px] font-bold 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>
|
||||
<span className="text-xs text-base-content/35">
|
||||
{LANE_LABELS[participant.teamPosition] ??
|
||||
participant.teamPosition ??
|
||||
"-"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ChampionAvatar({
|
||||
participant,
|
||||
manifest,
|
||||
size = "h-9 w-9",
|
||||
}: {
|
||||
participant: InternalGameParticipant;
|
||||
manifest: DdragonManifestData;
|
||||
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 scale-[1.18]" />
|
||||
) : null}
|
||||
{participant.championLevel > 0 ? (
|
||||
<span className="absolute bottom-0 right-0 min-w-4 bg-base-300 px-1 text-center text-[10px] font-bold leading-4 text-base-content">
|
||||
{participant.championLevel}
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function RuneBuildPanel({
|
||||
selectedGame,
|
||||
detail,
|
||||
manifest,
|
||||
}: {
|
||||
selectedGame: InternalGameDetail;
|
||||
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: InternalGameDetail;
|
||||
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-3 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-bold ${tone.text}`}>
|
||||
{team.side === "blue" ? "블루" : "레드"}
|
||||
</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: InternalGameParticipant;
|
||||
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
|
||||
? `border-transparent opacity-100 ring-1 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 scale-[1.18]" />
|
||||
) : null}
|
||||
{participant.championLevel > 0 ? (
|
||||
<span className="absolute bottom-0 right-0 min-w-4 bg-base-300 px-1 text-center text-[10px] font-bold leading-4 text-base-content">
|
||||
{participant.championLevel}
|
||||
</span>
|
||||
) : null}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
function RunesPanel({
|
||||
participant,
|
||||
manifest,
|
||||
}: {
|
||||
participant: InternalGameParticipant;
|
||||
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-3">
|
||||
<div className="mb-3 flex min-w-0 items-center justify-between gap-3">
|
||||
<div>
|
||||
<div className="text-xs font-bold uppercase tracking-wider text-base-content/35">
|
||||
룬
|
||||
</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-x-6 gap-y-4 md:grid-cols-2">
|
||||
<RuneTreeColumn
|
||||
label="주 룬"
|
||||
isPrimary
|
||||
runeStyle={primaryStyle}
|
||||
selection={runeStyleSelection(participant, primaryStyleId)}
|
||||
selectedIds={selectedIds}
|
||||
manifest={manifest}
|
||||
/>
|
||||
<RuneTreeColumn
|
||||
label="보조 룬"
|
||||
isPrimary={false}
|
||||
runeStyle={subStyle}
|
||||
selection={runeStyleSelection(participant, subStyleId)}
|
||||
selectedIds={selectedIds}
|
||||
manifest={manifest}
|
||||
/>
|
||||
</div>
|
||||
<RuneShardRows participant={participant} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function RuneTreeColumn({
|
||||
label,
|
||||
isPrimary,
|
||||
runeStyle,
|
||||
selection,
|
||||
selectedIds,
|
||||
manifest,
|
||||
}: {
|
||||
label: string;
|
||||
isPrimary: boolean;
|
||||
runeStyle: RuneStyleEntry | null;
|
||||
selection: ReturnType<typeof runeStyleSelection>;
|
||||
selectedIds: Set<number>;
|
||||
manifest: DdragonManifestData;
|
||||
}) {
|
||||
if (!runeStyle) {
|
||||
return (
|
||||
<div>
|
||||
<div className="text-xs font-bold uppercase tracking-wider 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>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="h-6 w-6 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-[10px] font-bold uppercase tracking-wider text-base-content/35">
|
||||
{label}
|
||||
</div>
|
||||
<div className="truncate text-xs font-bold text-base-content">
|
||||
{runeStyle.name}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-3 space-y-2.5">
|
||||
{runeStyle.slots.map((slot, slotIndex) => {
|
||||
// 보조 룬 트리는 핵심 룬(0번 행)을 선택하지 않으므로 숨긴다.
|
||||
if (!isPrimary && slotIndex === 0) return null;
|
||||
const isKeystoneRow = isPrimary && slotIndex === 0;
|
||||
const cell = isKeystoneRow ? "2.5rem" : "2.25rem";
|
||||
const iconSize = isKeystoneRow ? "h-10 w-10" : "h-9 w-9";
|
||||
return (
|
||||
<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, ${cell}))`,
|
||||
}}
|
||||
>
|
||||
{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={`${iconSize} overflow-hidden border bg-base-content/10 transition ${
|
||||
selected
|
||||
? "border-transparent opacity-100 ring-1 ring-primary/60"
|
||||
: "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: InternalGameParticipant }) {
|
||||
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 flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-base-content/8 pt-3 text-xs">
|
||||
<span className="font-bold uppercase tracking-wider text-base-content/35">
|
||||
스탯 파편
|
||||
</span>
|
||||
{shards.map((shard) => (
|
||||
<span key={`${shard.label}-${shard.value}`} className="text-base-content/60">
|
||||
<span className="text-base-content/35">{shard.label} </span>
|
||||
<span className="font-bold">
|
||||
{STAT_PERK_LABELS[shard.value ?? 0] ?? shard.value}
|
||||
</span>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ItemBuildPanel({
|
||||
participant,
|
||||
manifest,
|
||||
}: {
|
||||
participant: InternalGameParticipant;
|
||||
manifest: DdragonManifestData;
|
||||
}) {
|
||||
const buildEvents = (participant.itemBuild ?? []).filter(
|
||||
(event) => event.itemId > 0 && event.type === "purchased",
|
||||
);
|
||||
const fallbackItems = [
|
||||
...participant.items
|
||||
.filter((itemId) => itemId > 0)
|
||||
.map((itemId) => ({ itemId, trinket: false })),
|
||||
...(participant.trinket > 0
|
||||
? [{ itemId: participant.trinket, trinket: true }]
|
||||
: []),
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="p-3">
|
||||
<div className="text-xs font-bold uppercase tracking-wider text-base-content/35">
|
||||
아이템 빌드
|
||||
</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-bold text-base-content/25">
|
||||
>
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : fallbackItems.length > 0 ? (
|
||||
<div className="mt-3 flex flex-wrap gap-1.5">
|
||||
{fallbackItems.map((item, index) => (
|
||||
<ItemIcon
|
||||
key={`fallback-item-${item.itemId}-${index}`}
|
||||
itemId={item.itemId}
|
||||
manifest={manifest}
|
||||
trinket={item.trinket}
|
||||
className="h-9 w-9"
|
||||
/>
|
||||
))}
|
||||
</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;
|
||||
}) {
|
||||
return (
|
||||
<div className="w-11 text-center">
|
||||
<ItemIcon itemId={itemId} manifest={manifest} className="h-9 w-9" />
|
||||
<span className="mt-1 block text-[11px] font-bold tabular-nums text-base-content/35">
|
||||
{formatDuration(timestamp)}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function SkillBuildPanel({
|
||||
participant,
|
||||
}: {
|
||||
participant: InternalGameParticipant;
|
||||
}) {
|
||||
const skillEvents = participant.skillBuild ?? [];
|
||||
const skillByLevel = new Map(
|
||||
skillEvents.map((event) => [event.level, event]),
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="border-t border-base-content/8 p-3">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div className="text-xs font-bold uppercase tracking-wider text-base-content/35">
|
||||
스킬 빌드
|
||||
</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-bold ${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-bold 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>
|
||||
);
|
||||
}
|
||||
|
||||
function MatchupMetricRow({
|
||||
label,
|
||||
blueLead,
|
||||
redLead,
|
||||
blueText,
|
||||
redText,
|
||||
}: {
|
||||
label: string;
|
||||
blueLead: boolean;
|
||||
redLead: boolean;
|
||||
blueText: string;
|
||||
redText: string;
|
||||
}) {
|
||||
return (
|
||||
<div className="grid grid-cols-[1fr_auto_1fr] items-center gap-2 px-3 py-1.5 text-xs">
|
||||
<span
|
||||
className={`text-right tabular-nums ${
|
||||
blueLead ? "font-bold text-blue-400" : "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-bold text-red-400" : "text-base-content/55"
|
||||
}`}
|
||||
>
|
||||
{redText}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function LaneMatchupCard({
|
||||
blue,
|
||||
red,
|
||||
detail,
|
||||
manifest,
|
||||
}: {
|
||||
blue: InternalGameParticipant;
|
||||
red: InternalGameParticipant;
|
||||
detail: ApiInternalMatchDetailResponse;
|
||||
manifest: DdragonManifestData;
|
||||
}) {
|
||||
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: "cs",
|
||||
label: "CS",
|
||||
blueValue: blue.cs,
|
||||
redValue: red.cs,
|
||||
blueText: `${blue.cs} (${blue.csPerMin}/m)`,
|
||||
redText: `${red.cs} (${red.csPerMin}/m)`,
|
||||
},
|
||||
];
|
||||
|
||||
const championName = (participant: InternalGameParticipant) =>
|
||||
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-bold 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) => (
|
||||
<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}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function LaneMatchupPanel({
|
||||
selectedGame,
|
||||
detail,
|
||||
manifest,
|
||||
}: {
|
||||
selectedGame: InternalGameDetail;
|
||||
detail: ApiInternalMatchDetailResponse;
|
||||
manifest: DdragonManifestData;
|
||||
}) {
|
||||
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-bold">
|
||||
<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>
|
||||
);
|
||||
}
|
||||
|
||||
export function InternalGameDetailTabBar({
|
||||
activeTab,
|
||||
onChange,
|
||||
}: {
|
||||
activeTab: InternalGameDetailTab;
|
||||
onChange: (tab: InternalGameDetailTab) => void;
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
className="flex flex-wrap border-b border-base-content/8"
|
||||
role="tablist"
|
||||
aria-label="상세 분석"
|
||||
>
|
||||
{DETAIL_TABS.map((tab) => (
|
||||
<button
|
||||
key={tab.id}
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={activeTab === tab.id}
|
||||
onClick={() => onChange(tab.id)}
|
||||
className={`border-b-2 px-3 py-2 text-xs font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary ${
|
||||
activeTab === tab.id
|
||||
? "border-primary bg-primary/5 text-primary"
|
||||
: "border-transparent text-base-content/45 hover:text-base-content"
|
||||
}`}
|
||||
>
|
||||
{tab.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function InternalGameAnalysisPanel({
|
||||
activeTab,
|
||||
selectedGame,
|
||||
detail,
|
||||
manifest,
|
||||
scoreboard,
|
||||
}: {
|
||||
activeTab: InternalGameDetailTab;
|
||||
selectedGame: InternalGameDetail;
|
||||
detail: ApiInternalMatchDetailResponse;
|
||||
manifest: DdragonManifestData;
|
||||
scoreboard: ReactNode;
|
||||
}) {
|
||||
if (activeTab === "scoreboard") {
|
||||
return <>{scoreboard}</>;
|
||||
}
|
||||
|
||||
if (activeTab === "build") {
|
||||
return (
|
||||
<RuneBuildPanel
|
||||
selectedGame={selectedGame}
|
||||
detail={detail}
|
||||
manifest={manifest}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<LaneMatchupPanel
|
||||
selectedGame={selectedGame}
|
||||
detail={detail}
|
||||
manifest={manifest}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user