feat: polish match history UI

This commit is contained in:
dahyeon committed 2026-06-26 23:10:42 -07:00
1 parent 68afaf0cb8
commit 4906f665fd
4 files changed
+1370 -1041

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">
&gt;
</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}
/>
);
}
+28 -873
View File
@@ -17,7 +17,6 @@ import { DEFAULT_COMMUNITY_ID } from "../config";
import { import {
championDisplayName, championDisplayName,
championIconUrl, championIconUrl,
runeIconUrl,
runeKeystoneIconUrl, runeKeystoneIconUrl,
runeStyleIconUrl, runeStyleIconUrl,
summonerSpellIconUrl, summonerSpellIconUrl,
@@ -32,14 +31,16 @@ import {
internalMatchGamePath, internalMatchGamePath,
} from "../lib/internal-match-routes"; } from "../lib/internal-match-routes";
import { LANE_LABELS } from "../lib/riot-history"; import { LANE_LABELS } from "../lib/riot-history";
import {
InternalGameAnalysisPanel,
InternalGameDetailTabBar,
type InternalGameDetailTab,
} from "../components/InternalGameAnalysisTabs";
import { ItemIcon } from "../components/ItemTooltip"; import { ItemIcon } from "../components/ItemTooltip";
type MatchGameDetail = ApiInternalMatchDetailResponse["games"][number]; type MatchGameDetail = ApiInternalMatchDetailResponse["games"][number];
type MatchGameTeam = MatchGameDetail["teams"][number]; type MatchGameTeam = MatchGameDetail["teams"][number];
type MatchGameParticipant = MatchGameTeam["participants"][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 TimelineMetric = "gold" | "xp";
type MatchGameBackTarget = { type MatchGameBackTarget = {
to: string; to: string;
@@ -50,12 +51,6 @@ type MatchGameNavigationState = {
backLabel: string; 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 }> = [ const TIMELINE_METRICS: Array<{ id: TimelineMetric; label: string }> = [
{ id: "gold", label: "골드" }, { id: "gold", label: "골드" },
{ id: "xp", 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) { function formatDateTime(value: string | number) {
return new Intl.DateTimeFormat("ko-KR", { return new Intl.DateTimeFormat("ko-KR", {
month: "long", 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 }) { function WinBadge({ win }: { win: boolean }) {
return win ? ( 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"> <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, participant,
manifest, manifest,
size = "h-9 w-9",
}: { }: {
participant: MatchGameParticipant; participant: MatchGameParticipant;
manifest: ReturnType<typeof useDdragonManifest>["data"]; manifest: ReturnType<typeof useDdragonManifest>["data"];
size?: string;
}) { }) {
const icon = championIconUrl(manifest, participant.championId); const icon = championIconUrl(manifest, participant.championId);
const name = const name =
championDisplayName(manifest, participant.championId) ?? championDisplayName(manifest, participant.championId) ??
String(participant.championId); String(participant.championId);
return ( return (
<div className="flex min-w-0 items-center gap-2"> <span
<span className="relative h-10 w-10 shrink-0 overflow-hidden bg-base-content/10"> className={`relative ${size} shrink-0 overflow-hidden bg-base-content/10`}
title={name}
>
{icon ? ( {icon ? (
<img src={icon} alt={name} className="h-full w-full object-cover" /> <img src={icon} alt={name} className="h-full w-full object-cover" />
) : null} ) : null}
{participant.championLevel > 0 && ( {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"> <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} {participant.championLevel}
</span> </span>
)} ) : null}
</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>
); );
} }
@@ -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">
&gt;
</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({ function ScoreboardTables({
selectedGame, selectedGame,
detail, 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({ function GameTabs({
detail, detail,
communityId, communityId,
@@ -2117,7 +1261,8 @@ function MatchScoreHero({
export default function MatchGameDetailPage() { export default function MatchGameDetailPage() {
const { cid, matchId, id, gameNumber } = useParams(); const { cid, matchId, id, gameNumber } = useParams();
const location = useLocation(); const location = useLocation();
const [activeTab, setActiveTab] = useState<DetailTab>("scoreboard"); const [activeTab, setActiveTab] =
useState<InternalGameDetailTab>("scoreboard");
const communityId = cid ?? DEFAULT_COMMUNITY_ID; const communityId = cid ?? DEFAULT_COMMUNITY_ID;
const resolvedMatchId = matchId ?? id; const resolvedMatchId = matchId ?? id;
const requestedGameNumber = Number(gameNumber); const requestedGameNumber = Number(gameNumber);
@@ -2184,12 +1329,22 @@ export default function MatchGameDetailPage() {
/> />
<div className="mt-5 space-y-4"> <div className="mt-5 space-y-4">
<DetailTabBar activeTab={activeTab} onChange={setActiveTab} /> <InternalGameDetailTabBar
<GameAnalysisPanel activeTab={activeTab}
onChange={setActiveTab}
/>
<InternalGameAnalysisPanel
activeTab={activeTab} activeTab={activeTab}
selectedGame={selectedGame} selectedGame={selectedGame}
detail={detail} detail={detail}
manifest={ddragon} manifest={ddragon}
scoreboard={
<ScoreboardTables
selectedGame={selectedGame}
detail={detail}
manifest={ddragon}
/>
}
/> />
</div> </div>
+8 -8
View File
@@ -33,8 +33,8 @@ const GAME_MODE_LABEL: Record<MatchGameMode, string> = {
function resultBadgeClass(won: boolean) { function resultBadgeClass(won: boolean) {
return won return won
? "border-blue-500/20 bg-blue-500/10 text-blue-400" ? "border-info/20 bg-info/10 text-info"
: "border-red-500/20 bg-red-500/10 text-red-400"; : "border-error/20 bg-error/10 text-error";
} }
function captainName( function captainName(
@@ -132,7 +132,7 @@ function ParticipantLine({
{name} {name}
</span> </span>
{isCaptain && ( {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> </span>
)} )}
@@ -436,7 +436,7 @@ function TeamGameCardsSection({
<div className="p-4"> <div className="p-4">
{replaceError && ( {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} {replaceError}
</div> </div>
)} )}
@@ -534,7 +534,7 @@ export default function MatchTeamProgressPage() {
if (!DEFAULT_COMMUNITY_ID) { if (!DEFAULT_COMMUNITY_ID) {
return ( 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` 설정이 필요합니다. `VITE_DEFAULT_COMMUNITY_ID` 설정이 필요합니다.
</main> </main>
); );
@@ -704,9 +704,9 @@ export default function MatchTeamProgressPage() {
aria-modal="true" aria-modal="true"
aria-labelledby="team-tournament-code-replace-title" 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"> <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" /> <AlertTriangle className="h-4 w-4" />
</span> </span>
<div className="min-w-0"> <div className="min-w-0">
@@ -746,7 +746,7 @@ export default function MatchTeamProgressPage() {
handleConfirmReplaceTournamentCode(); 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="예" placeholder="예"
/> />
+411 -160
View File
@@ -5,6 +5,7 @@ import { Link, useLocation, useParams, useSearchParams } from "react-router";
import { import {
useChampionStats, useChampionStats,
useDdragonManifest, useDdragonManifest,
useInternalMatchDetail,
useRecentMatches, useRecentMatches,
useRecentSummary, useRecentSummary,
useRefreshUserHistory, useRefreshUserHistory,
@@ -16,6 +17,7 @@ import { useRiotRefreshSocket } from "../api/useRiotRefreshSocket";
import type { import type {
ApiChampionStatsRow, ApiChampionStatsRow,
ApiEnqueueRefreshResult, ApiEnqueueRefreshResult,
ApiInternalMatchDetailResponse,
ApiRiotRefreshEvent, ApiRiotRefreshEvent,
ApiRecentMatchTeam, ApiRecentMatchTeam,
ApiRecentMatchTeamParticipant, ApiRecentMatchTeamParticipant,
@@ -42,6 +44,11 @@ import {
RANK_FILTER_TABS, RANK_FILTER_TABS,
} from "../lib/riot-history"; } from "../lib/riot-history";
import { ResponsiveTierLabel } from "../components/RankBadge"; import { ResponsiveTierLabel } from "../components/RankBadge";
import {
InternalGameAnalysisPanel,
InternalGameDetailTabBar,
type InternalGameDetailTab,
} from "../components/InternalGameAnalysisTabs";
import { ItemIcon } from "../components/ItemTooltip"; import { ItemIcon } from "../components/ItemTooltip";
// recharts가 무거워 메인 번들에서 분리한다 (전적 페이지에서만 로드). // recharts가 무거워 메인 번들에서 분리한다 (전적 페이지에서만 로드).
const TierHistoryChart = lazy(() => import("../components/TierHistoryChart")); const TierHistoryChart = lazy(() => import("../components/TierHistoryChart"));
@@ -118,6 +125,21 @@ function formatRefreshError(error: unknown) {
return error instanceof Error ? error.message : "갱신 요청에 실패했습니다."; return error instanceof Error ? error.message : "갱신 요청에 실패했습니다.";
} }
function socketStatusMeta(status: string): { tone: string; label: string } {
switch (status) {
case "connected":
return { tone: "bg-emerald-400", label: "실시간 연결됨" };
case "connecting":
return { tone: "bg-amber-400", label: "연결 중" };
case "error":
return { tone: "bg-red-400", label: "연결 오류" };
case "disconnected":
return { tone: "bg-base-content/30", label: "연결 끊김" };
default:
return { tone: "bg-base-content/20", label: "대기 중" };
}
}
function ratioClass(value: number) { function ratioClass(value: number) {
if (value >= 55) return "text-blue-400"; if (value >= 55) return "text-blue-400";
if (value >= 50) return "text-amber-400"; if (value >= 50) return "text-amber-400";
@@ -158,24 +180,34 @@ function ChampionIcon({
championId, championId,
manifest, manifest,
size = "md", size = "md",
className = "",
}: { }: {
championId: number; championId: number;
manifest: DdragonManifest | null | undefined; manifest: DdragonManifest | null | undefined;
size?: "sm" | "md" | "lg"; size?: "xs" | "sm" | "md" | "lg";
className?: string;
}) { }) {
const iconUrl = championIconUrl(manifest, championId); const iconUrl = championIconUrl(manifest, championId);
const displayName = const displayName =
championDisplayName(manifest, championId) ?? String(championId); championDisplayName(manifest, championId) ?? String(championId);
const sizeClass = const sizeClass =
size === "lg" ? "w-12 h-12" : size === "sm" ? "w-5 h-5" : "w-8 h-8"; size === "lg"
? "w-12 h-12"
: size === "sm"
? "w-5 h-5"
: size === "xs"
? "w-4 h-4"
: "w-8 h-8";
return ( return (
<div className={`${sizeClass} bg-base-content/10 overflow-hidden shrink-0`}> <div
className={`${sizeClass} bg-base-content/10 overflow-hidden shrink-0 ${className}`}
>
{iconUrl ? ( {iconUrl ? (
<img <img
src={iconUrl} src={iconUrl}
alt={displayName} alt={displayName}
className="w-full h-full object-cover" className="w-full h-full object-cover scale-[1.18]"
loading="lazy" loading="lazy"
/> />
) : null} ) : null}
@@ -197,12 +229,10 @@ function SummaryCard({
<div className="text-xs font-bold uppercase tracking-wider text-base-content/30"> <div className="text-xs font-bold uppercase tracking-wider text-base-content/30">
{label} {label}
</div> </div>
<div className="mt-2 text-2xl font-black text-base-content tabular-nums"> <div className="mt-2 text-2xl font-bold text-base-content tabular-nums">
{value} {value}
</div> </div>
{sub && ( {sub && <div className="mt-1 text-xs text-base-content/40">{sub}</div>}
<div className="mt-1 text-xs text-base-content/40">{sub}</div>
)}
</div> </div>
); );
} }
@@ -232,17 +262,17 @@ function ChampionStatsTable({
<table className="w-full text-left min-w-[860px]"> <table className="w-full text-left min-w-[860px]">
<thead> <thead>
<tr className="bg-base-200/50 border-b border-base-content/10 text-xs text-base-content/35 uppercase tracking-wider"> <tr className="bg-base-200/50 border-b border-base-content/10 text-xs text-base-content/35 uppercase tracking-wider">
<th className="px-3 py-2.5">챔피언</th> <th className="px-3 py-3">챔피언</th>
<th className="px-3 py-2.5 text-center">승률</th> <th className="px-3 py-3 text-center">승률</th>
<th className="px-3 py-2.5 text-center">게임</th> <th className="px-3 py-3 text-center">게임</th>
<th className="px-3 py-2.5 text-center">승/패</th> <th className="px-3 py-3 text-center">승/패</th>
<th className="px-3 py-2.5 text-center">KDA</th> <th className="px-3 py-3 text-center">KDA</th>
<th className="px-3 py-2.5 text-center">킬</th> <th className="px-3 py-3 text-center">킬</th>
<th className="px-3 py-2.5 text-center">데스</th> <th className="px-3 py-3 text-center">데스</th>
<th className="px-3 py-2.5 text-center">어시스트</th> <th className="px-3 py-3 text-center">어시스트</th>
<th className="px-3 py-2.5 text-center">멀티킬</th> <th className="px-3 py-3 text-center">멀티킬</th>
<th className="px-3 py-2.5 text-center">CS</th> <th className="px-3 py-3 text-center">CS</th>
<th className="px-3 py-2.5 text-center">필터</th> <th className="px-3 py-3 text-center">필터</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -256,7 +286,7 @@ function ChampionStatsTable({
key={row.championId} key={row.championId}
className="border-b border-base-content/5 last:border-b-0 hover:bg-base-content/[0.02]" className="border-b border-base-content/5 last:border-b-0 hover:bg-base-content/[0.02]"
> >
<td className="px-3 py-2.5"> <td className="px-3 py-3">
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<ChampionIcon <ChampionIcon
championId={row.championId} championId={row.championId}
@@ -268,39 +298,39 @@ function ChampionStatsTable({
</div> </div>
</td> </td>
<td <td
className={`px-3 py-2.5 text-center text-sm font-bold ${ratioClass(row.winRate)}`} className={`px-3 py-3 text-center text-sm font-bold ${ratioClass(row.winRate)}`}
> >
{row.winRate}% {row.winRate}%
</td> </td>
<td className="px-3 py-2.5 text-center text-xs tabular-nums"> <td className="px-3 py-3 text-center text-xs tabular-nums">
{row.games} {row.games}
</td> </td>
<td className="px-3 py-2.5 text-center text-xs tabular-nums text-base-content/55"> <td className="px-3 py-3 text-center text-xs tabular-nums text-base-content/55">
<span className="text-blue-400">{row.wins}</span> /{" "} <span className="text-blue-400">{row.wins}</span> /{" "}
<span className="text-red-400">{row.losses}</span> <span className="text-red-400">{row.losses}</span>
</td> </td>
<td <td
className={`px-3 py-2.5 text-center text-sm font-bold tabular-nums ${kdaClass(row.kda)}`} className={`px-3 py-3 text-center text-sm font-bold tabular-nums ${kdaClass(row.kda)}`}
> >
{row.kda} {row.kda}
</td> </td>
<td className="px-3 py-2.5 text-center text-xs tabular-nums"> <td className="px-3 py-3 text-center text-xs tabular-nums">
{row.totalKills} {row.totalKills}
</td> </td>
<td className="px-3 py-2.5 text-center text-xs tabular-nums"> <td className="px-3 py-3 text-center text-xs tabular-nums">
{row.totalDeaths} {row.totalDeaths}
</td> </td>
<td className="px-3 py-2.5 text-center text-xs tabular-nums"> <td className="px-3 py-3 text-center text-xs tabular-nums">
{row.totalAssists} {row.totalAssists}
</td> </td>
<td className="px-3 py-2.5 text-center text-xs tabular-nums text-base-content/55"> <td className="px-3 py-3 text-center text-xs tabular-nums text-base-content/55">
{row.doubleKills}/{row.tripleKills}/{row.quadraKills}/ {row.doubleKills}/{row.tripleKills}/{row.quadraKills}/
{row.pentaKills} {row.pentaKills}
</td> </td>
<td className="px-3 py-2.5 text-center text-xs tabular-nums"> <td className="px-3 py-3 text-center text-xs tabular-nums">
{row.avgCs} · {row.avgCsPerMin}/m {row.avgCs} · {row.avgCsPerMin}/m
</td> </td>
<td className="px-3 py-2.5 text-center"> <td className="px-3 py-3 text-center">
<button <button
type="button" type="button"
className={`text-xs px-2 py-1 border ${ className={`text-xs px-2 py-1 border ${
@@ -325,6 +355,25 @@ function ChampionStatsTable({
); );
} }
function ItemSlot({
itemId,
manifest,
trinket = false,
}: {
itemId: number;
manifest: DdragonManifest | null | undefined;
trinket?: boolean;
}) {
return (
<ItemIcon
itemId={itemId}
manifest={manifest}
trinket={trinket}
className="h-6 w-6"
/>
);
}
function ItemGrid({ function ItemGrid({
items, items,
trinket, trinket,
@@ -338,44 +387,45 @@ function ItemGrid({
itemKey: string; itemKey: string;
variant?: "card" | "detail"; variant?: "card" | "detail";
}) { }) {
const slots = [...items.slice(0, 6), trinket]; // 6칸을 항상 채워 트링켓이 밀리지 않도록 빈 슬롯으로 패딩한다.
const layoutClass = const coreItems = [...items.slice(0, 6)];
variant === "detail" ? "grid-cols-7 w-[164px]" : "grid-cols-4 w-[92px]"; while (coreItems.length < 6) coreItems.push(0);
const gridCols = variant === "detail" ? "grid-cols-6" : "grid-cols-3";
return ( return (
<div className={`grid gap-1 ${layoutClass}`}> <div className="flex items-center gap-1.5">
{slots.map((itemId, index) => ( <div className={`grid gap-1 ${gridCols}`}>
<ItemIcon {coreItems.map((itemId, index) => (
<ItemSlot
key={`${itemKey}-item-${index}`} key={`${itemKey}-item-${index}`}
itemId={itemId} itemId={itemId}
manifest={manifest} manifest={manifest}
trinket={index === 6}
className="h-5 w-5"
imageClassName=""
/> />
))} ))}
</div> </div>
<ItemSlot itemId={trinket} manifest={manifest} trinket />
</div>
); );
} }
function TeamMini({ function TeamMini({
match, match,
manifest, manifest,
ownerParticipantId,
}: { }: {
match: ApiRecentMatchView; match: ApiRecentMatchView;
manifest: DdragonManifest | null | undefined; manifest: DdragonManifest | null | undefined;
ownerParticipantId: string;
}) { }) {
return ( return (
<div className="grid sm:grid-cols-2 gap-2 text-xs"> <div className="grid flex-1 grid-cols-2 gap-x-3 text-[10px] leading-tight min-w-0">
{match.teams.map((team) => ( {match.teams.map((team) => (
<div <div key={`${match.matchId}-${team.side}`} className="min-w-0">
key={`${match.matchId}-${team.side}`}
className={`space-y-0.5 ${team.win ? "text-base-content/70" : "text-base-content/35"}`}
>
{team.participants.map((participant) => { {team.participants.map((participant) => {
const championName = const championName =
championDisplayName(manifest, participant.championId) ?? championDisplayName(manifest, participant.championId) ??
String(participant.championId); String(participant.championId);
const isOwner = participant.puuid === ownerParticipantId;
return ( return (
<div <div
key={`${participant.puuid}-${participant.championId}`} key={`${participant.puuid}-${participant.championId}`}
@@ -384,9 +434,18 @@ function TeamMini({
<ChampionIcon <ChampionIcon
championId={participant.championId} championId={participant.championId}
manifest={manifest} manifest={manifest}
size="sm" size="xs"
className={
isOwner ? "ring-1 ring-primary ring-inset" : undefined
}
/> />
<span className="truncate"> <span
className={`truncate ${
isOwner
? "font-bold text-base-content/80"
: "text-base-content/40"
}`}
>
{participant.gameName || championName} {participant.gameName || championName}
</span> </span>
</div> </div>
@@ -399,9 +458,7 @@ function TeamMini({
} }
type MatchDetailScales = { type MatchDetailScales = {
maxGold: number;
maxDamage: number; maxDamage: number;
maxTaken: number;
}; };
function formatCompactNumber(value: number) { function formatCompactNumber(value: number) {
@@ -441,7 +498,12 @@ function AssetIcon({
aria-label={label} aria-label={label}
> >
{url ? ( {url ? (
<img src={url} alt="" className="w-full h-full object-cover" loading="lazy" /> <img
src={url}
alt=""
className="w-full h-full object-cover"
loading="lazy"
/>
) : null} ) : null}
</div> </div>
); );
@@ -457,22 +519,26 @@ function LoadoutIcons({
manifest: DdragonManifest | null | undefined; manifest: DdragonManifest | null | undefined;
}) { }) {
return ( return (
<div className="flex items-center gap-1"> <div className="grid grid-cols-2 gap-0.5 shrink-0">
<AssetIcon <AssetIcon
url={summonerSpellIconUrl(manifest, summonerSpells[0])} url={summonerSpellIconUrl(manifest, summonerSpells[0])}
label="스펠 1" label="스펠 1"
/> className="w-5 h-5"
<AssetIcon
url={summonerSpellIconUrl(manifest, summonerSpells[1])}
label="스펠 2"
/> />
<AssetIcon <AssetIcon
url={runeKeystoneIconUrl(manifest, perks.keystone)} url={runeKeystoneIconUrl(manifest, perks.keystone)}
label="핵심 룬" label="핵심 룬"
className="w-5 h-5"
/>
<AssetIcon
url={summonerSpellIconUrl(manifest, summonerSpells[1])}
label="스펠 2"
className="w-5 h-5"
/> />
<AssetIcon <AssetIcon
url={runeStyleIconUrl(manifest, perks.subStyle ?? perks.primaryStyle)} url={runeStyleIconUrl(manifest, perks.subStyle ?? perks.primaryStyle)}
label="보조 룬" label="보조 룬"
className="w-5 h-5"
/> />
</div> </div>
); );
@@ -497,7 +563,7 @@ function DetailStatBar({
{formatCompactNumber(value)} {formatCompactNumber(value)}
</span> </span>
</div> </div>
<div className="mt-1 h-1.5 overflow-hidden bg-base-content/8"> <div className="mt-0.5 h-1 overflow-hidden bg-base-content/8">
<div <div
className={`h-full ${fillClass}`} className={`h-full ${fillClass}`}
style={{ width: `${barPercent(value, max)}%` }} style={{ width: `${barPercent(value, max)}%` }}
@@ -509,18 +575,18 @@ function DetailStatBar({
function TeamHeader({ team }: { team: ApiRecentMatchTeam }) { function TeamHeader({ team }: { team: ApiRecentMatchTeam }) {
const sideLabel = team.side === 100 ? "블루팀" : "레드팀"; const sideLabel = team.side === 100 ? "블루팀" : "레드팀";
const sideClass = team.side === 100 ? "text-sky-400" : "text-rose-400"; const sideClass = team.side === 100 ? "text-blue-400" : "text-red-400";
const resultClass = team.win ? "text-blue-400" : "text-red-400"; const resultClass = team.win ? "text-blue-400" : "text-red-400";
return ( return (
<div className="px-3 py-2 flex flex-wrap items-center justify-between gap-2 border-b border-base-content/10"> <div className="px-3 py-1.5 flex flex-wrap items-center justify-between gap-2 border-b border-base-content/10">
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<span <span
className={`text-xs font-black uppercase tracking-wider ${sideClass}`} className={`text-xs font-bold uppercase tracking-wider ${sideClass}`}
> >
{sideLabel} {sideLabel}
</span> </span>
<span className={`text-xs font-black ${resultClass}`}> <span className={`text-xs font-bold ${resultClass}`}>
{team.win ? "승리" : "패배"} {team.win ? "승리" : "패배"}
</span> </span>
</div> </div>
@@ -539,12 +605,14 @@ function ParticipantRow({
ownerParticipantId, ownerParticipantId,
scales, scales,
teamSide, teamSide,
teamKills,
}: { }: {
participant: ApiRecentMatchTeamParticipant; participant: ApiRecentMatchTeamParticipant;
manifest: DdragonManifest | null | undefined; manifest: DdragonManifest | null | undefined;
ownerParticipantId: string; ownerParticipantId: string;
scales: MatchDetailScales; scales: MatchDetailScales;
teamSide: 100 | 200; teamSide: 100 | 200;
teamKills: number;
}) { }) {
const championName = const championName =
championDisplayName(manifest, participant.championId) ?? championDisplayName(manifest, participant.championId) ??
@@ -553,28 +621,34 @@ function ParticipantRow({
const participantName = participant.gameName || championName; const participantName = participant.gameName || championName;
const isOwner = participant.puuid === ownerParticipantId; const isOwner = participant.puuid === ownerParticipantId;
const kda = resolveParticipantKda(participant); const kda = resolveParticipantKda(participant);
const fillClass = teamSide === 100 ? "bg-sky-400/70" : "bg-rose-400/70"; const fillClass = teamSide === 100 ? "bg-blue-400/70" : "bg-red-400/70";
const killParticipation =
teamKills > 0
? Math.round(
((participant.kills + participant.assists) / teamKills) * 100,
)
: 0;
return ( return (
<div <div
className={`grid min-w-[920px] grid-cols-[260px_86px_132px_220px_164px] gap-3 items-center border-b border-base-content/5 border-l-2 px-3 py-2 text-xs last:border-b-0 ${ className={`grid min-w-[860px] grid-cols-[240px_92px_150px_104px_104px_196px] gap-3 items-center border-b border-base-content/5 border-l-2 px-3 py-1.5 text-xs last:border-b-0 ${
isOwner isOwner
? "border-l-primary bg-primary/[0.05]" ? "border-l-primary bg-primary/[0.05]"
: "border-l-transparent hover:bg-base-content/[0.02]" : "border-l-transparent hover:bg-base-content/[0.02]"
}`} }`}
> >
<div className="flex items-center gap-2 min-w-0"> <div className="flex items-center gap-2 min-w-0">
<div className="relative w-10 h-10 shrink-0 overflow-hidden bg-base-content/10"> <div className="relative w-9 h-9 shrink-0 overflow-hidden bg-base-content/10">
{championUrl ? ( {championUrl ? (
<img <img
src={championUrl} src={championUrl}
alt={championName} alt={championName}
className="w-full h-full object-cover" className="w-full h-full object-cover scale-[1.18]"
loading="lazy" loading="lazy"
/> />
) : null} ) : null}
{participant.championLevel > 0 && ( {participant.championLevel > 0 && (
<span className="absolute bottom-0 right-0 min-w-4 bg-base-300 px-1 text-center text-xs font-black leading-4 text-base-content"> <span className="absolute bottom-0 right-0 min-w-4 bg-base-300 px-1 text-center text-xs font-bold leading-4 text-base-content">
{participant.championLevel} {participant.championLevel}
</span> </span>
)} )}
@@ -608,60 +682,53 @@ function ParticipantRow({
> >
{participantName} {participantName}
</div> </div>
<div className="truncate text-xs text-base-content/35"> {/* 티어 (임시: 백엔드 연동 전까지 비움 — 라인은 행 순서로 식별) */}
{participant.tagLine ? `#${participant.tagLine} · ` : ""} <div className="truncate text-xs text-base-content/30">—</div>
{(LANE_LABELS[participant.teamPosition] ?? participant.teamPosition) ||
"포지션 없음"}
</div>
</div> </div>
</div> </div>
<div className="text-center tabular-nums"> <div className="text-center tabular-nums">
<div className="font-black text-base-content"> <div className="font-bold text-base-content">
{participant.kills} {participant.kills}
<span className="text-base-content/25"> / </span> <span className="text-base-content/25"> / </span>
<span className="text-red-400">{participant.deaths}</span> <span className="text-red-400">{participant.deaths}</span>
<span className="text-base-content/25"> / </span> <span className="text-base-content/25"> / </span>
{participant.assists} {participant.assists}
</div> </div>
<div className={`mt-0.5 text-xs font-bold ${kdaClass(kda)}`}> <div className="mt-0.5 text-xs">
{participant.deaths === 0 ? "Perfect" : `${kda} KDA`} <span className={`font-bold ${kdaClass(kda)}`}>
</div> {participant.deaths === 0 ? "Perfect" : kda}
</div>
<div className="space-y-2 tabular-nums">
<div className="flex items-center justify-between gap-2 text-xs text-base-content/45">
<span>CS</span>
<span className="font-bold text-base-content/70">
{participant.totalCs} ({participant.csPerMin}/m)
</span> </span>
<span className="text-base-content/35"> · {killParticipation}%</span>
</div> </div>
<DetailStatBar
label="골드"
value={participant.goldEarned}
max={scales.maxGold}
fillClass="bg-amber-400/70"
/>
</div> </div>
<div className="space-y-2 tabular-nums">
<div className="grid grid-cols-2 gap-3">
<DetailStatBar <DetailStatBar
label="가한 피해" label="피해량"
value={participant.damageDealtToChampions} value={participant.damageDealtToChampions}
max={scales.maxDamage} max={scales.maxDamage}
fillClass={fillClass} fillClass={fillClass}
/> />
<DetailStatBar
label="받은 피해" <div className="text-xs text-base-content/45 tabular-nums">
value={participant.damageTaken} <div className="font-bold text-base-content/70">
max={scales.maxTaken} 시야 {participant.visionScore}
fillClass="bg-base-content/35"
/>
</div> </div>
<div className="text-xs text-base-content/40"> <div className="mt-0.5">
시야 {participant.visionScore} · 와드 {participant.wardsPlaced}/ 와드 {participant.wardsPlaced}/{participant.wardsKilled} · 제어{" "}
{participant.wardsKilled} · 제어 {participant.controlWardsBought} {participant.controlWardsBought}
</div>
</div>
<div className="text-xs text-base-content/45 tabular-nums">
<div className="font-bold text-base-content/70">
CS {participant.totalCs}{" "}
<span className="font-normal text-base-content/40">
({participant.csPerMin}/m)
</span>
</div>
<div className="mt-0.5">
골드 {formatCompactNumber(participant.goldEarned)}
</div> </div>
</div> </div>
@@ -688,12 +755,10 @@ function MatchDetailPanel({
const teams = [...match.teams].sort((left, right) => left.side - right.side); const teams = [...match.teams].sort((left, right) => left.side - right.side);
const participants = teams.flatMap((team) => team.participants); const participants = teams.flatMap((team) => team.participants);
const scales: MatchDetailScales = { const scales: MatchDetailScales = {
maxGold: Math.max(1, ...participants.map((participant) => participant.goldEarned)),
maxDamage: Math.max( maxDamage: Math.max(
1, 1,
...participants.map((participant) => participant.damageDealtToChampions), ...participants.map((participant) => participant.damageDealtToChampions),
), ),
maxTaken: Math.max(1, ...participants.map((participant) => participant.damageTaken)),
}; };
if (participants.length === 0) { if (participants.length === 0) {
@@ -712,12 +777,19 @@ function MatchDetailPanel({
className="overflow-hidden border border-base-content/10 bg-base-100" className="overflow-hidden border border-base-content/10 bg-base-100"
> >
<TeamHeader team={team} /> <TeamHeader team={team} />
{(() => {
const teamKills = team.participants.reduce(
(sum, participant) => sum + participant.kills,
0,
);
return (
<div className="overflow-x-auto"> <div className="overflow-x-auto">
<div className="grid min-w-[920px] grid-cols-[260px_86px_132px_220px_164px] gap-3 border-b border-base-content/10 bg-base-200/40 px-3 py-2 text-xs font-black uppercase tracking-wider text-base-content/35"> <div className="grid min-w-[860px] grid-cols-[240px_92px_150px_104px_104px_196px] gap-3 border-b border-base-content/10 bg-base-200/40 px-3 py-2 text-xs font-bold uppercase tracking-wider text-base-content/35">
<div>소환사</div> <div>소환사</div>
<div className="text-center">KDA</div> <div className="text-center">KDA</div>
<div>피해량</div>
<div>와드</div>
<div>CS · 골드</div> <div>CS · 골드</div>
<div>피해량 · 와드</div>
<div>아이템</div> <div>아이템</div>
</div> </div>
{team.participants.map((participant) => ( {team.participants.map((participant) => (
@@ -728,15 +800,108 @@ function MatchDetailPanel({
ownerParticipantId={ownerParticipantId} ownerParticipantId={ownerParticipantId}
scales={scales} scales={scales}
teamSide={team.side} teamSide={team.side}
teamKills={teamKills}
/> />
))} ))}
</div> </div>
);
})()}
</section> </section>
))} ))}
</div> </div>
); );
} }
function resolveInternalDetailGame(
detail: ApiInternalMatchDetailResponse | undefined,
match: ApiRecentMatchView,
) {
if (!detail) return undefined;
return (
detail.games.find((game) => game.gameNumber === match.gameNumber) ??
detail.games.find((game) => game.riotMatchId === match.matchId) ??
detail.games[0]
);
}
function MatchDetailTabs({
match,
manifest,
ownerParticipantId,
}: {
match: ApiRecentMatchView;
manifest: DdragonManifest | null | undefined;
ownerParticipantId: string;
}) {
const [activeTab, setActiveTab] =
useState<InternalGameDetailTab>("scoreboard");
const hasInternalAnalysis = Boolean(match.internalMatchId);
const detailQuery = useInternalMatchDetail(
hasInternalAnalysis && activeTab !== "scoreboard"
? match.internalMatchId
: undefined,
DEFAULT_COMMUNITY_ID,
);
const selectedGame = resolveInternalDetailGame(detailQuery.data, match);
const scoreboard = (
<MatchDetailPanel
match={match}
manifest={manifest}
ownerParticipantId={ownerParticipantId}
/>
);
if (!hasInternalAnalysis) {
return scoreboard;
}
function renderTabContent() {
if (activeTab === "scoreboard") {
return scoreboard;
}
if (detailQuery.isLoading) {
return (
<div className="p-4 text-center text-xs font-bold text-base-content/35">
상세 분석 데이터를 불러오는 중...
</div>
);
}
if (detailQuery.error || !detailQuery.data || !selectedGame) {
return (
<div className="p-4 text-center text-xs font-bold text-base-content/35">
상세 분석 데이터를 불러오지 못했습니다.
</div>
);
}
return (
<div className="p-3 sm:p-4">
<InternalGameAnalysisPanel
activeTab={activeTab}
selectedGame={selectedGame}
detail={detailQuery.data}
manifest={manifest}
scoreboard={scoreboard}
/>
</div>
);
}
return (
<>
<div className="p-3 pb-0 sm:p-4 sm:pb-0">
<InternalGameDetailTabBar
activeTab={activeTab}
onChange={setActiveTab}
/>
</div>
{renderTabContent()}
</>
);
}
function RecentMatchCard({ function RecentMatchCard({
match, match,
manifest, manifest,
@@ -756,15 +921,15 @@ function RecentMatchCard({
<article <article
className={`border border-l-4 ${accent} border-base-content/10 bg-base-100`} className={`border border-l-4 ${accent} border-base-content/10 bg-base-100`}
> >
<div className="p-4 grid lg:grid-cols-[120px_1fr_120px_1.5fr_40px] gap-4 items-center"> <div className="p-3 grid lg:grid-cols-[120px_1fr_120px_1.5fr_40px] gap-3 items-center">
<div className="text-center lg:text-left"> <div className="text-center lg:text-left">
<div className={`text-xs font-black ${resultClass}`}> <div className={`text-sm font-bold ${resultClass}`}>
{match.remake ? "다시하기" : match.win ? "승리" : "패배"} {match.remake ? "다시하기" : match.win ? "승리" : "패배"}
</div> </div>
<div className="text-xs text-base-content/35 mt-1"> <div className="text-xs font-bold text-base-content/45 mt-1">
{match.queueLabel} {match.queueLabel}
</div> </div>
<div className="text-xs text-base-content/25"> <div className="mt-1 text-xs text-base-content/25">
{formatDate(match.gameCreation)} {formatDate(match.gameCreation)}
</div> </div>
<div className="text-xs text-base-content/25"> <div className="text-xs text-base-content/25">
@@ -772,12 +937,17 @@ function RecentMatchCard({
</div> </div>
</div> </div>
<div className="flex items-center gap-3 min-w-0"> <div className="flex items-center gap-2 min-w-0">
<ChampionIcon <ChampionIcon
championId={match.championId} championId={match.championId}
manifest={manifest} manifest={manifest}
size="lg" size="lg"
/> />
<LoadoutIcons
summonerSpells={match.summonerSpells}
perks={match.perks}
manifest={manifest}
/>
<div className="min-w-0"> <div className="min-w-0">
<div className="font-bold text-base-content truncate"> <div className="font-bold text-base-content truncate">
{championName} {championName}
@@ -787,18 +957,11 @@ function RecentMatchCard({
{(LANE_LABELS[match.teamPosition] ?? match.teamPosition) || {(LANE_LABELS[match.teamPosition] ?? match.teamPosition) ||
"포지션 없음"} "포지션 없음"}
</div> </div>
<div className="mt-1">
<LoadoutIcons
summonerSpells={match.summonerSpells}
perks={match.perks}
manifest={manifest}
/>
</div>
</div> </div>
</div> </div>
<div className="text-center"> <div className="text-center">
<div className="text-lg font-black tabular-nums"> <div className="text-lg font-bold tabular-nums">
<span>{match.kills}</span> <span>{match.kills}</span>
<span className="text-base-content/25"> / </span> <span className="text-base-content/25"> / </span>
<span className="text-red-400">{match.deaths}</span> <span className="text-red-400">{match.deaths}</span>
@@ -808,14 +971,14 @@ function RecentMatchCard({
<div <div
className={`text-xs font-bold tabular-nums ${kdaClass(match.kda)}`} className={`text-xs font-bold tabular-nums ${kdaClass(match.kda)}`}
> >
{match.deaths === 0 ? "Perfect" : `${match.kda} 평점`} {match.deaths === 0 ? "Perfect" : `${match.kda} KDA`}
</div> </div>
<div className="mt-1 text-xs text-base-content/35"> <div className="mt-1 text-xs text-base-content/35">
킬 관여 {match.killParticipation}% 킬 관여 {match.killParticipation}%
</div> </div>
</div> </div>
<div className="grid sm:grid-cols-[100px_1fr] gap-4 items-center"> <div className="grid sm:grid-cols-[100px_1fr] gap-3 items-center min-w-0">
<div className="space-y-1 text-xs text-base-content/45"> <div className="space-y-1 text-xs text-base-content/45">
<div> <div>
CS{" "} CS{" "}
@@ -838,14 +1001,18 @@ function RecentMatchCard({
</span> </span>
</div> </div>
</div> </div>
<div className="flex items-start gap-3"> <div className="flex items-start gap-3 min-w-0">
<ItemGrid <ItemGrid
items={match.items} items={match.items}
trinket={match.trinket} trinket={match.trinket}
manifest={manifest} manifest={manifest}
itemKey={match.matchId} itemKey={match.matchId}
/> />
<TeamMini match={match} manifest={manifest} /> <TeamMini
match={match}
manifest={manifest}
ownerParticipantId={ownerParticipantId}
/>
</div> </div>
</div> </div>
@@ -870,7 +1037,7 @@ function RecentMatchCard({
</div> </div>
{expanded && ( {expanded && (
<div className="border-t border-base-content/10 bg-base-200/30"> <div className="border-t border-base-content/10 bg-base-200/30">
<MatchDetailPanel <MatchDetailTabs
match={match} match={match}
manifest={manifest} manifest={manifest}
ownerParticipantId={ownerParticipantId} ownerParticipantId={ownerParticipantId}
@@ -881,6 +1048,97 @@ function RecentMatchCard({
); );
} }
function SkeletonBlock({ className = "" }: { className?: string }) {
return <div className={`animate-pulse bg-base-content/10 ${className}`} />;
}
function MatchCardSkeleton() {
return (
<article className="border border-l-4 border-l-base-content/10 border-base-content/10 bg-base-100">
<div className="grid items-center gap-3 p-3 lg:grid-cols-[120px_1fr_120px_1.5fr_40px]">
<div className="space-y-1.5">
<SkeletonBlock className="h-3.5 w-12" />
<SkeletonBlock className="h-2.5 w-16" />
<SkeletonBlock className="h-2.5 w-20" />
</div>
<div className="flex items-center gap-2">
<SkeletonBlock className="h-12 w-12" />
<div className="grid grid-cols-2 gap-0.5">
{Array.from({ length: 4 }).map((_, index) => (
<SkeletonBlock key={index} className="h-5 w-5" />
))}
</div>
<div className="space-y-1.5">
<SkeletonBlock className="h-3.5 w-24" />
<SkeletonBlock className="h-2.5 w-16" />
</div>
</div>
<div className="flex flex-col items-center gap-1.5">
<SkeletonBlock className="h-4 w-20" />
<SkeletonBlock className="h-2.5 w-12" />
</div>
<div className="flex items-start gap-3">
<div className="grid grid-cols-3 gap-1">
{Array.from({ length: 6 }).map((_, index) => (
<SkeletonBlock key={index} className="h-6 w-6" />
))}
</div>
<SkeletonBlock className="h-6 w-6" />
<div className="grid flex-1 grid-cols-2 gap-x-3 gap-y-1">
{Array.from({ length: 10 }).map((_, index) => (
<SkeletonBlock key={index} className="h-2.5 w-full" />
))}
</div>
</div>
<div className="hidden justify-end lg:flex">
<SkeletonBlock className="h-8 w-8" />
</div>
</div>
</article>
);
}
function MatchListSkeleton({ count = 5 }: { count?: number }) {
return (
<div className="space-y-2">
{Array.from({ length: count }).map((_, index) => (
<MatchCardSkeleton key={index} />
))}
</div>
);
}
function HistoryPageSkeleton() {
return (
<main className="mx-auto max-w-6xl px-4 py-6 sm:px-6">
<SkeletonBlock className="mb-6 h-3 w-16" />
<section className="mb-6 border border-base-content/10 bg-base-100 p-6">
<div className="flex flex-col gap-4 sm:flex-row sm:items-center">
<SkeletonBlock className="h-16 w-16" />
<div className="flex-1 space-y-2">
<SkeletonBlock className="h-6 w-40" />
<SkeletonBlock className="h-3 w-64" />
</div>
<SkeletonBlock className="h-9 w-32" />
</div>
</section>
<div className="mb-6 grid gap-3 sm:grid-cols-2 lg:grid-cols-5">
{Array.from({ length: 5 }).map((_, index) => (
<div
key={index}
className="space-y-2 border border-base-content/8 bg-base-100 p-4"
>
<SkeletonBlock className="h-2.5 w-12" />
<SkeletonBlock className="h-7 w-16" />
<SkeletonBlock className="h-2.5 w-20" />
</div>
))}
</div>
<MatchListSkeleton />
</main>
);
}
export default function UserHistoryPage() { export default function UserHistoryPage() {
const { userId } = useParams(); const { userId } = useParams();
const location = useLocation(); const location = useLocation();
@@ -1094,13 +1352,7 @@ export default function UserHistoryPage() {
} }
if (profileQuery.isLoading) { if (profileQuery.isLoading) {
return ( return <HistoryPageSkeleton />;
<main className="max-w-6xl mx-auto px-4 py-20 text-center">
<span className="text-sm text-base-content/40">
소환사 전적을 불러오는 중...
</span>
</main>
);
} }
if (profileQuery.error || !profile) { if (profileQuery.error || !profile) {
@@ -1114,16 +1366,21 @@ export default function UserHistoryPage() {
); );
} }
const socketStatus = socketStatusMeta(refreshSocket.connectionStatus);
const refreshNoticeIsError =
Boolean(refreshSocket.error) ||
Boolean(refreshNotice?.startsWith("갱신 실패"));
return ( return (
<main className="max-w-6xl mx-auto px-4 sm:px-6 py-6"> <main className="max-w-6xl mx-auto px-4 sm:px-6 py-6">
<Link <Link
to={backTo} to={backTo}
className="inline-flex items-center gap-1 text-xs text-base-content/40 hover:text-base-content transition-colors mb-5" className="inline-flex items-center gap-1 text-xs text-base-content/40 hover:text-base-content transition-colors mb-6"
> >
← 이전으로 ← 이전으로
</Link> </Link>
<section className="border border-base-content/10 bg-base-100 p-5 mb-5"> <section className="border border-base-content/10 bg-base-100 p-6 mb-6">
<div className="flex flex-col sm:flex-row sm:items-center gap-4"> <div className="flex flex-col sm:flex-row sm:items-center gap-4">
<div className="w-16 h-16 bg-base-content/10 overflow-hidden shrink-0"> <div className="w-16 h-16 bg-base-content/10 overflow-hidden shrink-0">
<img <img
@@ -1134,7 +1391,7 @@ export default function UserHistoryPage() {
</div> </div>
<div className="flex-1 min-w-0"> <div className="flex-1 min-w-0">
<div className="flex flex-wrap items-center gap-2"> <div className="flex flex-wrap items-center gap-2">
<h1 className="text-2xl font-black text-base-content"> <h1 className="text-2xl font-bold text-base-content">
{profile.gameName} {profile.gameName}
</h1> </h1>
<span className="text-sm text-base-content/35"> <span className="text-sm text-base-content/35">
@@ -1148,26 +1405,15 @@ export default function UserHistoryPage() {
<span>최근 저장: {formatLastFetched(profile.lastFetchedAt)}</span> <span>최근 저장: {formatLastFetched(profile.lastFetchedAt)}</span>
</div> </div>
</div> </div>
<div className="border border-dashed border-base-content/10 px-3 py-2 text-xs text-base-content/35 sm:text-right space-y-2"> <div className="flex flex-col gap-2 text-xs sm:items-end">
<div> <p className="text-base-content/35 sm:text-right">
{isInternalQueue ? ( {isInternalQueue
<> ? "내전 기록이 안 보이면 다시 불러오세요."
{/* 내전 탭은 토너먼트 결과 DB를 조회합니다. */} : "버튼을 누르면 최신 전적으로 갱신됩니다."}
{/* Riot API 갱신 없이 수집된 내전 결과를 다시 불러옵니다. */} </p>
내전 기록이 확인되지 않을 경우 버튼을 눌러 갱신 (테스트)
</>
) : (
<>
{/* 이 페이지는 저장된 경기 DB만 조회합니다. */}
<br />
{/* Riot API 갱신은 버튼 클릭 시 큐에서 처리합니다. */}
아래 버튼을 누르면 기록이 갱신됩니다.
</>
)}
</div>
<button <button
type="button" type="button"
className="btn btn-primary btn-xs px-3" className="bg-primary px-3 py-2 text-xs font-bold text-primary-content transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:opacity-40"
disabled={refreshMutation.isPending || !userId} disabled={refreshMutation.isPending || !userId}
onClick={handleRefresh} onClick={handleRefresh}
> >
@@ -1178,14 +1424,21 @@ export default function UserHistoryPage() {
: "정보 갱신"} : "정보 갱신"}
</button> </button>
{!isInternalQueue && ( {!isInternalQueue && (
<div className="text-xs text-base-content/25"> <div className="flex items-center gap-1.5 text-[11px] text-base-content/30 sm:justify-end">
갱신 소켓: {refreshSocket.connectionStatus} <span className={`h-1.5 w-1.5 ${socketStatus.tone}`} />
{socketStatus.label}
</div> </div>
)} )}
</div> </div>
</div> </div>
{(refreshNotice || refreshSocket.error) && ( {(refreshNotice || refreshSocket.error) && (
<div className="mt-4 border border-primary/15 bg-primary/5 px-3 py-2 text-xs text-base-content/55"> <div
className={`mt-4 border px-3 py-2 text-xs ${
refreshNoticeIsError
? "border-red-400/30 bg-red-400/5 text-red-300"
: "border-primary/15 bg-primary/5 text-base-content/55"
}`}
>
{refreshNotice ?? refreshSocket.error} {refreshNotice ?? refreshSocket.error}
</div> </div>
)} )}
@@ -1194,14 +1447,14 @@ export default function UserHistoryPage() {
{profile.tierHistory.length > 0 && ( {profile.tierHistory.length > 0 && (
<Suspense <Suspense
fallback={ fallback={
<div className="mb-5 h-[180px] border border-base-content/10 bg-base-100" /> <div className="mb-6 h-[180px] border border-base-content/10 bg-base-100" />
} }
> >
<TierHistoryChart entries={profile.tierHistory} /> <TierHistoryChart entries={profile.tierHistory} />
</Suspense> </Suspense>
)} )}
<section className="border border-base-content/10 bg-base-100 mb-5"> <section className="border border-base-content/10 bg-base-100 mb-6">
<div className="flex flex-wrap border-b border-base-content/8"> <div className="flex flex-wrap border-b border-base-content/8">
{QUEUE_GROUP_TABS.map((tab) => ( {QUEUE_GROUP_TABS.map((tab) => (
<FilterButton <FilterButton
@@ -1319,9 +1572,7 @@ export default function UserHistoryPage() {
</button> </button>
))} ))}
{(summary?.topChampions ?? []).length === 0 && ( {(summary?.topChampions ?? []).length === 0 && (
<span className="text-xs text-base-content/25"> <span className="text-xs text-base-content/25">기록 없음</span>
기록 없음
</span>
)} )}
</div> </div>
</div> </div>
@@ -1378,9 +1629,7 @@ export default function UserHistoryPage() {
</div> </div>
{matchesLoading ? ( {matchesLoading ? (
<div className="border border-base-content/10 bg-base-100 px-4 py-10 text-center text-sm text-base-content/35"> <MatchListSkeleton />
최근 경기를 불러오는 중...
</div>
) : matches.length === 0 ? ( ) : matches.length === 0 ? (
<div className="border border-base-content/10 bg-base-100 px-4 py-10 text-center text-sm text-base-content/35"> <div className="border border-base-content/10 bg-base-100 px-4 py-10 text-center text-sm text-base-content/35">
조건에 맞는 최근 경기 기록이 없습니다. 조건에 맞는 최근 경기 기록이 없습니다.
@@ -1392,7 +1641,9 @@ export default function UserHistoryPage() {
key={match.matchId} key={match.matchId}
match={match} match={match}
manifest={ddragon} manifest={ddragon}
ownerParticipantId={isInternalQueue ? profile.userId : profile.puuid} ownerParticipantId={
isInternalQueue ? profile.userId : profile.puuid
}
/> />
))} ))}
</div> </div>