feat(web): 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 02:06:42 +09:00
1 parent 7f0f78b4a1
commit 909845a1df
19 files changed
+2499 -466

No files matched your search

+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>
);
}