feat: implement main pages and auction system

- Set up React Router with routes for Home, Match Detail, and Auction pages
- Integrate Tailwind CSS and daisyUI for application styling
- Implement match management UI components using mock data
- Add auction team-building simulation logic and associated types
- Update project configuration to support the new UI framework
This commit is contained in:
dahyeon authored and 박다현 (Dahyeon Park) committed 2026-04-15 01:35:11 +09:00
1 parent 928d68cf00
commit e623715ea5
19 files changed
+2499 -466

No files matched your search

+605
View File
@@ -0,0 +1,605 @@
import { useEffect, useRef, useState } from "react";
import { useParams, Link } from "react-router";
import { createMockAuction } from "../auction-mock";
import type {
AuctionState,
AuctionPlayer,
AuctionTeam,
} from "../auction-types";
import { positionIcon, positionLabel, type Position } from "../mock";
// -- 티어 색상 --
function tierColor(tier: string): string {
if (tier.startsWith("챌린저")) return "text-amber-400";
if (tier.startsWith("그랜드마스터")) return "text-red-400";
if (tier.startsWith("마스터")) return "text-purple-400";
if (tier.startsWith("다이아")) return "text-cyan-400";
if (tier.startsWith("에메랄드")) return "text-emerald-400";
if (tier.startsWith("플래티넘")) return "text-teal-300";
if (tier.startsWith("골드")) return "text-yellow-400";
if (tier.startsWith("실버")) return "text-gray-300";
return "text-amber-700";
}
function formatPoints(n: number): string {
return n.toLocaleString();
}
function PosBadge({ pos }: { pos: Position }) {
return (
<span className="inline-flex items-center gap-1.5 text-[11px] font-medium px-1.5 py-0.5 border border-primary/20 text-primary bg-primary/5">
<img
src={positionIcon[pos]}
alt=""
className="w-3.5 h-3.5 object-contain"
/>
<span>{positionLabel[pos]}</span>
</span>
);
}
// -- 타이머 바 --
function TimerBar({ timer, maxTimer }: { timer: number; maxTimer: number }) {
const pct = (timer / maxTimer) * 100;
const urgent = timer <= 5;
return (
<div className="w-full h-1.5 bg-base-content/5">
<div
className={`h-full transition-all duration-1000 linear ${urgent ? "bg-red-500" : "bg-primary"}`}
style={{ width: `${pct}%` }}
/>
</div>
);
}
// -- 팀 패널 --
function TeamPanel({
team,
isActive,
isLeft,
}: {
team: AuctionTeam;
isActive: boolean;
isLeft: boolean;
}) {
const borderColor =
team.side === "blue" ? "border-blue-500/25" : "border-red-500/25";
const accentBar = team.side === "blue" ? "bg-blue-500" : "bg-red-500";
const sideColor = team.side === "blue" ? "text-blue-400" : "text-red-400";
const headerBg = team.side === "blue" ? "bg-blue-500/8" : "bg-red-500/8";
return (
<div
className={`border ${borderColor} bg-base-100 relative ${isActive ? "ring-1 ring-primary/30" : ""}`}
>
<div
className={`absolute ${isLeft ? "left-0" : "right-0"} top-0 bottom-0 w-0.5 ${accentBar}`}
/>
{/* 헤더 */}
<div className={`${headerBg} px-3 py-2 border-b ${borderColor}`}>
<div className="flex items-center justify-between">
<div className="flex items-center gap-2">
<span
className={`text-[11px] font-bold uppercase tracking-wide ${sideColor}`}
>
{team.side === "blue" ? "블루팀" : "레드팀"}
</span>
<span className="text-[10px] text-base-content/30">
팀장: {team.captainName}
</span>
</div>
<span className="text-xs font-bold text-amber-400 tabular-nums">
{formatPoints(team.points)}P
</span>
</div>
</div>
{/* 멤버 목록 */}
<div className="divide-y divide-base-content/5">
{team.members.length === 0 ? (
<div className="px-3 py-6 text-center text-[11px] text-base-content/20">
아직 멤버가 없습니다
</div>
) : (
team.members.map((m) => (
<div key={m.id} className="px-3 py-1.5 flex items-center gap-2">
<div className="w-6 h-6 bg-base-content/10 overflow-hidden shrink-0">
<img
src={`https://ddragon.leagueoflegends.com/cdn/16.7.1/img/profileicon/${m.profileIconId}.png`}
alt=""
className="w-full h-full object-cover"
loading="lazy"
/>
</div>
<div className="flex-1 min-w-0">
<span className="text-[12px] font-medium text-base-content truncate block leading-tight">
{m.summonerName}
</span>
</div>
<PosBadge pos={m.assignedPosition} />
<span className="text-[10px] text-amber-400/60 tabular-nums w-8 text-right">
{m.cost}
</span>
</div>
))
)}
{/* 빈 슬롯 */}
{Array.from({ length: 4 - team.members.length }).map((_, i) => (
<div
key={`empty-${i}`}
className="px-3 py-1.5 h-[34px] flex items-center"
>
<div className="w-6 h-6 border border-dashed border-base-content/8 shrink-0" />
<span className="ml-2 text-[10px] text-base-content/10">—</span>
</div>
))}
</div>
</div>
);
}
// -- 현재 경매 선수 카드 --
function PlayerSpotlight({
player,
phase,
currentBid,
currentBidder,
}: {
player: AuctionPlayer;
phase: AuctionState["phase"];
currentBid: number;
currentBidder: "blue" | "red" | null;
}) {
const winRate =
player.recentStats.games > 0
? Math.round((player.recentStats.wins / player.recentStats.games) * 100)
: 0;
const kdaRatio =
player.recentStats.kda.deaths > 0
? (
(player.recentStats.kda.kills + player.recentStats.kda.assists) /
player.recentStats.kda.deaths
).toFixed(2)
: "Perfect";
return (
<div className="border border-base-content/10 bg-base-100">
{/* 선수 프로필 */}
<div className="p-5 border-b border-base-content/8">
<div className="flex items-start gap-4">
<div className="w-16 h-16 bg-base-content/10 overflow-hidden shrink-0">
<img
src={`https://ddragon.leagueoflegends.com/cdn/16.7.1/img/profileicon/${player.profileIconId}.png`}
alt=""
className="w-full h-full object-cover"
/>
</div>
<div className="flex-1">
<div className="flex items-center gap-2 mb-1">
<h3 className="text-lg font-bold text-base-content leading-tight">
{player.summonerName}
</h3>
<span className="text-[10px] text-base-content/25">
#{player.tag}
</span>
</div>
<div className="flex items-center gap-1.5 text-[11px] mb-2">
<span className="text-base-content/25">
{player.tier.previousSeason}
</span>
<span className="text-base-content/15">→</span>
<span className={`font-bold ${tierColor(player.tier.current)}`}>
{player.tier.current}
</span>
<span
className={`text-[10px] ${tierColor(player.tier.peak)} opacity-50`}
>
({player.tier.peak})
</span>
</div>
<div className="flex items-center gap-1.5">
<PosBadge pos={player.mainPosition} />
<span className="inline-flex items-center gap-0.5 text-[11px] px-1.5 py-0.5 border border-base-content/8 text-base-content/35">
<img
src={positionIcon[player.subPosition]}
alt=""
className="w-3.5 h-3.5 object-contain inline"
/>{" "}
{positionLabel[player.subPosition]}
</span>
</div>
</div>
</div>
</div>
{/* 스탯 그리드 */}
<div className="grid grid-cols-2 divide-x divide-base-content/5">
{/* 숙련도 */}
<div className="p-4">
<h4 className="text-[10px] font-bold uppercase tracking-wider text-base-content/30 mb-2.5">
숙련도 높은 챔피언
</h4>
<div className="space-y-2">
{player.masteries.map((m) => (
<div key={m.championId} className="flex items-center gap-2">
<div className="w-7 h-7 bg-base-content/10 overflow-hidden shrink-0">
<img
src={`https://ddragon.leagueoflegends.com/cdn/16.7.1/img/champion/${m.championId}.png`}
alt={m.championName}
className="w-full h-full object-cover"
loading="lazy"
/>
</div>
<div className="flex-1 min-w-0">
<div className="text-[12px] font-medium text-base-content truncate">
{m.championName}
</div>
<div className="text-[10px] text-base-content/25">
Lv.{m.level} · {(m.points / 1000).toFixed(0)}K
</div>
</div>
</div>
))}
</div>
</div>
{/* 최근 전적 */}
<div className="p-4">
<h4 className="text-[10px] font-bold uppercase tracking-wider text-base-content/30 mb-2.5">
최근 솔로랭크
</h4>
<div className="space-y-2">
<div className="flex items-baseline justify-between">
<span className="text-[11px] text-base-content/40">승률</span>
<span
className={`text-sm font-bold tabular-nums ${winRate >= 55 ? "text-blue-400" : winRate >= 50 ? "text-base-content" : "text-red-400"}`}
>
{winRate}%
</span>
</div>
<div className="flex items-baseline justify-between">
<span className="text-[11px] text-base-content/40">전적</span>
<span className="text-[12px] text-base-content/60 tabular-nums">
<span className="text-blue-400">
{player.recentStats.wins}W
</span>{" "}
<span className="text-red-400">
{player.recentStats.losses}L
</span>
</span>
</div>
<div className="flex items-baseline justify-between">
<span className="text-[11px] text-base-content/40">KDA</span>
<span className="text-[12px] text-base-content/60 tabular-nums">
{player.recentStats.kda.kills}/{player.recentStats.kda.deaths}/
{player.recentStats.kda.assists}
<span
className={`ml-1 font-bold ${Number(kdaRatio) >= 3 ? "text-emerald-400" : "text-base-content/50"}`}
>
({kdaRatio})
</span>
</span>
</div>
<div className="flex items-baseline justify-between">
<span className="text-[11px] text-base-content/40">평균 CS</span>
<span className="text-[12px] text-base-content/60 tabular-nums">
{player.recentStats.avgCs}
</span>
</div>
</div>
</div>
</div>
{/* 현재 입찰 상태 */}
{(phase === "bidding" || phase === "sold") && (
<div className="border-t border-base-content/8 px-4 py-3 bg-base-content/[0.02]">
<div className="flex items-center justify-between">
<span className="text-[11px] text-base-content/30 uppercase tracking-wider font-semibold">
{phase === "sold" ? "낙찰가" : "현재 입찰가"}
</span>
<div className="flex items-center gap-2">
{currentBidder && (
<span
className={`text-[10px] font-bold uppercase ${currentBidder === "blue" ? "text-blue-400" : "text-red-400"}`}
>
{currentBidder === "blue" ? "블루" : "레드"}
</span>
)}
<span className="text-lg font-black text-amber-400 tabular-nums">
{currentBid > 0 ? formatPoints(currentBid) : "—"}
</span>
</div>
</div>
</div>
)}
</div>
);
}
// -- 입찰 컨트롤 --
function BidControls({
state,
onBid,
}: {
state: AuctionState;
onBid: (side: "blue" | "red", amount: number) => void;
}) {
const [bidAmount, setBidAmount] = useState(100);
const minBid = state.currentBid + 10;
useEffect(() => {
setBidAmount(Math.max(minBid, Math.ceil(minBid / 10) * 10));
}, [state.currentBid]);
if (state.phase !== "bidding") return null;
const presets = [50, 100, 150, 200, 300, 500];
return (
<div className="border border-base-content/10 bg-base-100 p-4">
<div className="flex items-center gap-2 mb-3 flex-wrap">
{presets.map((p) => (
<button
key={p}
onClick={() => setBidAmount(Math.max(minBid, p))}
className={`text-[11px] px-2.5 py-1 border transition-colors ${
bidAmount === p
? "border-primary/40 bg-primary/10 text-primary"
: "border-base-content/10 text-base-content/40 hover:border-base-content/20"
}`}
>
{p}P
</button>
))}
<input
type="number"
value={bidAmount}
onChange={(e) =>
setBidAmount(Math.max(minBid, Number(e.target.value)))
}
min={minBid}
className="w-20 text-xs px-2 py-1 border border-base-content/10 bg-transparent text-base-content tabular-nums text-right focus:outline-none focus:border-primary/30"
/>
</div>
<div className="grid grid-cols-2 gap-2">
<button
onClick={() => onBid("blue", bidAmount)}
disabled={
bidAmount > state.teams[0].points || bidAmount <= state.currentBid
}
className="py-2 text-xs font-bold uppercase tracking-wide border border-blue-500/30 bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 disabled:opacity-30 disabled:cursor-not-allowed transition-colors"
>
블루 입찰 ({formatPoints(bidAmount)}P)
</button>
<button
onClick={() => onBid("red", bidAmount)}
disabled={
bidAmount > state.teams[1].points || bidAmount <= state.currentBid
}
className="py-2 text-xs font-bold uppercase tracking-wide border border-red-500/30 bg-red-500/10 text-red-400 hover:bg-red-500/20 disabled:opacity-30 disabled:cursor-not-allowed transition-colors"
>
레드 입찰 ({formatPoints(bidAmount)}P)
</button>
</div>
</div>
);
}
// -- 입찰 로그 --
function BidLog({ bids }: { bids: AuctionState["bids"] }) {
const endRef = useRef<HTMLDivElement>(null);
useEffect(() => {
endRef.current?.scrollIntoView({ behavior: "smooth" });
}, [bids.length]);
if (bids.length === 0) return null;
return (
<div className="border border-base-content/10 bg-base-100 overflow-hidden">
<div className="px-3 py-1.5 border-b border-base-content/8 bg-base-200/40">
<span className="text-[10px] font-bold uppercase tracking-wider text-base-content/30">
입찰 기록
</span>
</div>
<div className="max-h-28 overflow-y-auto p-2 space-y-0.5">
{bids.map((b, i) => (
<div key={i} className="flex items-center gap-2 text-[11px]">
<span
className={`font-bold uppercase ${b.side === "blue" ? "text-blue-400" : "text-red-400"}`}
>
{b.side === "blue" ? "블루" : "레드"}
</span>
<span className="text-base-content/30">→</span>
<span className="text-amber-400 tabular-nums font-semibold">
{formatPoints(b.amount)}P
</span>
</div>
))}
<div ref={endRef} />
</div>
</div>
);
}
// -- 메인 --
export default function AuctionPage() {
const { id } = useParams();
const [state, setState] = useState<AuctionState | null>(null);
const auctionRef = useRef<ReturnType<typeof createMockAuction> | null>(null);
useEffect(() => {
const auction = createMockAuction((newState) => {
setState({ ...newState });
});
auctionRef.current = auction;
auction.start();
return () => {
auction.destroy();
};
}, [id]);
if (!state) {
return (
<main className="max-w-5xl mx-auto px-4 py-20 text-center">
<span className="text-sm text-base-content/40">연결 중...</span>
</main>
);
}
const handleBid = (side: "blue" | "red", amount: number) => {
auctionRef.current?.bid(side, amount);
};
const phaseLabel: Record<AuctionState["phase"], string> = {
waiting: "경매 준비 중...",
presenting: "다음 선수 등장",
bidding: "입찰 진행 중",
sold: "낙찰!",
complete: "경매 완료",
};
return (
<main className="max-w-5xl mx-auto px-4 sm:px-6 py-6">
{/* 뒤로가기 */}
<Link
to={`/match/${id}`}
className="inline-flex items-center gap-1 text-xs text-base-content/40 hover:text-base-content transition-colors mb-4"
>
<svg
xmlns="http://www.w3.org/2000/svg"
className="h-3.5 w-3.5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M15 19l-7-7 7-7"
/>
</svg>
내전 상세로
</Link>
{/* 경매 헤더 */}
<div className="mb-5 flex items-center justify-between flex-wrap gap-2">
<div>
<h1 className="text-xl font-bold text-base-content leading-tight">
경매 팀빌딩
</h1>
<p className="text-[11px] text-base-content/30 mt-0.5">
{state.currentPlayerIndex + 1} / {state.totalPlayers} 선수
</p>
</div>
<div className="flex items-center gap-2">
<span
className={`inline-flex items-center text-[11px] font-semibold px-2 py-1 border ${
state.phase === "bidding"
? "border-green-500/20 bg-green-500/10 text-green-400"
: state.phase === "sold"
? "border-amber-500/20 bg-amber-500/10 text-amber-400"
: "border-base-content/10 bg-base-content/5 text-base-content/40"
}`}
>
{phaseLabel[state.phase]}
</span>
{state.phase === "bidding" && (
<span
className={`text-lg font-black tabular-nums ${state.timer <= 5 ? "text-red-500" : "text-base-content"}`}
>
{state.timer}s
</span>
)}
</div>
</div>
{/* 타이머 바 */}
{state.phase === "bidding" && (
<TimerBar timer={state.timer} maxTimer={state.maxTimer} />
)}
{/* 메인 3컬럼 */}
<div className="flex flex-col lg:flex-row gap-4 mt-4">
{/* 블루팀 */}
<div className="w-full lg:w-56 shrink-0">
<TeamPanel
team={state.teams[0]}
isActive={state.currentBidder === "blue"}
isLeft
/>
</div>
{/* 중앙: 선수 카드 */}
<div className="flex-1 min-w-0 space-y-4">
{state.phase === "waiting" && (
<div className="border border-base-content/10 bg-base-100 p-12 text-center">
<div className="text-base-content/20 text-sm">
경매가 곧 시작됩니다...
</div>
</div>
)}
{state.phase === "complete" && (
<div className="border border-base-content/10 bg-base-100 p-8 text-center">
<div className="text-lg font-bold text-base-content mb-2">
경매 완료
</div>
<div className="text-xs text-base-content/40">
모든 선수가 팀에 배정되었습니다.
</div>
<Link
to={`/match/${id}`}
className="btn btn-primary btn-sm mt-4 px-6 text-[11px]"
>
결과 확인
</Link>
</div>
)}
{state.currentPlayer &&
(state.phase === "presenting" ||
state.phase === "bidding" ||
state.phase === "sold") && (
<>
<PlayerSpotlight
player={state.currentPlayer}
phase={state.phase}
currentBid={state.currentBid}
currentBidder={state.currentBidder}
/>
{state.phase === "sold" && state.currentBidder && (
<div
className={`text-center py-3 border text-sm font-bold ${
state.currentBidder === "blue"
? "border-blue-500/20 bg-blue-500/8 text-blue-400"
: "border-red-500/20 bg-red-500/8 text-red-400"
}`}
>
{state.currentBidder === "blue" ? "블루팀" : "레드팀"} 낙찰
— {formatPoints(state.currentBid)}P
</div>
)}
<BidControls state={state} onBid={handleBid} />
<BidLog bids={state.bids} />
</>
)}
</div>
{/* 레드팀 */}
<div className="w-full lg:w-56 shrink-0">
<TeamPanel
team={state.teams[1]}
isActive={state.currentBidder === "red"}
isLeft={false}
/>
</div>
</div>
</main>
);
}
+162
View File
@@ -0,0 +1,162 @@
import { Link } from "react-router";
import {
nextMatchSummary,
upcomingMatches,
pastMatches,
} from "../mock";
function StatusBadge({ status }: { status: string }) {
const styles: Record<string, string> = {
"모집 중": "bg-green-500/15 text-green-500 border-green-500/20",
"모집 완료": "bg-amber-500/15 text-amber-500 border-amber-500/20",
예정: "bg-blue-500/15 text-blue-400 border-blue-500/20",
};
return (
<span
className={`inline-flex items-center text-[11px] font-semibold px-1.5 py-0.5 border ${styles[status] ?? "bg-base-content/10 text-base-content/50 border-base-content/10"}`}
>
{status}
</span>
);
}
function MapBadge({ map }: { map: string }) {
return (
<span className="inline-flex items-center text-[11px] px-1.5 py-0.5 border border-base-content/10 text-base-content/50">
{map}
</span>
);
}
export default function HomePage() {
return (
<main className="max-w-5xl mx-auto px-4 sm:px-6">
{/* 다음 내전 (Hero) */}
<section className="pt-8 pb-6">
<h2 className="text-xs font-bold text-base-content/40 uppercase tracking-widest mb-3">
다음 내전
</h2>
<Link to={`/match/${nextMatchSummary.id}`} className="block group">
<div className="border border-base-content/10 bg-base-200/50 hover:bg-base-200 transition-colors">
<div className="p-5 sm:p-6">
<div className="flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4">
<div className="space-y-2.5">
<div className="flex items-center gap-2.5 flex-wrap">
<h3 className="text-xl sm:text-2xl font-bold text-base-content leading-tight">
{nextMatchSummary.title}
</h3>
<StatusBadge status={nextMatchSummary.status} />
</div>
<p className="text-sm text-base-content/50 max-w-xl leading-relaxed">
{nextMatchSummary.description}
</p>
<div className="flex items-center gap-3 text-xs text-base-content/40 flex-wrap">
<span className="flex items-center gap-1">
<svg xmlns="http://www.w3.org/2000/svg" className="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>
{nextMatchSummary.date} {nextMatchSummary.time}
</span>
<span className="text-base-content/15">|</span>
<span className="flex items-center gap-1">
<svg xmlns="http://www.w3.org/2000/svg" className="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z" /></svg>
{nextMatchSummary.participants}/{nextMatchSummary.maxParticipants}명
</span>
<span className="text-base-content/15">|</span>
<MapBadge map={nextMatchSummary.map} />
</div>
</div>
<div className="sm:shrink-0">
<span className="btn btn-primary btn-sm px-6 text-xs font-semibold">
상세 보기
</span>
</div>
</div>
</div>
</div>
</Link>
</section>
{/* 예정된 내전 */}
<section className="pb-6">
<h2 className="text-xs font-bold text-base-content/40 uppercase tracking-widest mb-3">
예정된 내전
</h2>
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-px bg-base-content/10 border border-base-content/10">
{upcomingMatches.map((match) => (
<Link key={match.id} to={`/match/${match.id}`}>
<div className="bg-base-100 hover:bg-base-200/50 transition-colors cursor-pointer h-full p-4">
<div className="flex items-center justify-between mb-2.5">
<h3 className="text-sm font-bold text-base-content truncate mr-2">
{match.title}
</h3>
<StatusBadge status={match.status} />
</div>
<div className="space-y-1 text-xs text-base-content/40">
<div className="flex items-center gap-1">
<svg xmlns="http://www.w3.org/2000/svg" className="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>
{match.date} {match.time}
</div>
<div className="flex items-center gap-1">
<svg xmlns="http://www.w3.org/2000/svg" className="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z" /></svg>
{match.participants}/{match.maxParticipants}명
</div>
</div>
<div className="mt-2.5">
<MapBadge map={match.map} />
</div>
</div>
</Link>
))}
</div>
</section>
{/* 지난 내전 기록 */}
<section className="pb-12">
<h2 className="text-xs font-bold text-base-content/40 uppercase tracking-widest mb-3">
지난 내전 기록
</h2>
<div className="border border-base-content/10 overflow-x-auto">
<table className="w-full text-left">
<thead>
<tr className="bg-base-200/60 border-b border-base-content/10 text-[11px] uppercase tracking-wider text-base-content/40">
<th className="py-2.5 px-4 font-semibold">날짜</th>
<th className="py-2.5 px-4 font-semibold">내전</th>
<th className="py-2.5 px-4 font-semibold">맵</th>
<th className="py-2.5 px-4 font-semibold">참가</th>
<th className="py-2.5 px-4 font-semibold">결과</th>
</tr>
</thead>
<tbody>
{pastMatches.map((match) => (
<tr
key={match.id}
className="border-b border-base-content/5 last:border-b-0 hover:bg-base-content/[0.02] transition-colors"
>
<td className="py-2.5 px-4 text-xs text-base-content/40 whitespace-nowrap">
{match.date}
</td>
<td className="py-2.5 px-4">
<Link
to={`/match/${match.id}`}
className="text-sm font-medium text-base-content hover:text-primary transition-colors"
>
{match.title}
</Link>
</td>
<td className="py-2.5 px-4">
<MapBadge map={match.map} />
</td>
<td className="py-2.5 px-4 text-xs text-base-content/50">
{match.participants}명
</td>
<td className="py-2.5 px-4 text-xs text-base-content/50">
{match.result}
</td>
</tr>
))}
</tbody>
</table>
</div>
</section>
</main>
);
}
+473
View File
@@ -0,0 +1,473 @@
import { useParams, Link } from "react-router";
import {
getMatchById,
positionLabel,
positionIcon,
type MatchDetail,
type Participant,
type Position,
type Team,
type TierInfo,
} from "../mock";
// -- 포지션 배지 --
function PosBadge({ pos, sub }: { pos: Position; sub?: boolean }) {
return (
<span
className={`inline-flex items-center gap-1.5 text-[11px] font-medium px-1.5 py-0.5 border ${
sub
? "border-base-content/8 text-base-content/35 bg-transparent"
: "border-primary/20 text-primary bg-primary/5"
}`}
>
<img
src={positionIcon[pos]}
alt=""
className="w-3.5 h-3.5 object-contain mr-4px"
/>
<span>{positionLabel[pos]}</span>
</span>
);
}
// -- 티어 색상 --
function tierColor(tier: string): string {
if (tier.startsWith("챌린저")) return "text-amber-400";
if (tier.startsWith("그랜드마스터")) return "text-red-400";
if (tier.startsWith("마스터")) return "text-purple-400";
if (tier.startsWith("다이아")) return "text-cyan-400";
if (tier.startsWith("에메랄드")) return "text-emerald-400";
if (tier.startsWith("플래티넘")) return "text-teal-300";
if (tier.startsWith("골드")) return "text-yellow-400";
if (tier.startsWith("실버")) return "text-gray-300";
return "text-amber-700";
}
// -- 티어 셀 (전시즌 / 현재 / 최고) --
function TierCell({ tier }: { tier: TierInfo }) {
return (
<div className="flex items-center gap-1.5 text-[11px] whitespace-nowrap">
<span className="text-base-content/25">{tier.previousSeason}</span>
<span className="text-base-content/15">→</span>
<span className={`font-bold ${tierColor(tier.current)}`}>
{tier.current}
</span>
<span className={`text-[10px] ${tierColor(tier.peak)} opacity-50`}>
({tier.peak})
</span>
</div>
);
}
// -- 상태 배지 --
function statusBadge(status: MatchDetail["status"]) {
switch (status) {
case "recruiting":
return {
label: "모집 중",
cls: "bg-green-500/15 text-green-500 border-green-500/20",
};
case "team-built":
return {
label: "팀빌딩 완료",
cls: "bg-amber-500/15 text-amber-500 border-amber-500/20",
};
case "finished":
return {
label: "종료",
cls: "bg-base-content/8 text-base-content/40 border-base-content/10",
};
}
}
// -- 참가자 행 --
function ParticipantRow({
p,
index,
assignedPos,
}: {
p: Participant;
index: number;
assignedPos?: Position;
}) {
return (
<tr className="border-b border-base-content/5 last:border-b-0 hover:bg-base-content/[0.02] transition-colors">
<td className="py-2 px-3 text-center text-[11px] text-base-content/30 w-8">
{index + 1}
</td>
<td className="py-2 px-3">
<div className="flex items-center gap-2">
<div className="w-7 h-7 bg-base-content/10 overflow-hidden shrink-0">
<img
src={`https://ddragon.leagueoflegends.com/cdn/16.7.1/img/profileicon/${p.profileIconId}.png`}
alt=""
className="w-full h-full object-cover"
loading="lazy"
/>
</div>
<div className="min-w-0">
<span className="font-medium text-[13px] text-base-content truncate block leading-tight">
{p.summonerName}
</span>
<span className="text-[10px] text-base-content/25 leading-tight">
#{p.tag}
</span>
</div>
</div>
</td>
<td className="py-2 px-3">
<TierCell tier={p.tier} />
</td>
{assignedPos ? (
<td className="py-2 px-3">
<PosBadge pos={assignedPos} />
</td>
) : (
<>
<td className="py-2 px-3">
<PosBadge pos={p.mainPosition} />
</td>
<td className="py-2 px-3">
<PosBadge pos={p.subPosition} sub />
</td>
</>
)}
</tr>
);
}
// -- 참가자 테이블 (팀빌딩 전) --
function ParticipantTable({ participants }: { participants: Participant[] }) {
return (
<div className="overflow-x-auto">
<table className="w-full text-left">
<thead>
<tr className="border-b border-base-content/10 bg-base-200/40 text-[11px] uppercase tracking-wider text-base-content/35 font-semibold">
<th className="py-2 px-3 w-8">#</th>
<th className="py-2 px-3">소환사</th>
<th className="py-2 px-3">전 시즌 → 현재 (최고)</th>
<th className="py-2 px-3">주 포지션</th>
<th className="py-2 px-3">부 포지션</th>
</tr>
</thead>
<tbody>
{participants.map((p, i) => (
<ParticipantRow key={p.id} p={p} index={i} />
))}
</tbody>
</table>
</div>
);
}
// -- 팀 카드 (팀빌딩 후) --
function TeamCard({
team,
side,
isWinner,
}: {
team: Team;
side: "blue" | "red";
isWinner?: boolean;
}) {
const borderColor =
side === "blue" ? "border-blue-500/25" : "border-red-500/25";
const headerBg = side === "blue" ? "bg-blue-500/8" : "bg-red-500/8";
const sideColor = side === "blue" ? "text-blue-400" : "text-red-400";
const accentBar = side === "blue" ? "bg-blue-500" : "bg-red-500";
return (
<div
className={`border ${borderColor} overflow-hidden bg-base-100 relative`}
>
<div className={`absolute left-0 top-0 bottom-0 w-0.5 ${accentBar}`} />
<div
className={`${headerBg} px-4 py-2 flex items-center justify-between border-b ${borderColor}`}
>
<div className="flex items-center gap-2">
<span
className={`text-xs font-bold uppercase tracking-wide ${sideColor}`}
>
{team.name}
</span>
{isWinner && (
<span className="inline-flex items-center text-[10px] font-bold px-1.5 py-0.5 bg-amber-500/15 text-amber-400 border border-amber-500/20">
WIN
</span>
)}
</div>
</div>
<table className="w-full text-left">
<thead>
<tr className="border-b border-base-content/8 bg-base-200/30 text-[11px] uppercase tracking-wider text-base-content/35 font-semibold">
<th className="py-2 px-3 w-8">#</th>
<th className="py-2 px-3">소환사</th>
<th className="py-2 px-3">전 시즌 → 현재 (최고)</th>
<th className="py-2 px-3">포지션</th>
</tr>
</thead>
<tbody>
{team.participants.map((p, i) => (
<ParticipantRow
key={p.id}
p={p}
index={i}
assignedPos={p.assignedPosition}
/>
))}
</tbody>
</table>
</div>
);
}
// -- 사이드바 카드 --
function SideCard({
title,
children,
}: {
title: string;
children: React.ReactNode;
}) {
return (
<div className="border border-base-content/10 bg-base-100 overflow-hidden">
<div className="px-4 py-2 border-b border-base-content/10 bg-base-200/40">
<h3 className="text-[11px] font-bold uppercase tracking-wider text-base-content/40">
{title}
</h3>
</div>
<div className="p-4">{children}</div>
</div>
);
}
// -- 메인 --
export default function MatchDetailPage() {
const { id } = useParams();
const match = getMatchById(Number(id));
if (!match) {
return (
<main className="max-w-5xl mx-auto px-4 py-20 text-center">
<h2 className="text-lg font-bold mb-2">내전을 찾을 수 없습니다</h2>
<Link to="/" className="btn btn-ghost btn-sm mt-4">
홈으로 돌아가기
</Link>
</main>
);
}
const si = statusBadge(match.status);
return (
<main className="max-w-5xl mx-auto px-4 sm:px-6 py-6">
{/* 뒤로가기 */}
<Link
to="/"
className="inline-flex items-center gap-1 text-xs text-base-content/40 hover:text-base-content transition-colors mb-5"
>
<svg
xmlns="http://www.w3.org/2000/svg"
className="h-3.5 w-3.5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M15 19l-7-7 7-7"
/>
</svg>
목록으로
</Link>
{/* 헤더 */}
<div className="mb-6 pb-5 border-b border-base-content/8">
<div className="flex items-center gap-2.5 flex-wrap mb-2">
<h1 className="text-xl sm:text-2xl font-bold text-base-content leading-tight">
{match.title}
</h1>
<span
className={`inline-flex items-center text-[11px] font-semibold px-1.5 py-0.5 border ${si.cls}`}
>
{si.label}
</span>
</div>
<p className="text-sm text-base-content/50 mb-2.5">
{match.description}
</p>
<div className="flex items-center gap-3 text-xs text-base-content/40 flex-wrap">
<span className="flex items-center gap-1">
<svg
xmlns="http://www.w3.org/2000/svg"
className="h-3.5 w-3.5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
/>
</svg>
{match.date} {match.time}
</span>
<span className="text-base-content/15">|</span>
<span className="flex items-center gap-1">
<svg
xmlns="http://www.w3.org/2000/svg"
className="h-3.5 w-3.5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z"
/>
</svg>
{match.participants.length}/{match.maxParticipants}명
</span>
<span className="text-base-content/15">|</span>
<span className="inline-flex items-center text-[11px] px-1.5 py-0.5 border border-base-content/10 text-base-content/40">
{match.map}
</span>
</div>
</div>
{/* 결과 배너 (종료된 경우) */}
{match.status === "finished" && match.result && (
<div className="mb-6 border border-base-content/10 bg-base-content/[0.02] p-5">
<div className="flex items-center justify-center gap-8">
<div
className={`text-center ${match.result.winner === "블루팀" ? "text-blue-400" : "text-blue-400/30"}`}
>
<div className="text-3xl font-black tabular-nums">
{match.result.blueScore}
</div>
<div className="text-[10px] uppercase tracking-wider mt-0.5 font-semibold">
블루팀
</div>
</div>
<div className="text-base-content/20 text-xs font-bold uppercase tracking-widest">
VS
</div>
<div
className={`text-center ${match.result.winner === "레드팀" ? "text-red-400" : "text-red-400/30"}`}
>
<div className="text-3xl font-black tabular-nums">
{match.result.redScore}
</div>
<div className="text-[10px] uppercase tracking-wider mt-0.5 font-semibold">
레드팀
</div>
</div>
</div>
<div className="text-center mt-3 text-[11px] font-bold text-amber-400 uppercase tracking-wide">
{match.result.winner} 승리
</div>
</div>
)}
<div className="flex flex-col lg:flex-row gap-5">
{/* 좌측: 참가자 / 팀 */}
<div className="flex-1 min-w-0">
{match.status === "recruiting" ? (
<div className="border border-base-content/10 bg-base-100 overflow-hidden">
<div className="px-4 py-2.5 border-b border-base-content/10 bg-base-200/40 flex items-center justify-between">
<h3 className="text-[11px] font-bold uppercase tracking-wider text-base-content/40">
참가자 ({match.participants.length}/{match.maxParticipants})
</h3>
<button className="btn btn-primary btn-xs px-4 text-[11px] font-semibold">
참가 신청
</button>
</div>
<ParticipantTable participants={match.participants} />
{match.participants.length < match.maxParticipants && (
<div className="px-4 py-2.5 border-t border-base-content/5 text-center bg-base-200/20">
<span className="text-[11px] text-base-content/25">
{match.maxParticipants - match.participants.length}자리 남음
</span>
</div>
)}
</div>
) : (
<div className="space-y-4">
{match.teams?.map((team, i) => (
<TeamCard
key={team.name}
team={team}
side={i === 0 ? "blue" : "red"}
isWinner={
match.status === "finished"
? match.result?.winner === team.name
: undefined
}
/>
))}
</div>
)}
</div>
{/* 우측: 사이드바 */}
<div className="w-full lg:w-64 shrink-0 space-y-4">
{/* 일정 */}
{match.schedule && match.schedule.length > 0 && (
<SideCard title="일정">
<ul className="space-y-2">
{match.schedule.map((s, i) => (
<li key={i} className="flex items-start gap-2.5 text-[13px]">
<span className="font-mono text-[11px] text-base-content/30 w-11 shrink-0 pt-px">
{s.time}
</span>
<span className="text-base-content/60">{s.label}</span>
</li>
))}
</ul>
</SideCard>
)}
{/* 상품 */}
{match.prizes && match.prizes.length > 0 && (
<SideCard title="상품">
<ul className="space-y-1.5">
{match.prizes.map((prize, i) => (
<li
key={i}
className="flex items-start gap-2 text-[13px] text-base-content/60"
>
<span className="text-amber-400 shrink-0 text-xs">▸</span>
<span>{prize}</span>
</li>
))}
</ul>
</SideCard>
)}
{/* 안내사항 */}
{match.notices && match.notices.length > 0 && (
<SideCard title="안내사항">
<ul className="space-y-1.5">
{match.notices.map((notice, i) => (
<li
key={i}
className="flex items-start gap-2 text-[13px] text-base-content/60"
>
<span className="text-base-content/20 shrink-0">•</span>
<span>{notice}</span>
</li>
))}
</ul>
</SideCard>
)}
</div>
</div>
</main>
);
}