feat: refresh the home page and separate match event types
Add an inhouse hero, Hall of Fame, rankings, and event-specific schedules. Carry the event type through the API and admin tools, and improve results and player history displays.
This commit is contained in:
1 parent
7e0cd7cb19
commit
664af15255
58 files changed
+2316
-593
No files matched your search
+492
-146
@@ -1,11 +1,23 @@
|
||||
import { useState } from 'react';
|
||||
import { useEffect, useState, type CSSProperties } from 'react';
|
||||
import type {
|
||||
MatchDetailResponse,
|
||||
MatchEventType,
|
||||
MatchSummaryResponse,
|
||||
} from '@lolympus/contracts';
|
||||
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
||||
import { Link, useSearchParams } from 'react-router';
|
||||
import { useMatches, useMatchesPage } from '../api/hooks';
|
||||
import {
|
||||
useCommunityLeaderboard,
|
||||
useDdragonManifest,
|
||||
useMatches,
|
||||
useMatchesPage,
|
||||
} from '../api/hooks';
|
||||
import nextMatchArtwork from '../assets/next-match-hero.webp';
|
||||
import HomeHallOfFame from '../components/HomeHallOfFame';
|
||||
import { championIconUrl, profileIconUrl } from '../lib/ddragon';
|
||||
import { rankLeaderboardByLane } from '../lib/internal-stats-presentation';
|
||||
import { MATCH_EVENT_LABEL } from '../lib/match-event-type';
|
||||
import { LANE_LABELS } from '../lib/riot-history';
|
||||
import { mapIdToLabel } from '../api/mappers';
|
||||
import { DEFAULT_COMMUNITY_ID } from '../config';
|
||||
import {
|
||||
@@ -17,18 +29,34 @@ import {
|
||||
Pill,
|
||||
PlainPage,
|
||||
Skeleton,
|
||||
pageWidthClass,
|
||||
} from '../ui';
|
||||
import {
|
||||
getHistoryMatchTitle,
|
||||
getHomeMatchEnrollment,
|
||||
getHomeMatchSchedule,
|
||||
getNextMatchBanner,
|
||||
HOME_MATCH_STATUS,
|
||||
} from './home-match-presentation';
|
||||
|
||||
const UPCOMING_MATCH_LIST_LIMIT = 4;
|
||||
const HISTORY_MATCH_PAGE_SIZE = 10;
|
||||
const HOME_HISTORY_LIMIT = 5;
|
||||
const HOME_HISTORY_LIMIT = 4;
|
||||
const HOME_RANKING_LIMIT = 5;
|
||||
const DEFAULT_MAP_ID = 11;
|
||||
const RANKING_COLUMNS_CLASS =
|
||||
'grid grid-cols-[1.5rem_minmax(0,1fr)_3rem] items-center gap-3 px-3';
|
||||
/** 순위 카드의 슬라이드 순서. undefined는 종합 순위. */
|
||||
const RANKING_SLIDES = [
|
||||
undefined,
|
||||
'TOP',
|
||||
'JUNGLE',
|
||||
'MIDDLE',
|
||||
'BOTTOM',
|
||||
'UTILITY',
|
||||
] as const;
|
||||
const RANKING_SLIDE_INTERVAL_MS = 5000;
|
||||
const GENERIC_MATCH_NAME = /^(?:정기\s*)?내전$/u;
|
||||
|
||||
const DECISION_LABELS = {
|
||||
walkover: '부전승',
|
||||
@@ -37,70 +65,75 @@ const DECISION_LABELS = {
|
||||
draw: '무승부',
|
||||
} as const;
|
||||
|
||||
function NextMatch({ match }: { match?: MatchDetailResponse }) {
|
||||
if (!match) {
|
||||
return (
|
||||
<h1 className="text-sm font-medium text-content-muted">
|
||||
예정된 내전이 없습니다
|
||||
</h1>
|
||||
);
|
||||
}
|
||||
|
||||
function NextMatch({ match }: { match: MatchDetailResponse }) {
|
||||
const schedule = getHomeMatchSchedule(match.scheduledAt);
|
||||
const enrollment = getHomeMatchEnrollment(match);
|
||||
const href = `/match/${match._id}`;
|
||||
const { title, status, capacity, canApply } = getNextMatchBanner(match);
|
||||
|
||||
return (
|
||||
<header className="flex flex-col gap-3 rounded-xl border border-line bg-card p-4 sm:flex-row sm:items-center sm:justify-between sm:gap-6 sm:p-5">
|
||||
<div className="min-w-0">
|
||||
<p className="flex flex-wrap items-baseline gap-x-2 gap-y-0.5 text-sm text-content-muted">
|
||||
<span className="font-semibold">다음 내전</span>
|
||||
{schedule && (
|
||||
<time
|
||||
dateTime={match.scheduledAt}
|
||||
className="tabular font-semibold text-content"
|
||||
>
|
||||
{schedule.date} · {schedule.time}
|
||||
</time>
|
||||
)}
|
||||
</p>
|
||||
<h1 className="mt-1 break-words text-xl font-bold leading-snug sm:text-2xl">
|
||||
{match.title}
|
||||
</h1>
|
||||
<p className="tabular mt-1 flex flex-wrap items-baseline gap-x-2 gap-y-0.5 text-sm text-content-muted">
|
||||
{match.status !== 'recruiting' && (
|
||||
<span>{HOME_MATCH_STATUS[match.status]} ·</span>
|
||||
)}
|
||||
<span>{enrollment.capacity} ·</span>
|
||||
<strong className="font-semibold text-content">
|
||||
{enrollment.label}
|
||||
</strong>
|
||||
{match.mapId !== DEFAULT_MAP_ID && (
|
||||
<span>· {mapIdToLabel(match.mapId)}</span>
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
{enrollment.canApply ? (
|
||||
<div className="shrink-0">
|
||||
<Button label="참가 신청" variant="primary" size="md" href={href} />
|
||||
<Link
|
||||
to={`/match/${match._id}`}
|
||||
aria-labelledby="next-match-label next-match-title"
|
||||
aria-describedby="next-match-schedule next-match-status"
|
||||
className="lts-home-hero group relative isolate block overflow-hidden focus-visible:-outline-offset-4 focus-visible:outline-primary"
|
||||
>
|
||||
<img
|
||||
src={nextMatchArtwork}
|
||||
alt=""
|
||||
fetchPriority="high"
|
||||
className="absolute inset-y-0 left-1/2 -z-20 h-full w-full max-w-[112rem] -translate-x-1/2 object-cover object-[75%_center] md:object-center"
|
||||
/>
|
||||
<div
|
||||
className={`${pageWidthClass()} flex min-h-[16rem] items-center py-8 md:min-h-[clamp(22rem,29vw,30rem)] md:py-12`}
|
||||
>
|
||||
<div className="w-full max-w-xl">
|
||||
<p
|
||||
id="next-match-label"
|
||||
className="text-sm font-semibold text-white/80 md:text-base"
|
||||
>
|
||||
다음 내전
|
||||
</p>
|
||||
<h1
|
||||
id="next-match-title"
|
||||
className="mt-3 text-[clamp(2rem,5vw,3.5rem)] font-extrabold leading-[1.15] tracking-tight text-white [overflow-wrap:anywhere] group-hover:underline group-hover:decoration-2 group-hover:underline-offset-8"
|
||||
>
|
||||
{title}
|
||||
</h1>
|
||||
<p
|
||||
id="next-match-schedule"
|
||||
className="tabular mt-4 text-base font-semibold text-white/90 md:mt-6 md:text-xl"
|
||||
>
|
||||
{schedule ? (
|
||||
<time dateTime={match.scheduledAt}>
|
||||
{schedule.date} {schedule.time}
|
||||
</time>
|
||||
) : '일정 미정'}
|
||||
</p>
|
||||
<p id="next-match-status" className="tabular mt-3 text-sm text-white/85 md:text-base">
|
||||
<strong className={canApply ? 'font-semibold text-brand-coral' : 'font-semibold'}>
|
||||
{status}
|
||||
</strong>
|
||||
{' · '}
|
||||
{capacity}
|
||||
{match.mapId !== DEFAULT_MAP_ID && (
|
||||
<> · {mapIdToLabel(match.mapId)}</>
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<Link
|
||||
to={href}
|
||||
className="inline-flex min-h-10 w-fit shrink-0 items-center gap-1 text-sm font-semibold text-content hover:underline"
|
||||
>
|
||||
내전 보기
|
||||
<ChevronRight className="size-4" aria-hidden="true" />
|
||||
</Link>
|
||||
)}
|
||||
</header>
|
||||
</div>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
function UpcomingMatches({ matches }: { matches: MatchDetailResponse[] }) {
|
||||
function UpcomingMatches({
|
||||
matches,
|
||||
title = '이어지는 내전',
|
||||
}: {
|
||||
matches: MatchDetailResponse[];
|
||||
title?: string;
|
||||
}) {
|
||||
return (
|
||||
<Panel>
|
||||
<PanelHeader title="이어지는 내전" />
|
||||
<PanelHeader title={title} />
|
||||
<ul className="divide-y divide-line">
|
||||
{matches.map((match) => {
|
||||
const schedule = getHomeMatchSchedule(match.scheduledAt);
|
||||
@@ -117,7 +150,7 @@ function UpcomingMatches({ matches }: { matches: MatchDetailResponse[] }) {
|
||||
>
|
||||
{schedule?.compact ?? '일정 미정'}
|
||||
</time>
|
||||
<h3 className="col-start-1 mt-0.5 truncate text-[15px] font-semibold text-content group-hover:underline sm:col-start-2 sm:row-start-1 sm:mt-0">
|
||||
<h3 className="col-start-1 mt-0.5 truncate text-[15px] font-semibold group-hover:underline sm:col-start-2 sm:row-start-1 sm:mt-0">
|
||||
{match.title}
|
||||
</h3>
|
||||
<p className="tabular col-start-1 mt-1 text-[13px] text-content-muted sm:col-start-3 sm:row-start-1 sm:mt-0">
|
||||
@@ -139,11 +172,29 @@ function UpcomingMatches({ matches }: { matches: MatchDetailResponse[] }) {
|
||||
);
|
||||
}
|
||||
|
||||
function HistoryResult({ match }: { match: MatchSummaryResponse }) {
|
||||
function HistoryResult({
|
||||
match,
|
||||
showTeamNames = false,
|
||||
}: {
|
||||
match: MatchSummaryResponse;
|
||||
showTeamNames?: boolean;
|
||||
}) {
|
||||
const result = match.historyResult;
|
||||
const teamLabelClass = `min-w-0 break-words text-content-muted${showTeamNames ? '' : ' md:truncate'}`;
|
||||
if (match.status === 'finished' && result) {
|
||||
switch (result.type) {
|
||||
case 'score': {
|
||||
if (showTeamNames && result.teamAName && result.teamBName) {
|
||||
return (
|
||||
<span className="break-words text-content">
|
||||
{result.teamAName}{' '}
|
||||
<strong className="tabular whitespace-nowrap font-bold">
|
||||
{result.teamAWins}–{result.teamBWins}
|
||||
</strong>{' '}
|
||||
{result.teamBName}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
const label = result.winnerTeamName
|
||||
? `${result.winnerTeamName} 승`
|
||||
: undefined;
|
||||
@@ -154,7 +205,7 @@ function HistoryResult({ match }: { match: MatchSummaryResponse }) {
|
||||
</strong>
|
||||
{label && (
|
||||
<span
|
||||
className="min-w-0 break-words text-content-muted md:truncate"
|
||||
className={teamLabelClass}
|
||||
title={label}
|
||||
>
|
||||
{label}
|
||||
@@ -171,7 +222,7 @@ function HistoryResult({ match }: { match: MatchSummaryResponse }) {
|
||||
{result.teamNames.length > 1 ? '공동 1위' : '우승'}
|
||||
</strong>
|
||||
<span
|
||||
className="min-w-0 break-words text-content-muted md:truncate"
|
||||
className={teamLabelClass}
|
||||
title={label}
|
||||
>
|
||||
{label}
|
||||
@@ -187,7 +238,7 @@ function HistoryResult({ match }: { match: MatchSummaryResponse }) {
|
||||
</strong>
|
||||
{result.winnerTeamName && (
|
||||
<span
|
||||
className="min-w-0 break-words text-content-muted md:truncate"
|
||||
className={teamLabelClass}
|
||||
title={result.winnerTeamName}
|
||||
>
|
||||
{result.winnerTeamName}
|
||||
@@ -227,8 +278,8 @@ function HistoryTableColumns() {
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">일정</th>
|
||||
<th scope="col">내전</th>
|
||||
<th scope="col">결과</th>
|
||||
<th scope="col">대회</th>
|
||||
<th scope="col">상태·결과</th>
|
||||
<th scope="col" className="!text-right">
|
||||
참가
|
||||
</th>
|
||||
@@ -277,9 +328,15 @@ function HistoryRecordsSkeleton({ limit }: { limit: number }) {
|
||||
);
|
||||
}
|
||||
|
||||
function HistoryRecords({ matches }: { matches: MatchSummaryResponse[] }) {
|
||||
function HistoryRecords({
|
||||
matches,
|
||||
eventLabel,
|
||||
}: {
|
||||
matches: MatchSummaryResponse[];
|
||||
eventLabel: string;
|
||||
}) {
|
||||
if (matches.length === 0) {
|
||||
return <EmptyNote size="sm" title="아직 내전 기록이 없습니다." />;
|
||||
return <EmptyNote size="sm" title={`아직 ${eventLabel} 기록이 없습니다.`} />;
|
||||
}
|
||||
|
||||
const rows = matches.map((match) => {
|
||||
@@ -352,6 +409,261 @@ function HistoryRecords({ matches }: { matches: MatchSummaryResponse[] }) {
|
||||
);
|
||||
}
|
||||
|
||||
function RecentMatchResults({ matches }: { matches: MatchSummaryResponse[] }) {
|
||||
if (matches.length === 0) {
|
||||
return <EmptyNote size="sm" title="아직 종료된 내전이 없습니다." />;
|
||||
}
|
||||
|
||||
return (
|
||||
<ul className="divide-y divide-line border-y border-line">
|
||||
{matches.map((match) => {
|
||||
const schedule = getHomeMatchSchedule(match.scheduledAt);
|
||||
const name = getHistoryMatchTitle(match.title, schedule);
|
||||
// 이름이 "내전"뿐이면 행을 구분할 수 없으므로 일정을 제목으로 올린다.
|
||||
const datedTitle = schedule && GENERIC_MATCH_NAME.test(name.trim());
|
||||
const details = [
|
||||
!datedTitle && (schedule?.compact ?? '일정 미정'),
|
||||
match.teams.length > 2 && `${match.teams.length}팀`,
|
||||
match.mapId !== DEFAULT_MAP_ID && mapIdToLabel(match.mapId),
|
||||
].filter(Boolean);
|
||||
return (
|
||||
<li key={match._id}>
|
||||
<Link
|
||||
to={`/match/${match._id}`}
|
||||
className="group grid gap-1 px-2 py-3.5 transition-colors hover:bg-sunken focus-visible:-outline-offset-2 md:grid-cols-[minmax(0,1fr)_auto] md:items-center md:gap-4"
|
||||
>
|
||||
<div className="min-w-0">
|
||||
<p className="tabular break-words text-[15px] font-semibold leading-snug text-content group-hover:underline">
|
||||
{datedTitle ? (
|
||||
<>
|
||||
<time dateTime={match.scheduledAt}>{schedule.compact}</time>{' '}
|
||||
{name}
|
||||
</>
|
||||
) : (
|
||||
name
|
||||
)}
|
||||
</p>
|
||||
{details.length > 0 && (
|
||||
<p className="tabular mt-0.5 text-xs text-content-muted">
|
||||
{details.join(' · ')}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
{match.historyResult && (
|
||||
<div className="min-w-0 text-[13px] md:text-right">
|
||||
<HistoryResult match={match} showTeamNames />
|
||||
</div>
|
||||
)}
|
||||
</Link>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
function RecentMatchResultsSkeleton({ limit }: { limit: number }) {
|
||||
return (
|
||||
<div className="divide-y divide-line border-y border-line" aria-hidden="true">
|
||||
{Array.from({ length: limit }, (_, index) => (
|
||||
<div
|
||||
key={index}
|
||||
className="grid gap-2 px-2 py-3.5 md:grid-cols-2 md:items-center"
|
||||
>
|
||||
<div className="space-y-1">
|
||||
<Skeleton width={130} height={16} index={index} />
|
||||
<Skeleton width={96} height={12} index={index} />
|
||||
</div>
|
||||
<Skeleton width={120} height={14} index={index} className="md:justify-self-end" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const RANK_BADGE_CLASS = [
|
||||
'bg-gold text-accent-content',
|
||||
'bg-sunken-strong text-content',
|
||||
'bg-gold-tint text-gold',
|
||||
] as const;
|
||||
|
||||
/** 현재 시즌 순위표의 앞부분. 전적 화면과 같은 집계를 그대로 보여준다. */
|
||||
function RankingPreview({ statsPath }: { statsPath: string }) {
|
||||
const leaderboardQuery = useCommunityLeaderboard({ seasonId: 'current' });
|
||||
const { data: manifest } = useDdragonManifest();
|
||||
const [slide, setSlide] = useState(0);
|
||||
const [direction, setDirection] = useState<1 | -1>(1);
|
||||
const [paused, setPaused] = useState(false);
|
||||
const [touchStartX, setTouchStartX] = useState<number>();
|
||||
const lane = RANKING_SLIDES[slide];
|
||||
const allRows = leaderboardQuery.data?.rows ?? [];
|
||||
const rows = (lane ? rankLeaderboardByLane(allRows, lane) : allRows).slice(
|
||||
0,
|
||||
HOME_RANKING_LIMIT,
|
||||
);
|
||||
const label = lane ? LANE_LABELS[lane] : '종합';
|
||||
const move = (step: 1 | -1) => {
|
||||
setDirection(step);
|
||||
setSlide(
|
||||
(current) => (current + step + RANKING_SLIDES.length) % RANKING_SLIDES.length,
|
||||
);
|
||||
};
|
||||
// key가 바뀌면 목록이 새로 붙으면서 넘긴 방향에서 들어오는 애니메이션이 다시 돈다.
|
||||
const slideStyle = {
|
||||
'--lts-rank-slide-from': `${direction * 1.5}rem`,
|
||||
} as CSSProperties;
|
||||
|
||||
// 읽거나 누르려는 동안에는 멈추고, 직접 넘기면 그 슬라이드부터 다시 센다.
|
||||
useEffect(() => {
|
||||
if (paused || window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
||||
return;
|
||||
}
|
||||
const timer = window.setTimeout(() => move(1), RANKING_SLIDE_INTERVAL_MS);
|
||||
return () => window.clearTimeout(timer);
|
||||
}, [paused, slide]);
|
||||
|
||||
return (
|
||||
<aside
|
||||
aria-busy={leaderboardQuery.isLoading}
|
||||
onMouseEnter={() => setPaused(true)}
|
||||
onMouseLeave={() => setPaused(false)}
|
||||
onFocus={() => setPaused(true)}
|
||||
onBlur={() => setPaused(false)}
|
||||
onTouchStart={(event) => setTouchStartX(event.touches[0]?.clientX)}
|
||||
onTouchEnd={(event) => {
|
||||
const endX = event.changedTouches[0]?.clientX;
|
||||
if (touchStartX === undefined || endX === undefined) return;
|
||||
const distance = endX - touchStartX;
|
||||
if (Math.abs(distance) > 48) move(distance < 0 ? 1 : -1);
|
||||
setTouchStartX(undefined);
|
||||
}}
|
||||
>
|
||||
<PanelHeader
|
||||
title={`시즌 ${label} 순위`}
|
||||
variant="section"
|
||||
actions={
|
||||
<Link
|
||||
to={`${statsPath}?view=ranking`}
|
||||
className="inline-flex items-center gap-0.5 text-[13px] font-semibold text-content-muted hover:text-content hover:underline"
|
||||
>
|
||||
전체 보기
|
||||
<ChevronRight className="size-4" aria-hidden="true" />
|
||||
</Link>
|
||||
}
|
||||
/>
|
||||
<div className="overflow-hidden rounded-2xl bg-sunken p-2">
|
||||
{leaderboardQuery.isLoading ? (
|
||||
<div className="space-y-3 p-3" aria-hidden="true">
|
||||
{Array.from({ length: HOME_RANKING_LIMIT }, (_, index) => (
|
||||
<Skeleton key={index} width="100%" height={36} index={index} />
|
||||
))}
|
||||
</div>
|
||||
) : leaderboardQuery.isError ? (
|
||||
<p className="p-3 text-sm text-content-muted">
|
||||
순위를 불러오지 못했습니다.
|
||||
</p>
|
||||
) : rows.length === 0 ? (
|
||||
<div
|
||||
key={slide}
|
||||
style={slideStyle}
|
||||
className="lts-rank-slide grid min-h-[17.5rem] place-items-center"
|
||||
>
|
||||
<EmptyNote size="sm" title="아직 집계된 순위가 없습니다." />
|
||||
</div>
|
||||
) : (
|
||||
<ol
|
||||
key={slide}
|
||||
style={slideStyle}
|
||||
className="lts-rank-slide min-h-[17.5rem]"
|
||||
>
|
||||
{rows.map((row, index) => (
|
||||
<li key={row.userId}>
|
||||
<Link
|
||||
to={`/users/${row.userId}/history?queueGroup=internal`}
|
||||
className={`${RANKING_COLUMNS_CLASS} group rounded-xl py-2.5 transition-colors hover:bg-card focus-visible:-outline-offset-2`}
|
||||
>
|
||||
<span
|
||||
className={`tabular grid size-6 place-items-center rounded-full text-xs font-bold ${
|
||||
RANK_BADGE_CLASS[index] ?? 'text-content-muted'
|
||||
}`}
|
||||
>
|
||||
{index + 1}
|
||||
<span className="sr-only">위</span>
|
||||
</span>
|
||||
<span className="flex min-w-0 items-center gap-2">
|
||||
<img
|
||||
src={profileIconUrl(manifest, row.profileIconId)}
|
||||
alt=""
|
||||
className="size-9 shrink-0 rounded-full bg-sunken-strong object-cover"
|
||||
loading="lazy"
|
||||
/>
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="block truncate text-sm font-semibold text-content group-hover:text-primary">
|
||||
{row.summonerName}
|
||||
</span>
|
||||
<span className="tabular block text-xs text-content-muted">
|
||||
{row.games}전 {row.wins}승 {row.losses}패
|
||||
</span>
|
||||
</span>
|
||||
<span className="hidden shrink-0 items-center gap-0.5 min-[420px]:flex lg:hidden">
|
||||
{row.topChampions.slice(0, 3).map((champion) => {
|
||||
const icon = championIconUrl(manifest, champion.championId);
|
||||
return icon ? (
|
||||
<img
|
||||
key={champion.championId}
|
||||
src={icon}
|
||||
alt=""
|
||||
className="size-6 rounded-full object-cover"
|
||||
loading="lazy"
|
||||
/>
|
||||
) : null;
|
||||
})}
|
||||
</span>
|
||||
</span>
|
||||
<strong
|
||||
className={`tabular text-right text-sm ${
|
||||
row.winRate >= 50 ? 'text-win' : 'text-content-muted'
|
||||
}`}
|
||||
>
|
||||
<span className="sr-only">승률 </span>
|
||||
{row.winRate}%
|
||||
</strong>
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
)}
|
||||
<div className="flex items-center justify-center gap-1 pt-1">
|
||||
<button
|
||||
type="button"
|
||||
aria-label="이전 순위"
|
||||
className="grid size-8 place-items-center rounded-full text-content-muted transition-colors hover:bg-card hover:text-content"
|
||||
onClick={() => move(-1)}
|
||||
>
|
||||
<ChevronLeft className="size-4" aria-hidden="true" />
|
||||
</button>
|
||||
<p
|
||||
className="tabular min-w-12 text-center text-[13px] text-content-muted"
|
||||
aria-live={paused ? 'polite' : 'off'}
|
||||
>
|
||||
<span className="sr-only">{label} 순위, </span>
|
||||
<strong className="font-bold text-content">{slide + 1}</strong> /{' '}
|
||||
{RANKING_SLIDES.length}
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
aria-label="다음 순위"
|
||||
className="grid size-8 place-items-center rounded-full text-content-muted transition-colors hover:bg-card hover:text-content"
|
||||
onClick={() => move(1)}
|
||||
>
|
||||
<ChevronRight className="size-4" aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
|
||||
interface HistoryPaginationProps {
|
||||
page: number;
|
||||
pageCount: number;
|
||||
@@ -396,10 +708,12 @@ function HistoryPagination({
|
||||
);
|
||||
}
|
||||
|
||||
export default function HomePage() {
|
||||
export default function HomePage({ eventType }: { eventType?: MatchEventType }) {
|
||||
const showArchive = eventType !== undefined;
|
||||
const selectedEventType = eventType ?? 'inhouse';
|
||||
const eventLabel = MATCH_EVENT_LABEL[selectedEventType];
|
||||
const [timelineNow] = useState(() => new Date().toISOString());
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const showArchive = searchParams.get('history') === 'all';
|
||||
const requestedPage = Number(searchParams.get('page'));
|
||||
const historyPage =
|
||||
showArchive && Number.isSafeInteger(requestedPage) && requestedPage > 0
|
||||
@@ -415,14 +729,17 @@ export default function HomePage() {
|
||||
setSearchParams(params, { preventScrollReset: true });
|
||||
}
|
||||
const upcomingMatchesQuery = useMatches({
|
||||
eventType: selectedEventType,
|
||||
limit: UPCOMING_MATCH_LIST_LIMIT,
|
||||
scheduledFrom: timelineNow,
|
||||
sort: 'asc',
|
||||
});
|
||||
const historyMatchesQuery = useMatchesPage({
|
||||
eventType: selectedEventType,
|
||||
limit: historyLimit,
|
||||
page: historyPage,
|
||||
scheduledTo: timelineNow,
|
||||
status: showArchive ? undefined : 'finished',
|
||||
scheduledTo: showArchive ? timelineNow : undefined,
|
||||
sort: 'desc',
|
||||
includeResults: true,
|
||||
});
|
||||
@@ -438,7 +755,10 @@ export default function HomePage() {
|
||||
);
|
||||
}
|
||||
|
||||
const [nextMatch, ...upcomingMatches] = upcomingMatchesQuery.data ?? [];
|
||||
const allUpcomingMatches = upcomingMatchesQuery.data ?? [];
|
||||
const [nextMatch, ...upcomingMatches] = allUpcomingMatches;
|
||||
const bannerMatch = showArchive ? undefined : nextMatch;
|
||||
const visibleUpcomingMatches = showArchive ? allUpcomingMatches : upcomingMatches;
|
||||
const historyTotal = historyMatchesQuery.data?.total ?? 0;
|
||||
const historyPageCount = Math.max(
|
||||
1,
|
||||
@@ -450,25 +770,27 @@ export default function HomePage() {
|
||||
const hasHistoryError =
|
||||
Boolean(historyMatchesQuery.error) && !historyMatchesQuery.data;
|
||||
const statsPath = `/communities/${DEFAULT_COMMUNITY_ID}/internal-stats`;
|
||||
const HistorySection = showArchive ? Panel : 'section';
|
||||
const UpcomingStatusHeading = showArchive ? 'p' : 'h1';
|
||||
const contentSpacing = showArchive ? 'space-y-5 pb-16' : 'space-y-8 pb-10 md:pb-16';
|
||||
const contentTopPadding = bannerMatch ? 'pt-10 md:pt-16' : 'pt-5 sm:pt-6';
|
||||
|
||||
return (
|
||||
<PlainPage className="lts-overview space-y-5 pt-5 pb-16 sm:pt-6">
|
||||
{showArchive ? (
|
||||
<div className="flex flex-wrap items-center justify-between gap-3">
|
||||
<h1 className="text-2xl font-bold">전체 내전 일정</h1>
|
||||
<Link to="/" className="text-sm font-semibold hover:underline">
|
||||
내전 홈
|
||||
</Link>
|
||||
</div>
|
||||
) : upcomingMatchesQuery.isLoading ? (
|
||||
<h1 className="text-sm text-content-muted" aria-busy="true">
|
||||
내전 일정을 불러오는 중
|
||||
</h1>
|
||||
const content = (
|
||||
<div className={`${pageWidthClass()} ${contentSpacing} ${contentTopPadding}`}>
|
||||
{showArchive && (
|
||||
<header>
|
||||
<h1 className="text-2xl font-bold">{eventLabel} 일정</h1>
|
||||
</header>
|
||||
)}
|
||||
{upcomingMatchesQuery.isLoading ? (
|
||||
<UpcomingStatusHeading className="text-sm text-content-muted" aria-busy="true">
|
||||
{eventLabel} 일정을 불러오는 중
|
||||
</UpcomingStatusHeading>
|
||||
) : upcomingMatchesQuery.isError && !upcomingMatchesQuery.data ? (
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<h1 className="text-sm text-content-muted">
|
||||
내전 일정을 불러오지 못했습니다
|
||||
</h1>
|
||||
<UpcomingStatusHeading className="text-sm text-content-muted">
|
||||
{eventLabel} 일정을 불러오지 못했습니다
|
||||
</UpcomingStatusHeading>
|
||||
<button
|
||||
type="button"
|
||||
className="min-h-8 text-sm font-semibold underline"
|
||||
@@ -477,67 +799,91 @@ export default function HomePage() {
|
||||
다시 시도
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<NextMatch match={nextMatch} />
|
||||
)}
|
||||
) : !nextMatch ? (
|
||||
<UpcomingStatusHeading className="text-sm text-content-muted">
|
||||
예정된 {eventLabel}이 없습니다
|
||||
</UpcomingStatusHeading>
|
||||
) : null}
|
||||
|
||||
{!showArchive && upcomingMatches.length > 0 && (
|
||||
<UpcomingMatches matches={upcomingMatches} />
|
||||
)}
|
||||
|
||||
<Panel aria-busy={isHistoryPageLoading} aria-live="polite">
|
||||
<PanelHeader
|
||||
title={showArchive ? '지난 일정 전체' : '최근 내전 일정'}
|
||||
actions={
|
||||
<Link
|
||||
to={statsPath}
|
||||
className="inline-flex items-center gap-0.5 text-[13px] font-semibold text-content-muted hover:text-content hover:underline"
|
||||
>
|
||||
전적 검색
|
||||
<ChevronRight className="size-4" aria-hidden="true" />
|
||||
</Link>
|
||||
}
|
||||
{visibleUpcomingMatches.length > 0 && (
|
||||
<UpcomingMatches
|
||||
matches={visibleUpcomingMatches}
|
||||
title={showArchive ? '다가오는 일정' : undefined}
|
||||
/>
|
||||
{isHistoryPageLoading ? (
|
||||
<HistoryRecordsSkeleton limit={historyLimit} />
|
||||
) : hasHistoryError ? (
|
||||
<div className="p-4">
|
||||
<ErrorNote
|
||||
title="지난 내전 기록을 불러오지 못했습니다"
|
||||
action={
|
||||
<Button
|
||||
label="다시 시도"
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
onClick={() => void historyMatchesQuery.refetch()}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<HistoryRecords matches={historyMatchesQuery.data?.matches ?? []} />
|
||||
)}
|
||||
{showArchive && !hasHistoryError && historyTotal > 0 && (
|
||||
<HistoryPagination
|
||||
page={historyPage}
|
||||
pageCount={historyPageCount}
|
||||
total={historyTotal}
|
||||
isFetching={historyMatchesQuery.isFetching}
|
||||
onPrevious={() => setHistoryPage(Math.max(1, historyPage - 1))}
|
||||
onNext={() => setHistoryPage(historyPage + 1)}
|
||||
)}
|
||||
|
||||
<div
|
||||
className={
|
||||
showArchive
|
||||
? undefined
|
||||
: 'grid items-start gap-8 lg:grid-cols-[minmax(0,1fr)_20rem]'
|
||||
}
|
||||
>
|
||||
<HistorySection aria-busy={isHistoryPageLoading} aria-live="polite">
|
||||
<PanelHeader
|
||||
title={showArchive ? '지난 일정과 결과' : '최근 내전 결과'}
|
||||
variant={showArchive ? 'panel' : 'section'}
|
||||
actions={
|
||||
<Link
|
||||
to={showArchive ? statsPath : '/inhouse'}
|
||||
className="inline-flex items-center gap-0.5 text-[13px] font-semibold text-content-muted hover:text-content hover:underline"
|
||||
>
|
||||
{showArchive ? '전적 검색' : '전체 내전 기록'}
|
||||
<ChevronRight className="size-4" aria-hidden="true" />
|
||||
</Link>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{!showArchive && historyTotal > HOME_HISTORY_LIMIT && (
|
||||
<div className="border-t border-line px-4 py-2.5 text-right sm:px-5">
|
||||
<Link
|
||||
to="/?history=all"
|
||||
className="text-sm text-content-muted hover:underline"
|
||||
>
|
||||
전체 일정 기록
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
</Panel>
|
||||
</PlainPage>
|
||||
{isHistoryPageLoading ? (
|
||||
showArchive ? (
|
||||
<HistoryRecordsSkeleton limit={historyLimit} />
|
||||
) : (
|
||||
<RecentMatchResultsSkeleton limit={historyLimit} />
|
||||
)
|
||||
) : hasHistoryError ? (
|
||||
<div className="p-4">
|
||||
<ErrorNote
|
||||
title={`지난 ${eventLabel} 기록을 불러오지 못했습니다`}
|
||||
action={
|
||||
<Button
|
||||
label="다시 시도"
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
onClick={() => void historyMatchesQuery.refetch()}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
) : showArchive ? (
|
||||
<HistoryRecords
|
||||
matches={historyMatchesQuery.data?.matches ?? []}
|
||||
eventLabel={eventLabel}
|
||||
/>
|
||||
) : (
|
||||
<RecentMatchResults matches={historyMatchesQuery.data?.matches ?? []} />
|
||||
)}
|
||||
{showArchive && !hasHistoryError && historyTotal > 0 && (
|
||||
<HistoryPagination
|
||||
page={historyPage}
|
||||
pageCount={historyPageCount}
|
||||
total={historyTotal}
|
||||
isFetching={historyMatchesQuery.isFetching}
|
||||
onPrevious={() => setHistoryPage(Math.max(1, historyPage - 1))}
|
||||
onNext={() => setHistoryPage(historyPage + 1)}
|
||||
/>
|
||||
)}
|
||||
</HistorySection>
|
||||
{!showArchive && <RankingPreview statsPath={statsPath} />}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<main>
|
||||
{bannerMatch && <NextMatch match={bannerMatch} />}
|
||||
{content}
|
||||
{!showArchive && (
|
||||
<HomeHallOfFame introReady={!upcomingMatchesQuery.isPending} />
|
||||
)}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user