From 4906f665fdac6caec1e8fc9618aa86c4eff691c5 Mon Sep 17 00:00:00 2001 From: dahyeon Date: Fri, 26 Jun 2026 23:10:42 -0700 Subject: [PATCH] feat: polish match history UI --- .../components/InternalGameAnalysisTabs.tsx | 923 ++++++++++++++++++ apps/web/src/pages/MatchGameDetailPage.tsx | 913 +---------------- apps/web/src/pages/MatchTeamProgressPage.tsx | 16 +- apps/web/src/pages/UserHistoryPage.tsx | 625 ++++++++---- 4 files changed, 1403 insertions(+), 1074 deletions(-) create mode 100644 apps/web/src/components/InternalGameAnalysisTabs.tsx diff --git a/apps/web/src/components/InternalGameAnalysisTabs.tsx b/apps/web/src/components/InternalGameAnalysisTabs.tsx new file mode 100644 index 00000000..7a75d6c0 --- /dev/null +++ b/apps/web/src/components/InternalGameAnalysisTabs.tsx @@ -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 = { + 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 ( +
+ + {icon ? ( + {name} + ) : null} + {participant.championLevel > 0 && ( + + {participant.championLevel} + + )} + +
+ + {name} + + + {LANE_LABELS[participant.teamPosition] ?? + participant.teamPosition ?? + "-"} + +
+
+ ); +} + +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 ( + + {icon ? ( + {name} + ) : null} + {participant.championLevel > 0 ? ( + + {participant.championLevel} + + ) : null} + + ); +} + +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 ( +
+ 빌드 데이터가 없습니다 +
+ ); + } + + return ( +
+ +
+ +
+ + +
+
+
+ ); +} + +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 ( +
+ {orderedTeams.map((team) => { + const tone = sideTone(team.side); + return ( +
+
+
+ {team.side === "blue" ? "블루" : "레드"} +
+
+ {getTeamName(detail, team.teamIndex)} +
+
+
+ {team.participants.map((participant) => ( + onSelect(participantBuildKey(participant))} + /> + ))} +
+
+ ); + })} +
+ ); +} + +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 ( + + ); +} + +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 ( +
+
+
+
+ 룬 +
+
+ {participant.summonerName} +
+
+ +
+
+ + +
+ +
+ ); +} + +function RuneTreeColumn({ + label, + isPrimary, + runeStyle, + selection, + selectedIds, + manifest, +}: { + label: string; + isPrimary: boolean; + runeStyle: RuneStyleEntry | null; + selection: ReturnType; + selectedIds: Set; + manifest: DdragonManifestData; +}) { + if (!runeStyle) { + return ( +
+
+ {label} +
+
+ 룬 데이터 없음 +
+
+ ); + } + + const styleIcon = runeStyleIconUrl(manifest, runeStyle.id); + const selectionIds = new Set(selection?.perkIds ?? []); + + return ( +
+
+ + {styleIcon ? ( + + ) : null} + +
+
+ {label} +
+
+ {runeStyle.name} +
+
+
+
+ {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 ( +
+ {slot.runes.map((rune) => { + const selected = + selectedIds.has(rune.id) || selectionIds.has(rune.id); + const icon = runeIconUrl(manifest, rune.id); + return ( + + {icon ? ( + + ) : null} + + ); + })} +
+ ); + })} +
+
+ ); +} + +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 ( +
+ + 스탯 파편 + + {shards.map((shard) => ( + + {shard.label} + + {STAT_PERK_LABELS[shard.value ?? 0] ?? shard.value} + + + ))} +
+ ); +} + +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 ( +
+
+ 아이템 빌드 +
+ {buildEvents.length > 0 ? ( +
+ {buildEvents.map((event, index) => ( +
+ + {index < buildEvents.length - 1 ? ( + + > + + ) : null} +
+ ))} +
+ ) : fallbackItems.length > 0 ? ( +
+ {fallbackItems.map((item, index) => ( + + ))} +
+ ) : ( +
+ 아이템 빌드 데이터 없음 +
+ )} +
+ ); +} + +function ItemBuildNode({ + itemId, + timestamp, + manifest, +}: { + itemId: number; + timestamp: number; + manifest: DdragonManifestData; +}) { + return ( +
+ + + {formatDuration(timestamp)} + +
+ ); +} + +function SkillBuildPanel({ + participant, +}: { + participant: InternalGameParticipant; +}) { + const skillEvents = participant.skillBuild ?? []; + const skillByLevel = new Map( + skillEvents.map((event) => [event.level, event]), + ); + + return ( +
+
+
+ 스킬 빌드 +
+
+ Lv. {skillEvents.length || participant.championLevel || "-"} +
+
+ {skillEvents.length > 0 ? ( +
+
+ {SKILL_ROWS.map((row) => ( +
+
+ {row.label} +
+ {Array.from({ length: 18 }, (_, index) => index + 1).map( + (level) => { + const event = skillByLevel.get(level); + const active = event?.skillSlot === row.slot; + return ( +
+ {active ? level : ""} +
+ ); + }, + )} +
+ ))} +
+
+ ) : ( +
+ 스킬 빌드 데이터 없음 +
+ )} +
+ ); +} + +function MatchupMetricRow({ + label, + blueLead, + redLead, + blueText, + redText, +}: { + label: string; + blueLead: boolean; + redLead: boolean; + blueText: string; + redText: string; +}) { + return ( +
+ + {blueText} + + + {label} + + + {redText} + +
+ ); +} + +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 ( +
+
+
+
+
+ {blue.summonerName} +
+
+ {championName(blue)} +
+
+ +
+ + {laneLabel} + +
+ +
+
+ {red.summonerName} +
+
+ {championName(red)} +
+
+
+
+
+ {metrics.map((metric) => ( + metric.redValue} + redLead={metric.redValue > metric.blueValue} + blueText={metric.blueText} + redText={metric.redText} + /> + ))} +
+
+ ); +} + +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 ( +
+ 라인전 비교 데이터가 없습니다 +
+ ); + } + + 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 ( +
+
+ + {blueTeamName} + + VS + {redTeamName} +
+
+ {blueSorted.map((blue, index) => { + const red = redSorted[index]; + if (!red) return null; + return ( + + ); + })} +
+
+ ); +} + +export function InternalGameDetailTabBar({ + activeTab, + onChange, +}: { + activeTab: InternalGameDetailTab; + onChange: (tab: InternalGameDetailTab) => void; +}) { + return ( +
+ {DETAIL_TABS.map((tab) => ( + + ))} +
+ ); +} + +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 ( + + ); + } + + return ( + + ); +} diff --git a/apps/web/src/pages/MatchGameDetailPage.tsx b/apps/web/src/pages/MatchGameDetailPage.tsx index e626ac7a..b40dd4f7 100644 --- a/apps/web/src/pages/MatchGameDetailPage.tsx +++ b/apps/web/src/pages/MatchGameDetailPage.tsx @@ -17,7 +17,6 @@ import { DEFAULT_COMMUNITY_ID } from "../config"; import { championDisplayName, championIconUrl, - runeIconUrl, runeKeystoneIconUrl, runeStyleIconUrl, summonerSpellIconUrl, @@ -32,14 +31,16 @@ import { internalMatchGamePath, } from "../lib/internal-match-routes"; import { LANE_LABELS } from "../lib/riot-history"; +import { + InternalGameAnalysisPanel, + InternalGameDetailTabBar, + type InternalGameDetailTab, +} from "../components/InternalGameAnalysisTabs"; import { ItemIcon } from "../components/ItemTooltip"; type MatchGameDetail = ApiInternalMatchDetailResponse["games"][number]; type MatchGameTeam = MatchGameDetail["teams"][number]; type MatchGameParticipant = MatchGameTeam["participants"][number]; -type DdragonManifestData = ReturnType["data"]; -type RuneStyleEntry = NonNullable["runesReforged"][number]; -type DetailTab = "scoreboard" | "matchup" | "build"; type TimelineMetric = "gold" | "xp"; type MatchGameBackTarget = { to: string; @@ -50,12 +51,6 @@ type MatchGameNavigationState = { backLabel: string; }; -const DETAIL_TABS: Array<{ id: DetailTab; label: string }> = [ - { id: "scoreboard", label: "스코어보드" }, - { id: "matchup", label: "라인전" }, - { id: "build", label: "룬 / 빌드" }, -]; - const TIMELINE_METRICS: Array<{ id: TimelineMetric; label: string }> = [ { id: "gold", label: "골드" }, { id: "xp", label: "경험치" }, @@ -101,28 +96,6 @@ function createNavigationState( }; } -const SKILL_ROWS: Array<{ - slot: 1 | 2 | 3 | 4; - label: string; - className: string; -}> = [ - { slot: 1, label: "Q", className: "bg-blue-500 text-white" }, - { slot: 2, label: "W", className: "bg-cyan-500 text-white" }, - { slot: 3, label: "E", className: "bg-amber-500 text-black" }, - { slot: 4, label: "R", className: "bg-red-500 text-white" }, -]; - -const STAT_PERK_LABELS: Record = { - 5001: "체력", - 5002: "방어", - 5003: "마저", - 5005: "공속", - 5007: "가속", - 5008: "적응", - 5010: "이속", - 5011: "체력", -}; - function formatDateTime(value: string | number) { return new Intl.DateTimeFormat("ko-KR", { month: "long", @@ -236,35 +209,6 @@ function resolveSelectedSeries( ); } -function participantBuildKey(participant: MatchGameParticipant) { - return `${participant.side}-${participant.userId ?? participant.summonerName}-${participant.championId}`; -} - -function findRuneStyle( - manifest: DdragonManifestData, - styleId: number | undefined, -) { - return manifest?.runesReforged.find((style) => style.id === styleId) ?? null; -} - -function selectedRuneIds(participant: MatchGameParticipant) { - const explicit = participant.perks.selectedPerkIds ?? []; - const fromStyles = - participant.perks.styles?.flatMap((style) => style.perkIds) ?? []; - return new Set([ - ...explicit, - ...fromStyles, - ...(participant.perks.keystone ? [participant.perks.keystone] : []), - ]); -} - -function runeStyleSelection( - participant: MatchGameParticipant, - styleId: number | undefined, -) { - return participant.perks.styles?.find((style) => style.styleId === styleId); -} - function WinBadge({ win }: { win: boolean }) { return win ? ( @@ -277,41 +221,33 @@ function WinBadge({ win }: { win: boolean }) { ); } -function ChampionCell({ +function ChampionAvatar({ participant, manifest, + size = "h-9 w-9", }: { participant: MatchGameParticipant; manifest: ReturnType["data"]; + size?: string; }) { const icon = championIconUrl(manifest, participant.championId); const name = championDisplayName(manifest, participant.championId) ?? String(participant.championId); - return ( -
- - {icon ? ( - {name} - ) : null} - {participant.championLevel > 0 && ( - - {participant.championLevel} - - )} - -
- - {name} + + {icon ? ( + {name} + ) : null} + {participant.championLevel > 0 ? ( + + {participant.championLevel} - - {LANE_LABELS[participant.teamPosition] ?? - participant.teamPosition ?? - "-"} - -
-
+ ) : null} +
); } @@ -1151,758 +1087,6 @@ function TeamTable({ ); } -function DetailTabBar({ - activeTab, - onChange, -}: { - activeTab: DetailTab; - onChange: (tab: DetailTab) => void; -}) { - return ( -
- {DETAIL_TABS.map((tab) => ( - - ))} -
- ); -} - -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 ( -
- 빌드 데이터가 없습니다 -
- ); - } - - return ( -
- -
- -
- - -
-
-
- ); -} - -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 ( -
- {orderedTeams.map((team) => { - const tone = sideTone(team.side); - return ( -
-
-
- {sideLabel(team.side)} Side -
-
- {getTeamName(detail, team.teamIndex)} -
-
-
- {team.participants.map((participant) => ( - onSelect(participantBuildKey(participant))} - /> - ))} -
-
- ); - })} -
- ); -} - -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 ( - - ); -} - -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 ( -
-
-
-
Runes
-
- {participant.summonerName} -
-
- -
-
- - -
- -
- ); -} - -function RuneTreeColumn({ - label, - runeStyle, - selection, - selectedIds, - manifest, -}: { - label: string; - runeStyle: RuneStyleEntry | null; - selection: ReturnType; - selectedIds: Set; - manifest: DdragonManifestData; -}) { - if (!runeStyle) { - return ( -
-
{label}
-
- 룬 데이터 없음 -
-
- ); - } - - const styleIcon = runeStyleIconUrl(manifest, runeStyle.id); - const selectionIds = new Set(selection?.perkIds ?? []); - - return ( -
-
- - {styleIcon ? ( - - ) : null} - -
-
{label}
-
- {runeStyle.name} -
-
-
-
- {runeStyle.slots.map((slot, slotIndex) => ( -
- {slot.runes.map((rune) => { - const selected = - selectedIds.has(rune.id) || selectionIds.has(rune.id); - const icon = runeIconUrl(manifest, rune.id); - return ( - - {icon ? ( - - ) : null} - - ); - })} -
- ))} -
-
- ); -} - -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 ( -
-
스탯 파편
-
- {shards.map((shard) => ( - - {shard.label} - {STAT_PERK_LABELS[shard.value ?? 0] ?? shard.value} - - ))} -
-
- ); -} - -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 ( -
-
Item Build
- {buildEvents.length > 0 ? ( -
- {buildEvents.map((event, index) => ( -
- - {index < buildEvents.length - 1 ? ( - - > - - ) : null} -
- ))} -
- ) : fallbackItems.length > 0 ? ( -
- {fallbackItems.map((itemId, index) => { - const icon = itemIconUrl(manifest, itemId); - return ( - - {icon ? ( - - ) : null} - - ); - })} -
- ) : ( -
- 아이템 빌드 데이터 없음 -
- )} -
- ); -} - -function ItemBuildNode({ - itemId, - timestamp, - manifest, -}: { - itemId: number; - timestamp: number; - manifest: DdragonManifestData; -}) { - const icon = itemIconUrl(manifest, itemId); - - return ( -
- - {icon ? ( - - ) : null} - - - {formatDuration(timestamp)} - -
- ); -} - -function SkillBuildPanel({ - participant, -}: { - participant: MatchGameParticipant; -}) { - const skillEvents = participant.skillBuild ?? []; - const skillByLevel = new Map( - skillEvents.map((event) => [event.level, event]), - ); - - return ( -
-
-
Skill Build
-
- Lv. {skillEvents.length || participant.championLevel || "-"} -
-
- {skillEvents.length > 0 ? ( -
-
- {SKILL_ROWS.map((row) => ( -
-
- {row.label} -
- {Array.from({ length: 18 }, (_, index) => index + 1).map( - (level) => { - const event = skillByLevel.get(level); - const active = event?.skillSlot === row.slot; - return ( -
- {active ? level : ""} -
- ); - }, - )} -
- ))} -
-
- ) : ( -
- 스킬 빌드 데이터 없음 -
- )} -
- ); -} - -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["data"]; - size?: string; -}) { - const icon = championIconUrl(manifest, participant.championId); - const name = - championDisplayName(manifest, participant.championId) ?? - String(participant.championId); - return ( - - {icon ? ( - {name} - ) : null} - {participant.championLevel > 0 ? ( - - {participant.championLevel} - - ) : null} - - ); -} - -function MatchupMetricRow({ - label, - blueLead, - redLead, - blueText, - redText, - bluePct, -}: { - label: string; - blueLead: boolean; - redLead: boolean; - blueText: string; - redText: string; - bluePct: number; -}) { - return ( -
-
- - {blueText} - - - {label} - - - {redText} - -
-
-
-
-
-
- ); -} - -function LaneMatchupCard({ - blue, - red, - detail, - manifest, -}: { - blue: MatchGameParticipant; - red: MatchGameParticipant; - detail: ApiInternalMatchDetailResponse; - manifest: ReturnType["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 ( -
-
-
-
-
- {blue.summonerName} -
-
- {championName(blue)} -
-
- -
- - {laneLabel} - -
- -
-
- {red.summonerName} -
-
- {championName(red)} -
-
-
-
-
- {metrics.map((metric) => { - const total = metric.blueValue + metric.redValue; - const bluePct = total > 0 ? (metric.blueValue / total) * 100 : 50; - return ( - metric.redValue} - redLead={metric.redValue > metric.blueValue} - blueText={metric.blueText} - redText={metric.redText} - bluePct={bluePct} - /> - ); - })} -
-
- ); -} - -function LaneMatchupPanel({ - selectedGame, - detail, - manifest, -}: { - selectedGame: MatchGameDetail; - detail: ApiInternalMatchDetailResponse; - manifest: ReturnType["data"]; -}) { - const blueTeam = selectedGame.teams.find((team) => team.side === "blue"); - const redTeam = selectedGame.teams.find((team) => team.side === "red"); - - if (!blueTeam || !redTeam) { - return ( -
- 라인전 비교 데이터가 없습니다 -
- ); - } - - 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 ( -
-
- - {blueTeamName} - - VS - {redTeamName} -
-
- {blueSorted.map((blue, index) => { - const red = redSorted[index]; - if (!red) return null; - return ( - - ); - })} -
-
- ); -} - function ScoreboardTables({ selectedGame, detail, @@ -1930,46 +1114,6 @@ function ScoreboardTables({ ); } -function GameAnalysisPanel({ - activeTab, - selectedGame, - detail, - manifest, -}: { - activeTab: DetailTab; - selectedGame: MatchGameDetail; - detail: ApiInternalMatchDetailResponse; - manifest: ReturnType["data"]; -}) { - if (activeTab === "scoreboard") { - return ( - - ); - } - - if (activeTab === "build") { - return ( - - ); - } - - return ( - - ); -} - function GameTabs({ detail, communityId, @@ -2117,7 +1261,8 @@ function MatchScoreHero({ export default function MatchGameDetailPage() { const { cid, matchId, id, gameNumber } = useParams(); const location = useLocation(); - const [activeTab, setActiveTab] = useState("scoreboard"); + const [activeTab, setActiveTab] = + useState("scoreboard"); const communityId = cid ?? DEFAULT_COMMUNITY_ID; const resolvedMatchId = matchId ?? id; const requestedGameNumber = Number(gameNumber); @@ -2184,12 +1329,22 @@ export default function MatchGameDetailPage() { />
- - + + } />
diff --git a/apps/web/src/pages/MatchTeamProgressPage.tsx b/apps/web/src/pages/MatchTeamProgressPage.tsx index a7cff0a1..07032688 100644 --- a/apps/web/src/pages/MatchTeamProgressPage.tsx +++ b/apps/web/src/pages/MatchTeamProgressPage.tsx @@ -33,8 +33,8 @@ const GAME_MODE_LABEL: Record = { function resultBadgeClass(won: boolean) { return won - ? "border-blue-500/20 bg-blue-500/10 text-blue-400" - : "border-red-500/20 bg-red-500/10 text-red-400"; + ? "border-info/20 bg-info/10 text-info" + : "border-error/20 bg-error/10 text-error"; } function captainName( @@ -132,7 +132,7 @@ function ParticipantLine({ {name} {isCaptain && ( - + 팀장 )} @@ -436,7 +436,7 @@ function TeamGameCardsSection({
{replaceError && ( -
+
{replaceError}
)} @@ -534,7 +534,7 @@ export default function MatchTeamProgressPage() { if (!DEFAULT_COMMUNITY_ID) { return ( -
+
`VITE_DEFAULT_COMMUNITY_ID` 설정이 필요합니다.
); @@ -704,9 +704,9 @@ export default function MatchTeamProgressPage() { aria-modal="true" aria-labelledby="team-tournament-code-replace-title" > -
+
- +
@@ -746,7 +746,7 @@ export default function MatchTeamProgressPage() { handleConfirmReplaceTournamentCode(); } }} - className="mt-2 h-10 w-full border border-base-content/15 bg-base-100 px-3 text-sm text-base-content outline-none transition-colors focus:border-amber-400/60" + className="mt-2 h-10 w-full border border-base-content/15 bg-base-100 px-3 text-sm text-base-content outline-none transition-colors focus:border-warning/60" placeholder="예" /> diff --git a/apps/web/src/pages/UserHistoryPage.tsx b/apps/web/src/pages/UserHistoryPage.tsx index 6f44a71c..5192a529 100644 --- a/apps/web/src/pages/UserHistoryPage.tsx +++ b/apps/web/src/pages/UserHistoryPage.tsx @@ -5,6 +5,7 @@ import { Link, useLocation, useParams, useSearchParams } from "react-router"; import { useChampionStats, useDdragonManifest, + useInternalMatchDetail, useRecentMatches, useRecentSummary, useRefreshUserHistory, @@ -16,6 +17,7 @@ import { useRiotRefreshSocket } from "../api/useRiotRefreshSocket"; import type { ApiChampionStatsRow, ApiEnqueueRefreshResult, + ApiInternalMatchDetailResponse, ApiRiotRefreshEvent, ApiRecentMatchTeam, ApiRecentMatchTeamParticipant, @@ -42,6 +44,11 @@ import { RANK_FILTER_TABS, } from "../lib/riot-history"; import { ResponsiveTierLabel } from "../components/RankBadge"; +import { + InternalGameAnalysisPanel, + InternalGameDetailTabBar, + type InternalGameDetailTab, +} from "../components/InternalGameAnalysisTabs"; import { ItemIcon } from "../components/ItemTooltip"; // recharts가 무거워 메인 번들에서 분리한다 (전적 페이지에서만 로드). const TierHistoryChart = lazy(() => import("../components/TierHistoryChart")); @@ -118,6 +125,21 @@ function formatRefreshError(error: unknown) { 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) { if (value >= 55) return "text-blue-400"; if (value >= 50) return "text-amber-400"; @@ -158,24 +180,34 @@ function ChampionIcon({ championId, manifest, size = "md", + className = "", }: { championId: number; manifest: DdragonManifest | null | undefined; - size?: "sm" | "md" | "lg"; + size?: "xs" | "sm" | "md" | "lg"; + className?: string; }) { const iconUrl = championIconUrl(manifest, championId); const displayName = championDisplayName(manifest, championId) ?? String(championId); 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 ( -
+
{iconUrl ? ( {displayName} ) : null} @@ -197,12 +229,10 @@ function SummaryCard({
{label}
-
+
{value}
- {sub && ( -
{sub}
- )} + {sub &&
{sub}
}
); } @@ -232,17 +262,17 @@ function ChampionStatsTable({ - - - - - - - - - - - + + + + + + + + + + + @@ -256,7 +286,7 @@ function ChampionStatsTable({ key={row.championId} className="border-b border-base-content/5 last:border-b-0 hover:bg-base-content/[0.02]" > - - - - - - - - -
챔피언승률게임승/패KDA킬데스어시스트멀티킬CS필터챔피언승률게임승/패KDA킬데스어시스트멀티킬CS필터
+
{row.winRate}% + {row.games} + {row.wins} /{" "} {row.losses} {row.kda} + {row.totalKills} + {row.totalDeaths} + {row.totalAssists} + {row.doubleKills}/{row.tripleKills}/{row.quadraKills}/ {row.pentaKills} + {row.avgCs} · {row.avgCsPerMin}/m + {!isInternalQueue && ( -
- 갱신 소켓: {refreshSocket.connectionStatus} +
+ + {socketStatus.label}
)}
{(refreshNotice || refreshSocket.error) && ( -
+
{refreshNotice ?? refreshSocket.error}
)} @@ -1194,14 +1447,14 @@ export default function UserHistoryPage() { {profile.tierHistory.length > 0 && ( +
} > )} -
+
{QUEUE_GROUP_TABS.map((tab) => ( ))} {(summary?.topChampions ?? []).length === 0 && ( - - 기록 없음 - + 기록 없음 )}
@@ -1378,9 +1629,7 @@ export default function UserHistoryPage() {
{matchesLoading ? ( -
- 최근 경기를 불러오는 중... -
+ ) : matches.length === 0 ? (
조건에 맞는 최근 경기 기록이 없습니다. @@ -1392,7 +1641,9 @@ export default function UserHistoryPage() { key={match.matchId} match={match} manifest={ddragon} - ownerParticipantId={isInternalQueue ? profile.userId : profile.puuid} + ownerParticipantId={ + isInternalQueue ? profile.userId : profile.puuid + } /> ))}