feat: enhance auction interactions and player statistics UI
This commit is contained in:
1 parent
6c582ba3cf
commit
be4de61bb7
115 files changed
+13292
-2871
No files matched your search
@@ -0,0 +1,207 @@
|
||||
import { useState, type KeyboardEvent } from "react";
|
||||
import { ArrowUpRight } from "lucide-react";
|
||||
import type {
|
||||
DdragonManifest,
|
||||
Position,
|
||||
RiotLane,
|
||||
} from "../../api/types";
|
||||
import { RankBadge } from "../../components/RankBadge";
|
||||
import { formatRankDetail } from "../../components/rankBadgeUtils";
|
||||
import { DEFAULT_COMMUNITY_ID } from "../../config";
|
||||
import { championDisplayName, championIconUrl, profileIconUrl } from "../../lib/ddragon";
|
||||
import { internalMatchGamePath } from "../../lib/internal-match-routes";
|
||||
import { POSITION_ORDER, positionIcon, positionLabel } from "../../lib/league";
|
||||
import { internalMatches, manifest, profile, snapshot, summaries, type PreviewMatch, type PreviewProfile, type PreviewSnapshot, type PreviewSummary } from "./data";
|
||||
import "./preview.css";
|
||||
|
||||
const MATCH_ID = "6a3b94bccb8a54219653f457";
|
||||
const USER_ID = "69ed3d75f3a6fd129207196b";
|
||||
const LANES: Record<Position, RiotLane> = {
|
||||
TOP: "TOP", JGL: "JUNGLE", MID: "MIDDLE", ADC: "BOTTOM", SUP: "UTILITY",
|
||||
};
|
||||
type ProfileTab = "internal" | "solo";
|
||||
|
||||
function formatDate(value: string | number | null | undefined) {
|
||||
if (!value) return "기록 없음";
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) return "기록 없음";
|
||||
return new Intl.DateTimeFormat("ko-KR", {
|
||||
timeZone: "Asia/Seoul", year: "numeric", month: "2-digit", day: "2-digit",
|
||||
}).format(date).replace(/\s/g, "").replace(/\.$/, "");
|
||||
}
|
||||
|
||||
function Portrait({ championId, manifest }: { championId: number; manifest: DdragonManifest }) {
|
||||
const src = championIconUrl(manifest, championId);
|
||||
return (
|
||||
<span className="pi-champion-portrait">
|
||||
{src && <img src={src} alt="" loading="lazy" />}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function PositionExperience({ summary, mainPosition, tab }: {
|
||||
summary: PreviewSummary;
|
||||
mainPosition: Position;
|
||||
tab: ProfileTab;
|
||||
}) {
|
||||
const mainRate = summary.positionRates[LANES[mainPosition]] ?? 0;
|
||||
return (
|
||||
<section className="pi-experience" aria-label="실제 플레이 포지션">
|
||||
<div className="pi-section-heading">
|
||||
<h3>실제 플레이 포지션</h3>
|
||||
<span>최근 {summary.windowSize}경기</span>
|
||||
</div>
|
||||
<div className="pi-position-grid">
|
||||
{POSITION_ORDER.map(position => {
|
||||
const rate = summary.positionRates[LANES[position]] ?? 0;
|
||||
const games = Math.round(summary.windowSize * rate / 100);
|
||||
return (
|
||||
<div className="pi-position-stat" data-played={games > 0} key={position}>
|
||||
<div><img src={positionIcon[position]} alt="" />{positionLabel[position]}</div>
|
||||
<strong>{games}<span>경기</span></strong>
|
||||
<div className="pi-position-track" aria-hidden="true"><span style={{ width: `${rate}%` }} /></div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{summary.windowSize > 0 && mainRate === 0 && (
|
||||
<p className="pi-position-note">신청 1순위는 {positionLabel[mainPosition]} · 최근 {tab === "solo" ? "솔로랭크" : "내전"}에서 해당 포지션 기록은 없습니다.</p>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function Metrics({ summary }: { summary: PreviewSummary }) {
|
||||
return (
|
||||
<div className="pi-metrics">
|
||||
<div><span>승률</span><strong>{summary.winRate}<small>%</small></strong><p>{summary.wins}승 {summary.losses}패 · {summary.windowSize}경기</p></div>
|
||||
<div><span>KDA</span><strong>{summary.kda}</strong><p>{summary.avgKills} / {summary.avgDeaths} / {summary.avgAssists}</p></div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function RecentChampions({ summary, manifest }: { summary: PreviewSummary; manifest: DdragonManifest }) {
|
||||
return (
|
||||
<section>
|
||||
<div className="pi-section-heading"><h3>최근 사용 챔피언</h3><span>{summary.windowSize}경기 기준</span></div>
|
||||
<div className="pi-champion-list">
|
||||
{summary.topChampions.slice(0, 5).map(champion => {
|
||||
const wins = Math.round(champion.games * champion.winRate / 100);
|
||||
return (
|
||||
<div className="pi-champion-row" key={champion.championId}>
|
||||
<Portrait championId={champion.championId} manifest={manifest} />
|
||||
<div><strong>{championDisplayName(manifest, champion.championId)}</strong><p>{champion.games}경기 · {wins}승 {champion.games - wins}패</p></div>
|
||||
<span className="pi-champion-rate">{champion.winRate}%</span>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{summary.topChampions.length === 0 && <p className="pi-empty">최근 챔피언 기록이 없습니다.</p>}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function RecentGames({ matches, manifest }: { matches: PreviewMatch[]; manifest: DdragonManifest }) {
|
||||
return (
|
||||
<section>
|
||||
<div className="pi-section-heading"><h3>최근 내전</h3><span>{Math.min(5, matches.length)}경기</span></div>
|
||||
<div className="pi-recent-list">
|
||||
{matches.slice(0, 5).map(match => {
|
||||
const name = championDisplayName(manifest, match.championId);
|
||||
const href = match.internalMatchId && match.gameNumber
|
||||
? internalMatchGamePath(DEFAULT_COMMUNITY_ID, match.internalMatchId, match.gameNumber)
|
||||
: `/users/${USER_ID}/history?queueGroup=internal`;
|
||||
return (
|
||||
<a className="pi-recent-game" key={match.matchId} href={href} target="_blank" rel="noreferrer" aria-label={`${name} ${match.win ? "승리" : "패배"} 경기 상세 새 탭에서 보기`}>
|
||||
<Portrait championId={match.championId} manifest={manifest} />
|
||||
<div><strong><b data-result={match.win ? "win" : "loss"}>{match.remake ? "다시하기" : match.win ? "승리" : "패배"}</b> {name}</strong><p>{formatDate(match.gameCreation).slice(5)}</p></div>
|
||||
<span className="pi-game-kda">{match.kills}/{match.deaths}/{match.assists}</span>
|
||||
</a>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function Masteries({ snapshot, manifest }: { snapshot: PreviewSnapshot; manifest: DdragonManifest }) {
|
||||
return (
|
||||
<section>
|
||||
<div className="pi-section-heading"><h3>누적 숙련도</h3><span>경매 등록 기준</span></div>
|
||||
<div className="pi-champion-list">
|
||||
{(snapshot.masteries ?? []).slice(0, 5).map(champion => (
|
||||
<div className="pi-champion-row" key={champion.championId}>
|
||||
<Portrait championId={champion.championId} manifest={manifest} />
|
||||
<div><strong>{championDisplayName(manifest, champion.championId)}</strong><p>Lv.{champion.championLevel} · {(champion.championPoints / 1000).toFixed(0)}K</p></div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function PlayerCard({ initialTab, label, profile, snapshot, manifest }: {
|
||||
initialTab: ProfileTab;
|
||||
label: string;
|
||||
profile: PreviewProfile;
|
||||
snapshot: PreviewSnapshot;
|
||||
manifest: DdragonManifest;
|
||||
}) {
|
||||
const [tab, setTab] = useState<ProfileTab>(initialTab);
|
||||
const summary = summaries[tab];
|
||||
const preferences = [...snapshot.preferredPositions].sort((a, b) => a.priority - b.priority);
|
||||
const mainPosition = preferences[0]?.position ?? "MID";
|
||||
const tier = profile.tier;
|
||||
const peakLabel = formatRankDetail(profile.peak);
|
||||
const historyHref = `/users/${USER_ID}/history?queueGroup=${tab === "internal" ? "internal" : "summoners-rift"}${tab === "solo" ? "&rank=solo" : ""}`;
|
||||
const tabPrefix = `profile-${initialTab}`;
|
||||
|
||||
function handleTabKey(event: KeyboardEvent<HTMLButtonElement>) {
|
||||
if (!["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) return;
|
||||
event.preventDefault();
|
||||
const next = event.key === "Home" ? "internal" : event.key === "End" ? "solo" : tab === "internal" ? "solo" : "internal";
|
||||
setTab(next);
|
||||
document.getElementById(`${tabPrefix}-${next}`)?.focus();
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="pi-preview-state">
|
||||
<div className="pi-state-label">{initialTab === "internal" ? "01" : "02"} · {tab === "internal" ? "내전" : "솔로랭크"}</div>
|
||||
<article className="pi-player-card">
|
||||
<header className="pi-identity">
|
||||
<img className="pi-player-avatar" src={profileIconUrl(manifest, profile.profileIconId)} alt="" />
|
||||
<div className="pi-player-info">
|
||||
<div className="pi-player-name"><h2>{profile.gameName}</h2><span>#{profile.tagLine}</span></div>
|
||||
<div className="pi-rank"><RankBadge tier={tier} /><span>{formatRankDetail(tier)}</span><span className="pi-secondary">현재</span></div>
|
||||
{peakLabel && <p className="pi-peak">기록된 최고 <strong>{peakLabel}</strong></p>}
|
||||
<div className="pi-preferences"><span>신청 포지션</span>{preferences.slice(0, 2).map((preference, index) => <span className="pi-role-chip" data-primary={index === 0} key={preference.position}><img src={positionIcon[preference.position]} alt="" />{positionLabel[preference.position]}<small>{index + 1}순위</small></span>)}</div>
|
||||
</div>
|
||||
</header>
|
||||
<div className="pi-tabs" role="tablist" aria-label={`${label} 전적 종류`}>
|
||||
{(["internal", "solo"] as const).map(value => <button key={value} type="button" role="tab" id={`${tabPrefix}-${value}`} aria-selected={tab === value} aria-controls={`${tabPrefix}-panel`} tabIndex={tab === value ? 0 : -1} onClick={() => setTab(value)} onKeyDown={handleTabKey}>{value === "internal" ? "내전" : "솔로랭크"}</button>)}
|
||||
</div>
|
||||
<div className="pi-card-body" id={`${tabPrefix}-panel`} role="tabpanel" aria-labelledby={`${tabPrefix}-${tab}`}>
|
||||
<div className="pi-summary-heading"><h3>최근 {summary.windowSize}경기 · {tab === "internal" ? "내전" : "솔로랭크"}</h3><a href={historyHref} target="_blank" rel="noreferrer">전체 전적<ArrowUpRight size={13} aria-hidden="true" /></a></div>
|
||||
<p className="pi-record-basis">전체 포지션 기준<span>·</span>마지막 경기 {formatDate(summary.lastGameAt)}</p>
|
||||
<PositionExperience summary={summary} mainPosition={mainPosition} tab={tab} />
|
||||
<Metrics summary={summary} />
|
||||
<div className="pi-detail-columns"><RecentChampions summary={summary} manifest={manifest} />{tab === "internal" ? <RecentGames matches={internalMatches} manifest={manifest} /> : <Masteries snapshot={snapshot} manifest={manifest} />}</div>
|
||||
<div className="pi-data-note">{tab === "solo" && summary.lastFetchedAt && <span>전적 수집 기준 {formatDate(summary.lastFetchedAt)}</span>}<span>티어 확인 {formatDate(tier?.fetchedAt)}</span></div>
|
||||
</div>
|
||||
<footer className="pi-auction-status">{snapshot.passCount > 0 ? "유찰 — 강제 배정 대상" : "경매 참가 선수"}</footer>
|
||||
</article>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export default function Preview() {
|
||||
return (
|
||||
<main className="player-info-preview">
|
||||
<header className="pi-workbench-header"><div><p className="pi-eyebrow">LOLYMPUS · 선수 정보 개선 시안</p><h1>신청 포지션과 실제 경험을 한눈에</h1><p>같은 선수의 두 탭을 나란히 볼 수 있습니다. 탭과 전적 링크를 직접 눌러보세요.</p></div><a className="pi-original-link" href={`/match/${MATCH_ID}/auction`} target="_blank" rel="noreferrer">원래 경매 페이지<ArrowUpRight size={15} aria-hidden="true" /></a></header>
|
||||
<p className="pi-fixture-note">2026.11.11 확인 기록을 바탕으로 구성한 고정 시안 데이터입니다.</p>
|
||||
<div className="pi-preview-columns"><PlayerCard initialTab="internal" label="01 · 내전" profile={profile} snapshot={snapshot} manifest={manifest} /><PlayerCard initialTab="solo" label="02 · 솔로랭크" profile={profile} snapshot={snapshot} manifest={manifest} /></div>
|
||||
<div className="pi-design-notes"><p><b>01</b> 신청한 포지션과 실제 플레이 기록을 구분합니다.</p><p><b>02</b> 최근 챔피언과 누적 숙련도를 따로 보여줍니다.</p><p><b>03</b> 경기수와 기준일을 펼치기 없이 표시합니다.</p></div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user