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:
dahyeon committed 2026-11-10 22:13:55 +09:00
1 parent 7e0cd7cb19
commit 664af15255
58 files changed
+2316 -593

No files matched your search

+165 -69
View File
@@ -1,10 +1,19 @@
import { BrowserRouter, Link, NavLink, Route, Routes } from "react-router";
import { lazy, Suspense, type ReactNode } from "react";
import {
BrowserRouter,
Link,
matchPath,
Navigate,
Route,
Routes,
useLocation,
useNavigate,
} from "react-router";
import { lazy, Suspense, useState, type FormEvent, type ReactNode } from "react";
import { useMsal } from "@azure/msal-react";
import { LogOut, Moon, Sun } from "lucide-react";
import { LogOut, Moon, Search, Sun } from "lucide-react";
import DevAuthSwitcher from "./components/DevAuthSwitcher";
import { DEFAULT_COMMUNITY_ID, setTheme, useTheme } from "./config";
import { useCommunity, useMe } from "./api/hooks";
import { useCommunity, useMatch, useMe } from "./api/hooks";
import { isMsalConfigured } from "./lib/auth/msal.config";
import AuthCallbackPage from "./pages/AuthCallback";
import HomePage from "./pages/HomePage";
@@ -30,7 +39,7 @@ const MatchFlowsPreview = import.meta.env.DEV
: null;
const NAV_ICON_BUTTON_CLASS =
"grid size-9 shrink-0 place-items-center rounded-field text-content-muted transition-colors hover:bg-sunken-strong hover:text-content";
"grid size-10 shrink-0 place-items-center rounded-field text-content-muted transition-colors hover:bg-sunken-strong hover:text-content md:size-11";
function MsalHeaderActions() {
const { accounts, instance } = useMsal();
@@ -39,7 +48,7 @@ function MsalHeaderActions() {
if (!account) {
return (
<Link
className="inline-flex h-9 items-center whitespace-nowrap rounded-full border border-line-strong px-2.5 text-[13px] font-semibold text-content transition-colors hover:bg-sunken sm:px-3.5"
className="inline-flex h-10 items-center whitespace-nowrap rounded-full border border-line-strong px-3.5 text-sm font-semibold text-content transition-colors hover:bg-sunken md:h-11 md:px-4 md:text-[15px]"
to="/login"
>
로그인
@@ -51,7 +60,7 @@ function MsalHeaderActions() {
return (
<div className="flex min-w-0 items-center gap-1">
<span className="hidden max-w-40 truncate text-[13px] font-medium text-content-muted sm:block">
<span className="hidden max-w-40 truncate text-sm font-medium text-content-muted lg:block">
{name}
</span>
<Tooltip content="로그아웃" placement="below">
@@ -61,7 +70,7 @@ function MsalHeaderActions() {
aria-label={`${name} 로그아웃`}
onClick={() => void instance.logoutRedirect()}
>
<LogOut className="size-4" aria-hidden="true" />
<LogOut className="size-[18px] md:size-5" aria-hidden="true" />
</button>
</Tooltip>
</div>
@@ -83,7 +92,7 @@ function ThemeToggle() {
aria-label={label}
onClick={() => setTheme(nextTheme)}
>
<Icon className="size-4" aria-hidden="true" />
<Icon className="size-[18px] md:size-5" aria-hidden="true" />
</button>
</Tooltip>
);
@@ -91,31 +100,78 @@ function ThemeToggle() {
function PrimaryNavLink({
to,
end,
sectionPaths = [],
children,
}: {
to: string;
end?: boolean;
sectionPaths?: string[];
children: ReactNode;
}) {
const { pathname } = useLocation();
const current = matchPath(to, pathname)
? "page"
: sectionPaths.some((pattern) => matchPath(pattern, pathname))
? "location"
: undefined;
return (
<NavLink
<Link
to={to}
end={end}
className={({ isActive }) =>
`relative inline-flex h-full items-center whitespace-nowrap px-3 text-sm font-semibold transition-colors ${
isActive
? "text-content after:absolute after:inset-x-3 after:bottom-0 after:h-0.5 after:rounded-t-full after:bg-content"
: "text-content-muted hover:text-content"
}`
}
aria-current={current}
className={`relative inline-flex h-full items-center whitespace-nowrap px-2.5 text-base font-semibold transition-colors focus-visible:-outline-offset-2 sm:px-4 md:px-7 md:text-xl ${
current
? "text-content-strong after:absolute after:inset-x-2.5 after:bottom-0 after:h-[3px] after:rounded-t-full after:bg-primary sm:after:inset-x-4 md:after:inset-x-7"
: "text-content-subtle hover:text-content-strong"
}`}
>
{children}
</NavLink>
</Link>
);
}
/** 선수 이름으로 전적 순위표를 바로 찾는 머리글 검색. */
function HeaderPlayerSearch() {
const navigate = useNavigate();
const [value, setValue] = useState("");
function handleSubmit(event: FormEvent<HTMLFormElement>) {
event.preventDefault();
const query = value.trim();
if (!query) return;
const params = new URLSearchParams({ view: "ranking", q: query });
void navigate(
`/communities/${DEFAULT_COMMUNITY_ID}/internal-stats?${params.toString()}`,
);
setValue("");
}
return (
<form
role="search"
onSubmit={handleSubmit}
className="relative hidden w-56 min-w-0 md:block lg:w-72"
>
<Search
className="pointer-events-none absolute left-3.5 top-1/2 size-[18px] -translate-y-1/2 text-content-subtle"
aria-hidden="true"
/>
<input
type="search"
value={value}
onChange={(event) => setValue(event.target.value)}
placeholder="선수 이름 검색"
aria-label="선수 이름으로 전적 검색"
className="h-11 w-full rounded-full border border-line-strong bg-sunken pr-4 pl-10 text-[15px] text-content placeholder:text-content-muted focus-visible:bg-card focus-visible:placeholder:text-content-subtle"
/>
</form>
);
}
function AppHeader() {
const { pathname } = useLocation();
const matchId = matchPath("/match/:id/*", pathname)?.params.id;
const matchQuery = useMatch(matchId);
const isTournamentMatch = matchQuery.data?.eventType === "tournament";
const communityQuery = useCommunity(DEFAULT_COMMUNITY_ID);
const meQuery = useMe();
const communityLabel = communityQuery.data?.name ?? "LOLYMPUS";
@@ -123,55 +179,72 @@ function AppHeader() {
(membership) => membership.community?._id === DEFAULT_COMMUNITY_ID,
)?.user?.role;
const canManage = role === "owner" || role === "admin";
const statsPath = `/communities/${DEFAULT_COMMUNITY_ID}/internal-stats`;
const adminPath = `/admin/communities/${DEFAULT_COMMUNITY_ID}`;
return (
<header className="sticky top-0 z-50 border-b border-line bg-card dark:bg-ink">
<div
className={`${pageWidthClass("xl")} grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] grid-rows-[var(--app-header-row-height)_var(--app-header-nav-height)] items-center sm:gap-x-3`}
>
<Link
className="col-start-2 row-start-1 flex h-full items-center text-content"
to="/"
aria-label={`${communityLabel} 홈`}
<>
<header className="h-(--app-header-row-height) shrink-0 border-b border-line bg-card dark:bg-ink">
<div
className={`${pageWidthClass("xl")} grid h-full grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center sm:gap-x-3`}
>
<span className="max-w-24 truncate text-[17px] font-extrabold tracking-[-0.02em] sm:max-w-40">
{communityLabel}
</span>
</Link>
{DEFAULT_COMMUNITY_ID && (
<nav
aria-label="주 메뉴"
className="col-span-3 row-start-2 flex h-full items-center justify-center sm:col-span-1 sm:col-start-1 sm:row-start-1 sm:justify-start"
<Link
className="col-start-2 row-start-1 flex h-full items-center text-content-strong"
to="/"
aria-label={`${communityLabel} 홈`}
>
<PrimaryNavLink to="/" end>
내전
</PrimaryNavLink>
<PrimaryNavLink
to={`/communities/${DEFAULT_COMMUNITY_ID}/internal-stats`}
>
전적
</PrimaryNavLink>
{canManage && (
<PrimaryNavLink
to={`/admin/communities/${DEFAULT_COMMUNITY_ID}/matches`}
>
운영
</PrimaryNavLink>
)}
</nav>
)}
<div className="contents sm:col-start-3 sm:row-start-1 sm:flex sm:min-w-0 sm:items-center sm:justify-self-end sm:gap-1">
<div className="col-start-1 row-start-1 justify-self-start sm:shrink-0">
<ThemeToggle />
</div>
{isMsalConfigured && (
<div className="col-start-3 row-start-1 min-w-0 justify-self-end">
<MsalHeaderActions />
<span className="max-w-32 truncate text-xl font-extrabold tracking-[-0.02em] md:max-w-48 md:text-[22px]">
{communityLabel}
</span>
</Link>
<div className="contents sm:col-start-3 sm:row-start-1 sm:flex sm:min-w-0 sm:items-center sm:justify-end sm:gap-1 lg:gap-2">
{DEFAULT_COMMUNITY_ID && <HeaderPlayerSearch />}
<div className="col-start-1 row-start-1 justify-self-start sm:shrink-0">
<ThemeToggle />
</div>
)}
{isMsalConfigured && (
<div className="col-start-3 row-start-1 min-w-0 justify-self-end sm:shrink-0">
<MsalHeaderActions />
</div>
)}
</div>
</div>
</div>
</header>
</header>
{DEFAULT_COMMUNITY_ID && (
<nav
aria-label="주 메뉴"
className="sticky top-0 z-50 flex h-(--app-header-nav-height) shrink-0 justify-center gap-0.5 border-b border-line bg-card sm:gap-2 md:gap-5 dark:bg-ink"
>
<PrimaryNavLink to="/">홈</PrimaryNavLink>
<PrimaryNavLink
to="/inhouse"
sectionPaths={isTournamentMatch ? undefined : ["/match/*"]}
>
내전
</PrimaryNavLink>
<PrimaryNavLink
to="/tournaments"
sectionPaths={isTournamentMatch ? ["/match/*"] : undefined}
>
멸망전
</PrimaryNavLink>
<PrimaryNavLink
to={statsPath}
sectionPaths={[`${statsPath}/*`, "/users/:userId/history"]}
>
전적
</PrimaryNavLink>
{canManage && (
<PrimaryNavLink
to={`${adminPath}/matches`}
sectionPaths={[`${adminPath}/*`]}
>
운영
</PrimaryNavLink>
)}
</nav>
)}
</>
);
}
@@ -213,7 +286,7 @@ function LegalPage({
}) {
return (
<PlainPage width="md" className="py-12">
<h1 className="text-2xl font-extrabold text-content">{title}</h1>
<h1 className="text-2xl font-extrabold">{title}</h1>
<div className="lts-panel mt-6 space-y-4 p-6 text-sm leading-7 text-content-muted">
{children}
</div>
@@ -227,14 +300,14 @@ function NotFoundPage() {
<p className="tabular text-5xl font-extrabold text-content-disabled">
404
</p>
<h1 className="mt-4 text-xl font-bold text-content">
<h1 className="mt-4 text-xl font-bold">
페이지를 찾을 수 없습니다
</h1>
<p className="mt-2 text-sm text-content-muted">
주소가 바뀌었거나 삭제된 내전일 수 있습니다.
</p>
<Link
to="/"
to="/inhouse"
className="mt-6 inline-flex h-10 items-center rounded-field bg-primary px-5 text-sm font-bold text-primary-content"
>
내전 목록으로
@@ -243,17 +316,40 @@ function NotFoundPage() {
);
}
function HomeRoute() {
const { search, hash } = useLocation();
const params = new URLSearchParams(search);
if (params.get("history") === "all") {
params.delete("history");
return (
<Navigate
replace
to={{ pathname: "/inhouse", search: params.toString(), hash }}
/>
);
}
return <HomePage />;
}
function App() {
return (
<BrowserRouter>
<div
className={`lts-app-shell flex min-h-screen flex-col bg-body ${DEFAULT_COMMUNITY_ID ? "max-sm:[--app-header-nav-height:2.5rem]" : ""}`}
className={`lts-app-shell flex min-h-screen flex-col bg-body ${DEFAULT_COMMUNITY_ID ? "" : "[--app-header-nav-height:0px]"}`}
>
<AppHeader />
<div className="flex-1">
<Routes>
<Route path="/" element={<HomePage />} />
<Route path="/" element={<HomeRoute />} />
<Route
path="/inhouse"
element={<HomePage key="inhouse" eventType="inhouse" />}
/>
<Route
path="/tournaments"
element={<HomePage key="tournament" eventType="tournament" />}
/>
<Route path="/login" element={<LoginPage />} />
<Route path="/auth/callback" element={<AuthCallbackPage />} />
<Route path="/match/:id" element={<MatchDetailPage />} />