feat: add spell and rune tooltips

This commit is contained in:
dahyeon committed 2026-06-26 23:29:47 -07:00
1 parent 4906f665fd
commit 292e37aaac
8 files changed
+404 -161

No files matched your search

@@ -20,7 +20,7 @@ describe('RiotDdragonService', () => {
jest.restoreAllMocks(); jest.restoreAllMocks();
}); });
it('includes localized item metadata in the manifest', async () => { it('includes localized item, spell, and rune metadata in the manifest', async () => {
const fetchMock = jest.fn(async (url: string) => { const fetchMock = jest.fn(async (url: string) => {
if (url.endsWith('/api/versions.json')) { if (url.endsWith('/api/versions.json')) {
return jsonResponse(['15.24.1']); return jsonResponse(['15.24.1']);
@@ -35,12 +35,40 @@ describe('RiotDdragonService', () => {
if (url.endsWith('/summoner.json')) { if (url.endsWith('/summoner.json')) {
return jsonResponse({ return jsonResponse({
data: { data: {
SummonerFlash: { key: '4', id: 'SummonerFlash', name: '점멸' }, SummonerFlash: {
key: '4',
id: 'SummonerFlash',
name: '점멸',
description: '커서 방향으로 순간이동합니다.',
tooltip: '<span>커서 방향으로 순간이동합니다.</span>',
},
}, },
}); });
} }
if (url.endsWith('/runesReforged.json')) { if (url.endsWith('/runesReforged.json')) {
return jsonResponse([]); return jsonResponse([
{
id: 8000,
key: 'Precision',
icon: 'perk-images/Styles/7201_Precision.png',
name: '정밀',
slots: [
{
runes: [
{
id: 8005,
key: 'PressTheAttack',
icon: 'perk-images/Styles/Precision/PressTheAttack/PressTheAttack.png',
name: '집중 공격',
shortDesc: '연속 공격 시 추가 피해',
longDesc:
'<lol-uikit-tooltipped-keyword>기본 공격</lol-uikit-tooltipped-keyword>으로 적을 약화시킵니다.',
},
],
},
],
},
]);
} }
if (url.endsWith('/item.json')) { if (url.endsWith('/item.json')) {
return jsonResponse({ return jsonResponse({
@@ -70,6 +98,33 @@ describe('RiotDdragonService', () => {
await expect(service.getManifest('ko_KR')).resolves.toMatchObject({ await expect(service.getManifest('ko_KR')).resolves.toMatchObject({
version: '15.24.1', version: '15.24.1',
locale: 'ko_KR', locale: 'ko_KR',
summonerSpells: {
'4': {
key: 'SummonerFlash',
name: '점멸',
description: '커서 방향으로 순간이동합니다.',
tooltip: '<span>커서 방향으로 순간이동합니다.</span>',
},
},
runesReforged: [
{
id: 8000,
name: '정밀',
slots: [
{
runes: [
{
id: 8005,
name: '집중 공격',
shortDesc: '연속 공격 시 추가 피해',
longDesc:
'<lol-uikit-tooltipped-keyword>기본 공격</lol-uikit-tooltipped-keyword>으로 적을 약화시킵니다.',
},
],
},
],
},
],
items: { items: {
'1055': { '1055': {
name: '도란의 검', name: '도란의 검',
@@ -90,8 +145,22 @@ describe('RiotDdragonService', () => {
expect.any(Object), expect.any(Object),
); );
expect(redis.setJson).toHaveBeenCalledWith( expect(redis.setJson).toHaveBeenCalledWith(
'ddragon:manifest:v4:ko_KR', 'ddragon:manifest:v5:ko_KR',
expect.objectContaining({ expect.objectContaining({
summonerSpells: expect.objectContaining({
'4': expect.objectContaining({ description: '커서 방향으로 순간이동합니다.' }),
}),
runesReforged: expect.arrayContaining([
expect.objectContaining({
slots: expect.arrayContaining([
expect.objectContaining({
runes: expect.arrayContaining([
expect.objectContaining({ longDesc: expect.stringContaining('기본 공격') }),
]),
}),
]),
}),
]),
items: expect.objectContaining({ items: expect.objectContaining({
'1055': expect.objectContaining({ name: '도란의 검' }), '1055': expect.objectContaining({ name: '도란의 검' }),
}), }),
@@ -5,7 +5,7 @@ const DDRAGON_BASE = 'https://ddragon.leagueoflegends.com';
const DDRAGON_CDN = `${DDRAGON_BASE}/cdn`; const DDRAGON_CDN = `${DDRAGON_BASE}/cdn`;
const DEFAULT_LOCALE = 'ko_KR'; const DEFAULT_LOCALE = 'ko_KR';
const CACHE_TTL_SECONDS = 24 * 60 * 60; const CACHE_TTL_SECONDS = 24 * 60 * 60;
const CACHE_VERSION = 'v4'; const CACHE_VERSION = 'v5';
const FETCH_TIMEOUT_MS = 10_000; const FETCH_TIMEOUT_MS = 10_000;
export interface DdragonChampionEntry { export interface DdragonChampionEntry {
@@ -16,6 +16,8 @@ export interface DdragonChampionEntry {
export interface DdragonSummonerSpellEntry { export interface DdragonSummonerSpellEntry {
key: string; key: string;
name: string; name: string;
description: string;
tooltip: string;
} }
export interface DdragonRuneEntry { export interface DdragonRuneEntry {
@@ -23,6 +25,8 @@ export interface DdragonRuneEntry {
key: string; key: string;
icon: string; icon: string;
name: string; name: string;
shortDesc: string;
longDesc: string;
} }
export interface DdragonRuneStyleEntry extends DdragonRuneEntry { export interface DdragonRuneStyleEntry extends DdragonRuneEntry {
@@ -66,6 +70,8 @@ interface SummonerSpellDataEntry {
key: string; key: string;
id: string; id: string;
name: string; name: string;
description?: string;
tooltip?: string;
} }
interface SummonerSpellDataResponse { interface SummonerSpellDataResponse {
@@ -77,6 +83,8 @@ interface RuneDataEntry {
key: string; key: string;
icon: string; icon: string;
name: string; name: string;
shortDesc?: string;
longDesc?: string;
} }
interface RuneStyleDataEntry extends RuneDataEntry { interface RuneStyleDataEntry extends RuneDataEntry {
@@ -195,6 +203,9 @@ export class RiotDdragonService {
map[entry.key] = { map[entry.key] = {
key: entry.id, key: entry.id,
name: typeof entry.name === 'string' ? entry.name : entry.id, name: typeof entry.name === 'string' ? entry.name : entry.id,
description:
typeof entry.description === 'string' ? entry.description : '',
tooltip: typeof entry.tooltip === 'string' ? entry.tooltip : '',
}; };
} }
} }
@@ -218,6 +229,9 @@ export class RiotDdragonService {
key: style.key, key: style.key,
icon: style.icon, icon: style.icon,
name: style.name, name: style.name,
shortDesc:
typeof style.shortDesc === 'string' ? style.shortDesc : '',
longDesc: typeof style.longDesc === 'string' ? style.longDesc : '',
slots: (style.slots ?? []).map((slot) => ({ slots: (style.slots ?? []).map((slot) => ({
runes: (slot.runes ?? []) runes: (slot.runes ?? [])
.filter((rune): rune is RuneDataEntry => isRuneEntry(rune)) .filter((rune): rune is RuneDataEntry => isRuneEntry(rune))
@@ -226,6 +240,9 @@ export class RiotDdragonService {
key: rune.key, key: rune.key,
icon: rune.icon, icon: rune.icon,
name: rune.name, name: rune.name,
shortDesc:
typeof rune.shortDesc === 'string' ? rune.shortDesc : '',
longDesc: typeof rune.longDesc === 'string' ? rune.longDesc : '',
})), })),
})), })),
})); }));
+4
View File
@@ -482,6 +482,8 @@ export interface DdragonChampionEntry {
export interface DdragonSummonerSpellEntry { export interface DdragonSummonerSpellEntry {
key: string; key: string;
name: string; name: string;
description: string;
tooltip: string;
} }
export interface DdragonRuneEntry { export interface DdragonRuneEntry {
@@ -489,6 +491,8 @@ export interface DdragonRuneEntry {
key: string; key: string;
icon: string; icon: string;
name: string; name: string;
shortDesc: string;
longDesc: string;
} }
export interface DdragonRuneStyleEntry extends DdragonRuneEntry { export interface DdragonRuneStyleEntry extends DdragonRuneEntry {
@@ -3,12 +3,10 @@ import type { ApiInternalMatchDetailResponse, DdragonManifest, TeamSide } from "
import { import {
championDisplayName, championDisplayName,
championIconUrl, championIconUrl,
runeIconUrl,
runeStyleIconUrl,
} from "../lib/ddragon"; } from "../lib/ddragon";
import { teamIndexLabel } from "../lib/league"; import { teamIndexLabel } from "../lib/league";
import { LANE_LABELS } from "../lib/riot-history"; import { LANE_LABELS } from "../lib/riot-history";
import { ItemIcon } from "./ItemTooltip"; import { ItemIcon, RuneIcon, RuneStyleIcon } from "./ItemTooltip";
export type InternalGameDetailTab = "scoreboard" | "matchup" | "build"; export type InternalGameDetailTab = "scoreboard" | "matchup" | "build";
@@ -413,21 +411,17 @@ function RuneTreeColumn({
); );
} }
const styleIcon = runeStyleIconUrl(manifest, runeStyle.id);
const selectionIds = new Set(selection?.perkIds ?? []); const selectionIds = new Set(selection?.perkIds ?? []);
return ( return (
<div> <div>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<span className="h-6 w-6 overflow-hidden bg-base-content/10"> <RuneStyleIcon
{styleIcon ? ( styleId={runeStyle.id}
<img manifest={manifest}
src={styleIcon} className="h-6 w-6"
alt="" slotClassName="bg-base-content/10"
className="h-full w-full object-cover" />
/>
) : null}
</span>
<div className="min-w-0"> <div className="min-w-0">
<div className="text-[10px] font-bold uppercase tracking-wider text-base-content/35"> <div className="text-[10px] font-bold uppercase tracking-wider text-base-content/35">
{label} {label}
@@ -455,25 +449,18 @@ function RuneTreeColumn({
{slot.runes.map((rune) => { {slot.runes.map((rune) => {
const selected = const selected =
selectedIds.has(rune.id) || selectionIds.has(rune.id); selectedIds.has(rune.id) || selectionIds.has(rune.id);
const icon = runeIconUrl(manifest, rune.id);
return ( return (
<span <RuneIcon
key={rune.id} key={rune.id}
title={rune.name} runeId={rune.id}
className={`${iconSize} overflow-hidden border bg-base-content/10 transition ${ manifest={manifest}
className={iconSize}
slotClassName={`border bg-base-content/10 transition ${
selected selected
? "border-transparent opacity-100 ring-1 ring-primary/60" ? "border-transparent opacity-100 ring-1 ring-primary/60"
: "border-transparent opacity-20 grayscale" : "border-transparent opacity-20 grayscale"
}`} }`}
> />
{icon ? (
<img
src={icon}
alt=""
className="h-full w-full object-cover"
/>
) : null}
</span>
); );
})} })}
</div> </div>
+226 -24
View File
@@ -1,4 +1,4 @@
import type { CSSProperties, RefObject } from "react"; import type { CSSProperties, ReactNode, RefObject } from "react";
import { useEffect, useId, useRef, useState } from "react"; import { useEffect, useId, useRef, useState } from "react";
import { createPortal } from "react-dom"; import { createPortal } from "react-dom";
import type { DdragonManifest } from "../api/types"; import type { DdragonManifest } from "../api/types";
@@ -6,7 +6,13 @@ import {
itemDetails, itemDetails,
itemDisplayName, itemDisplayName,
itemIconUrl, itemIconUrl,
runeDetails,
runeIconUrl,
runeStyleDetails,
runeStyleIconUrl,
safeDdragonDescriptionHtml, safeDdragonDescriptionHtml,
summonerSpellDetails,
summonerSpellIconUrl,
} from "../lib/ddragon"; } from "../lib/ddragon";
type TooltipPosition = { type TooltipPosition = {
@@ -24,6 +30,24 @@ type ItemIconProps = {
trinket?: boolean; trinket?: boolean;
}; };
type TooltipIconProps = {
active: boolean;
label: string;
emptyLabel: string;
icon: string | null;
className: string;
imageClassName: string;
slotClassName: string;
children: ReactNode;
};
type ManifestIconProps = {
manifest: DdragonManifest | null | undefined;
className?: string;
imageClassName?: string;
slotClassName?: string;
};
const VIEWPORT_MARGIN = 8; const VIEWPORT_MARGIN = 8;
const TOOLTIP_GAP = 8; const TOOLTIP_GAP = 8;
const TOOLTIP_WIDTH = 320; const TOOLTIP_WIDTH = 320;
@@ -35,9 +59,6 @@ export function ItemIcon({
imageClassName = "scale-[1.18]", imageClassName = "scale-[1.18]",
trinket = false, trinket = false,
}: ItemIconProps) { }: ItemIconProps) {
const anchorRef = useRef<HTMLSpanElement>(null);
const tooltipId = useId();
const [open, setOpen] = useState(false);
const icon = itemIconUrl(manifest, itemId); const icon = itemIconUrl(manifest, itemId);
const hasItem = itemId > 0; const hasItem = itemId > 0;
const itemName = itemDisplayName(manifest, itemId) ?? `아이템 ${itemId}`; const itemName = itemDisplayName(manifest, itemId) ?? `아이템 ${itemId}`;
@@ -45,21 +66,125 @@ export function ItemIcon({
? "border-primary/25 bg-base-content/[0.04]" ? "border-primary/25 bg-base-content/[0.04]"
: "border-base-content/5 bg-base-content/8"; : "border-base-content/5 bg-base-content/8";
return (
<TooltipIcon
active={hasItem}
label={itemName}
emptyLabel="빈 아이템 슬롯"
icon={icon}
className={className}
imageClassName={imageClassName}
slotClassName={`border ${slotTone}`}
>
<ItemTooltipContent itemId={itemId} manifest={manifest} />
</TooltipIcon>
);
}
export function SummonerSpellIcon({
spellId,
manifest,
className = "h-5 w-5",
imageClassName = "",
slotClassName = "border border-base-content/5 bg-base-content/10",
}: ManifestIconProps & { spellId: number }) {
const spell = summonerSpellDetails(manifest, spellId);
const spellName = spell?.name ?? `스펠 ${spellId}`;
return (
<TooltipIcon
active={spellId > 0}
label={spellName}
emptyLabel="빈 스펠 슬롯"
icon={summonerSpellIconUrl(manifest, spellId)}
className={className}
imageClassName={imageClassName}
slotClassName={slotClassName}
>
<SummonerSpellTooltipContent spellId={spellId} manifest={manifest} />
</TooltipIcon>
);
}
export function RuneIcon({
runeId,
manifest,
className = "h-5 w-5",
imageClassName = "",
slotClassName = "border border-base-content/5 bg-base-content/10",
}: ManifestIconProps & { runeId: number | undefined }) {
const rune = runeDetails(manifest, runeId);
const runeName = rune?.name ?? (runeId ? `룬 ${runeId}` : "룬");
return (
<TooltipIcon
active={Boolean(runeId)}
label={runeName}
emptyLabel="빈 룬 슬롯"
icon={runeIconUrl(manifest, runeId)}
className={className}
imageClassName={imageClassName}
slotClassName={slotClassName}
>
<RuneTooltipContent runeId={runeId} manifest={manifest} />
</TooltipIcon>
);
}
export function RuneStyleIcon({
styleId,
manifest,
className = "h-5 w-5",
imageClassName = "",
slotClassName = "border border-base-content/5 bg-base-content/10",
}: ManifestIconProps & { styleId: number | undefined }) {
const style = runeStyleDetails(manifest, styleId);
const styleName = style?.name ?? (styleId ? `룬 ${styleId}` : "룬");
return (
<TooltipIcon
active={Boolean(styleId)}
label={styleName}
emptyLabel="빈 룬 슬롯"
icon={runeStyleIconUrl(manifest, styleId)}
className={className}
imageClassName={imageClassName}
slotClassName={slotClassName}
>
<RuneStyleTooltipContent styleId={styleId} manifest={manifest} />
</TooltipIcon>
);
}
function TooltipIcon({
active,
label,
emptyLabel,
icon,
className,
imageClassName,
slotClassName,
children,
}: TooltipIconProps) {
const anchorRef = useRef<HTMLSpanElement>(null);
const tooltipId = useId();
const [open, setOpen] = useState(false);
return ( return (
<span <span
ref={anchorRef} ref={anchorRef}
className={`relative inline-flex shrink-0 ${className}`} className={`relative inline-flex shrink-0 ${className}`}
role={hasItem ? "img" : undefined} role={active ? "img" : undefined}
tabIndex={hasItem ? 0 : undefined} tabIndex={active ? 0 : undefined}
aria-label={hasItem ? itemName : "빈 아이템 슬롯"} aria-label={active ? label : emptyLabel}
aria-describedby={hasItem && open ? tooltipId : undefined} aria-describedby={active && open ? tooltipId : undefined}
onBlur={() => setOpen(false)} onBlur={() => setOpen(false)}
onFocus={() => hasItem && setOpen(true)} onFocus={() => active && setOpen(true)}
onMouseEnter={() => hasItem && setOpen(true)} onMouseEnter={() => active && setOpen(true)}
onMouseLeave={() => setOpen(false)} onMouseLeave={() => setOpen(false)}
> >
<span <span
className={`block h-full w-full overflow-hidden border ${slotTone}`} className={`block h-full w-full overflow-hidden ${slotClassName}`}
aria-hidden="true" aria-hidden="true"
> >
{icon ? ( {icon ? (
@@ -71,28 +196,23 @@ export function ItemIcon({
/> />
) : null} ) : null}
</span> </span>
{hasItem && open ? ( {active && open ? (
<ItemTooltipPortal <TooltipPortal id={tooltipId} anchorRef={anchorRef}>
id={tooltipId} {children}
anchorRef={anchorRef} </TooltipPortal>
itemId={itemId}
manifest={manifest}
/>
) : null} ) : null}
</span> </span>
); );
} }
function ItemTooltipPortal({ function TooltipPortal({
id, id,
anchorRef, anchorRef,
itemId, children,
manifest,
}: { }: {
id: string; id: string;
anchorRef: RefObject<HTMLElement | null>; anchorRef: RefObject<HTMLElement | null>;
itemId: number; children: ReactNode;
manifest: DdragonManifest | null | undefined;
}) { }) {
const [position, setPosition] = useState<TooltipPosition | null>(null); const [position, setPosition] = useState<TooltipPosition | null>(null);
@@ -149,12 +269,94 @@ function ItemTooltipPortal({
style={style} style={style}
className="pointer-events-none fixed z-[1000] border border-base-content/20 bg-black px-3 py-3 text-xs leading-relaxed text-white shadow-2xl" className="pointer-events-none fixed z-[1000] border border-base-content/20 bg-black px-3 py-3 text-xs leading-relaxed text-white shadow-2xl"
> >
<ItemTooltipContent itemId={itemId} manifest={manifest} /> {children}
</div>, </div>,
document.body, document.body,
); );
} }
function SummonerSpellTooltipContent({
spellId,
manifest,
}: {
spellId: number;
manifest: DdragonManifest | null | undefined;
}) {
const spell = summonerSpellDetails(manifest, spellId);
const descriptionHtml = spell?.description
? safeDdragonDescriptionHtml(spell.description)
: "";
return (
<div className="space-y-2">
<div className="font-black text-[#f0d878]">
{spell?.name ?? `스펠 ${spellId}`}
</div>
{descriptionHtml ? (
<div
className="text-white/80 [&_br]:block [&_br]:content-['']"
dangerouslySetInnerHTML={{ __html: descriptionHtml }}
/>
) : (
<div className="text-white/55">
스펠 상세 정보를 불러오는 중입니다.
</div>
)}
</div>
);
}
function RuneTooltipContent({
runeId,
manifest,
}: {
runeId: number | undefined;
manifest: DdragonManifest | null | undefined;
}) {
const rune = runeDetails(manifest, runeId);
const descriptionHtml = rune?.longDesc
? safeDdragonDescriptionHtml(rune.longDesc)
: "";
return (
<div className="space-y-2">
<div className="font-black text-[#f0d878]">
{rune?.name ?? (runeId ? `룬 ${runeId}` : "룬")}
</div>
{rune?.shortDesc ? (
<div className="font-bold text-white">{rune.shortDesc}</div>
) : null}
{descriptionHtml ? (
<div
className="text-white/80 [&_br]:block [&_br]:content-['']"
dangerouslySetInnerHTML={{ __html: descriptionHtml }}
/>
) : (
<div className="text-white/55">룬 상세 정보를 불러오는 중입니다.</div>
)}
</div>
);
}
function RuneStyleTooltipContent({
styleId,
manifest,
}: {
styleId: number | undefined;
manifest: DdragonManifest | null | undefined;
}) {
const style = runeStyleDetails(manifest, styleId);
return (
<div className="space-y-2">
<div className="font-black text-[#f0d878]">
{style?.name ?? (styleId ? `룬 ${styleId}` : "룬")}
</div>
<div className="text-white/55">룬 스타일</div>
</div>
);
}
function ItemTooltipContent({ function ItemTooltipContent({
itemId, itemId,
manifest, manifest,
+27 -4
View File
@@ -98,21 +98,44 @@ export function summonerSpellIconUrl(
return `${cdn(manifest)}/${version(manifest)}/img/spell/${spell.key}.png`; return `${cdn(manifest)}/${version(manifest)}/img/spell/${spell.key}.png`;
} }
export function summonerSpellDetails(
manifest: DdragonManifest | null | undefined,
spellId: number,
) {
if (!spellId) return null;
return manifest?.summonerSpells[String(spellId)] ?? null;
}
export function runeStyleDetails(
manifest: DdragonManifest | null | undefined,
styleId: number | undefined,
) {
return manifest?.runesReforged.find((entry) => entry.id === styleId) ?? null;
}
export function runeStyleIconUrl( export function runeStyleIconUrl(
manifest: DdragonManifest | null | undefined, manifest: DdragonManifest | null | undefined,
styleId: number | undefined, styleId: number | undefined,
) { ) {
const style = manifest?.runesReforged.find((entry) => entry.id === styleId); const style = runeStyleDetails(manifest, styleId);
return style ? `${cdn(manifest)}/img/${style.icon}` : null; return style ? `${cdn(manifest)}/img/${style.icon}` : null;
} }
export function runeDetails(
manifest: DdragonManifest | null | undefined,
runeId: number | undefined,
) {
if (!runeId) return null;
return manifest?.runesReforged
.flatMap((style) => style.slots.flatMap((slot) => slot.runes))
.find((entry) => entry.id === runeId) ?? null;
}
export function runeKeystoneIconUrl( export function runeKeystoneIconUrl(
manifest: DdragonManifest | null | undefined, manifest: DdragonManifest | null | undefined,
runeId: number | undefined, runeId: number | undefined,
) { ) {
const rune = manifest?.runesReforged const rune = runeDetails(manifest, runeId);
.flatMap((style) => style.slots.flatMap((slot) => slot.runes))
.find((entry) => entry.id === runeId);
return rune ? `${cdn(manifest)}/img/${rune.icon}` : null; return rune ? `${cdn(manifest)}/img/${rune.icon}` : null;
} }
+15 -37
View File
@@ -17,9 +17,6 @@ import { DEFAULT_COMMUNITY_ID } from "../config";
import { import {
championDisplayName, championDisplayName,
championIconUrl, championIconUrl,
runeKeystoneIconUrl,
runeStyleIconUrl,
summonerSpellIconUrl,
} from "../lib/ddragon"; } from "../lib/ddragon";
import { import {
sideShortLabel, sideShortLabel,
@@ -36,7 +33,12 @@ import {
InternalGameDetailTabBar, InternalGameDetailTabBar,
type InternalGameDetailTab, type InternalGameDetailTab,
} from "../components/InternalGameAnalysisTabs"; } from "../components/InternalGameAnalysisTabs";
import { ItemIcon } from "../components/ItemTooltip"; import {
ItemIcon,
RuneIcon,
RuneStyleIcon,
SummonerSpellIcon,
} from "../components/ItemTooltip";
type MatchGameDetail = ApiInternalMatchDetailResponse["games"][number]; type MatchGameDetail = ApiInternalMatchDetailResponse["games"][number];
type MatchGameTeam = MatchGameDetail["teams"][number]; type MatchGameTeam = MatchGameDetail["teams"][number];
@@ -258,47 +260,23 @@ function SpellRuneStrip({
participant: MatchGameParticipant; participant: MatchGameParticipant;
manifest: ReturnType<typeof useDdragonManifest>["data"]; manifest: ReturnType<typeof useDdragonManifest>["data"];
}) { }) {
const spellIcons = participant.summonerSpells
.map((spellId) => summonerSpellIconUrl(manifest, spellId))
.filter((icon): icon is string => Boolean(icon));
const runeIcons = [
runeKeystoneIconUrl(manifest, participant.perks.keystone),
runeStyleIconUrl(manifest, participant.perks.subStyle),
].filter((icon): icon is string => Boolean(icon));
return ( return (
<div className="flex items-center gap-1.5"> <div className="flex items-center gap-1.5">
<div className="grid grid-cols-1 gap-0.5"> <div className="grid grid-cols-1 gap-0.5">
{[0, 1].map((index) => ( {[0, 1].map((index) => (
<span <SummonerSpellIcon
key={`spell-${index}`} key={`spell-${index}`}
className="h-5 w-5 overflow-hidden bg-base-content/10" spellId={participant.summonerSpells[index] ?? 0}
> manifest={manifest}
{spellIcons[index] ? ( />
<img
src={spellIcons[index]}
alt=""
className="h-full w-full object-cover"
/>
) : null}
</span>
))} ))}
</div> </div>
<div className="grid grid-cols-1 gap-0.5"> <div className="grid grid-cols-1 gap-0.5">
{[0, 1].map((index) => ( <RuneIcon runeId={participant.perks.keystone} manifest={manifest} />
<span <RuneStyleIcon
key={`rune-${index}`} styleId={participant.perks.subStyle ?? participant.perks.primaryStyle}
className="h-5 w-5 overflow-hidden bg-base-content/10" manifest={manifest}
> />
{runeIcons[index] ? (
<img
src={runeIcons[index]}
alt=""
className="h-full w-full object-cover"
/>
) : null}
</span>
))}
</div> </div>
</div> </div>
); );
+28 -65
View File
@@ -32,9 +32,6 @@ import {
championDisplayName, championDisplayName,
championIconUrl, championIconUrl,
profileIconUrl, profileIconUrl,
runeKeystoneIconUrl,
runeStyleIconUrl,
summonerSpellIconUrl,
} from "../lib/ddragon"; } from "../lib/ddragon";
import { import {
isRiotQueueGroup, isRiotQueueGroup,
@@ -49,7 +46,12 @@ import {
InternalGameDetailTabBar, InternalGameDetailTabBar,
type InternalGameDetailTab, type InternalGameDetailTab,
} from "../components/InternalGameAnalysisTabs"; } from "../components/InternalGameAnalysisTabs";
import { ItemIcon } from "../components/ItemTooltip"; import {
ItemIcon,
RuneIcon,
RuneStyleIcon,
SummonerSpellIcon,
} from "../components/ItemTooltip";
// recharts가 무거워 메인 번들에서 분리한다 (전적 페이지에서만 로드). // recharts가 무거워 메인 번들에서 분리한다 (전적 페이지에서만 로드).
const TierHistoryChart = lazy(() => import("../components/TierHistoryChart")); const TierHistoryChart = lazy(() => import("../components/TierHistoryChart"));
@@ -482,33 +484,6 @@ function barPercent(value: number, max: number) {
return Math.max(0, Math.min(100, Math.round((value / max) * 100))); return Math.max(0, Math.min(100, Math.round((value / max) * 100)));
} }
function AssetIcon({
url,
label,
className = "w-4 h-4",
}: {
url: string | null;
label: string;
className?: string;
}) {
return (
<div
className={`${className} bg-base-content/8 overflow-hidden border border-base-content/5`}
title={label}
aria-label={label}
>
{url ? (
<img
src={url}
alt=""
className="w-full h-full object-cover"
loading="lazy"
/>
) : null}
</div>
);
}
function LoadoutIcons({ function LoadoutIcons({
summonerSpells, summonerSpells,
perks, perks,
@@ -520,25 +495,12 @@ function LoadoutIcons({
}) { }) {
return ( return (
<div className="grid grid-cols-2 gap-0.5 shrink-0"> <div className="grid grid-cols-2 gap-0.5 shrink-0">
<AssetIcon <SummonerSpellIcon spellId={summonerSpells[0]} manifest={manifest} />
url={summonerSpellIconUrl(manifest, summonerSpells[0])} <RuneIcon runeId={perks.keystone} manifest={manifest} />
label="스펠 1" <SummonerSpellIcon spellId={summonerSpells[1]} manifest={manifest} />
className="w-5 h-5" <RuneStyleIcon
/> styleId={perks.subStyle ?? perks.primaryStyle}
<AssetIcon manifest={manifest}
url={runeKeystoneIconUrl(manifest, perks.keystone)}
label="핵심 룬"
className="w-5 h-5"
/>
<AssetIcon
url={summonerSpellIconUrl(manifest, summonerSpells[1])}
label="스펠 2"
className="w-5 h-5"
/>
<AssetIcon
url={runeStyleIconUrl(manifest, perks.subStyle ?? perks.primaryStyle)}
label="보조 룬"
className="w-5 h-5"
/> />
</div> </div>
); );
@@ -654,24 +616,25 @@ function ParticipantRow({
)} )}
</div> </div>
<div className="grid grid-cols-2 gap-0.5 shrink-0"> <div className="grid grid-cols-2 gap-0.5 shrink-0">
<AssetIcon <SummonerSpellIcon
url={summonerSpellIconUrl(manifest, participant.summonerSpells[0])} spellId={participant.summonerSpells[0]}
label="스펠 1" manifest={manifest}
className="h-4 w-4"
/> />
<AssetIcon <RuneIcon
url={runeKeystoneIconUrl(manifest, participant.perks.keystone)} runeId={participant.perks.keystone}
label="핵심 룬" manifest={manifest}
className="h-4 w-4"
/> />
<AssetIcon <SummonerSpellIcon
url={summonerSpellIconUrl(manifest, participant.summonerSpells[1])} spellId={participant.summonerSpells[1]}
label="스펠 2" manifest={manifest}
className="h-4 w-4"
/> />
<AssetIcon <RuneStyleIcon
url={runeStyleIconUrl( styleId={participant.perks.subStyle ?? participant.perks.primaryStyle}
manifest, manifest={manifest}
participant.perks.subStyle ?? participant.perks.primaryStyle, className="h-4 w-4"
)}
label="보조 룬"
/> />
</div> </div>
<div className="min-w-0"> <div className="min-w-0">