Files
persona-lenz/apps/web/src/components/dashboard/champion-pool-card.tsx
T

53 lines
2.2 KiB
TypeScript

import type { ChampionPoolEntryDto } from '@persona-lenz/shared'
import type { ChampionIndex } from '../../lib/ddragon'
import { championImageUrl } from '../../lib/ddragon'
interface ChampionPoolCardProps {
championPool: ChampionPoolEntryDto[]
champions: ChampionIndex | null
}
/** 분석 표본에 포함된 챔피언 풀 — 판수 내림차순 상위 5개 */
export function ChampionPoolCard({ championPool, champions }: ChampionPoolCardProps) {
const entries = championPool.slice(0, 5)
return (
<section className="rounded-2xl border border-border bg-card p-6 shadow-[var(--shadow-card)]">
<h2 className="text-[18px] font-bold text-text-primary">챔피언 풀</h2>
<p className="mt-1 text-[13px] text-text-tertiary">이번 분석 표본에서 많이 플레이한 순이에요.</p>
<ul className="mt-4 divide-y divide-border">
{entries.map((entry) => {
const champion = champions?.byId.get(entry.championId)
const winRate = entry.games > 0 ? Math.round((entry.wins / entry.games) * 100) : 0
return (
<li key={entry.championId} className="flex items-center gap-4 py-3">
{champion && champions ? (
<img
src={championImageUrl(champions.version, champion.slug)}
alt=""
className="size-10 rounded-lg"
loading="lazy"
/>
) : (
<span aria-hidden className="size-10 rounded-lg bg-surface-muted" />
)}
<div className="min-w-0 flex-1">
<p className="text-[15px] font-bold text-text-primary">
{champion?.name ?? `챔피언 #${entry.championId}`}
</p>
<p className="text-[13px] tabular-nums text-text-tertiary">
{entry.games}전 {entry.wins}승
</p>
</div>
<span className="text-[17px] font-bold tabular-nums text-text-primary">
{winRate}
<span className="text-[11px] font-medium text-text-tertiary">%</span>
</span>
</li>
)
})}
</ul>
</section>
)
}