Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions web/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ const eslintConfig = defineConfig([
"no-restricted-imports": [
"error",
{
// Only the component; its hooks are fine anywhere.
name: "next/link",
importNames: ["default"],
message: "Use Link from @/ui/Link, which turns off prefetching.",
},
],
Expand Down
2 changes: 2 additions & 0 deletions web/next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const nextConfig: NextConfig = {
// That proxying buffers request bodies, cut off at 10 MB by default; a packed map can be up to the API's
// 256 MB (`staff/map_viewer_file.rs`).
proxyClientMaxBodySize: "256mb",
// Pages block on their data by design (`instant = false` in the root layout), so don't warn about it.
instantInsights: { validationLevel: "manual-warning" },
},
turbopack: {
rules: {
Expand Down
27 changes: 11 additions & 16 deletions web/src/app/activity/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Activity page: runs and world records per day, then the latest runs, narrowed by style, track, lowest tier or
// world records only.
import type { Metadata } from "next";
import { Suspense } from "react";
import { RecentRuns } from "@/features/activity/RecentRuns";
import { DailyTotals } from "@/features/dailyTotals/DailyTotals";
import { Page } from "@/ui/Page";
Expand All @@ -15,21 +14,17 @@ export default function ActivityPage({ searchParams }: PageProps<"/activity">) {
return (
<Page className="gap-6">
<h1 className="text-3xl font-bold">Activity</h1>
<Suspense>
<DailyTotals kind="runs" />
</Suspense>
<Suspense>
{searchParams.then(({ style, track, tier, show }) => (
<RecentRuns
params={{
style: typeof style === "string" ? style : undefined,
track: typeof track === "string" ? track : undefined,
tier: typeof tier === "string" ? tier : undefined,
show: typeof show === "string" ? show : undefined,
}}
/>
))}
</Suspense>
<DailyTotals kind="runs" />
{searchParams.then(({ style, track, tier, show }) => (
<RecentRuns
params={{
style: typeof style === "string" ? style : undefined,
track: typeof track === "string" ? track : undefined,
tier: typeof tier === "string" ? tier : undefined,
show: typeof show === "string" ? show : undefined,
}}
/>
))}
</Page>
);
}
9 changes: 3 additions & 6 deletions web/src/app/community/[post]/edit/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Editing a community post, for its author and staff.
import type { Metadata } from "next";
import { Suspense } from "react";
import { WritePost } from "@/features/community/WritePost";
import { Page } from "@/ui/Page";

Expand All @@ -15,11 +14,9 @@ export default function EditPostPage({
return (
<Page className="gap-6" width="narrow">
<h1 className="text-3xl font-bold">Edit post</h1>
<Suspense>
{params.then(({ post }) => (
<WritePost path={decodeURIComponent(post)} />
))}
</Suspense>
{params.then(({ post }) => (
<WritePost path={decodeURIComponent(post)} />
))}
</Page>
);
}
9 changes: 3 additions & 6 deletions web/src/app/community/[post]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// One community post. The address is `/community/{id}-{slug}`; other forms of it redirect there.
import type { Metadata } from "next";
import { Suspense } from "react";
import { PostView } from "@/features/community/PostView";
import { Page } from "@/ui/Page";

Expand All @@ -9,11 +8,9 @@ export const metadata: Metadata = { title: "Community" };
export default function PostPage({ params }: PageProps<"/community/[post]">) {
return (
<Page width="narrow">
<Suspense>
{params.then(({ post }) => (
<PostView path={decodeURIComponent(post)} />
))}
</Suspense>
{params.then(({ post }) => (
<PostView path={decodeURIComponent(post)} />
))}
</Page>
);
}
5 changes: 1 addition & 4 deletions web/src/app/community/new/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Writing a new community post, for players allowed to post.
import type { Metadata } from "next";
import { Suspense } from "react";
import { WritePost } from "@/features/community/WritePost";
import { Page } from "@/ui/Page";

Expand All @@ -13,9 +12,7 @@ export default function NewPostPage() {
return (
<Page className="gap-6" width="narrow">
<h1 className="text-3xl font-bold">New post</h1>
<Suspense>
<WritePost />
</Suspense>
<WritePost />
</Page>
);
}
19 changes: 8 additions & 11 deletions web/src/app/community/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Community page: posts and videos by players allowed to post, newest first.
import type { Metadata } from "next";
import { Suspense } from "react";
import { PostList } from "@/features/community/PostList";
import { Page } from "@/ui/Page";

Expand All @@ -15,16 +14,14 @@ export default function CommunityPage({
return (
<Page className="gap-6" width="narrow">
<h1 className="text-3xl font-bold">Community</h1>
<Suspense>
{searchParams.then((params) => (
<PostList
params={{
kind: first(params.kind),
before: first(params.before),
}}
/>
))}
</Suspense>
{searchParams.then((params) => (
<PostList
params={{
kind: first(params.kind),
before: first(params.before),
}}
/>
))}
</Page>
);
}
Expand Down
5 changes: 5 additions & 0 deletions web/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Suspense } from "react";
import { RunDialogHost } from "@/features/runs/RunDialogHost";
import { SiteFooter } from "@/features/site/SiteFooter";
import { SiteHeader } from "@/features/site/SiteHeader";
import { NavigationProgress } from "@/ui/NavigationProgress";
import "./globals.css";

const play = Play({
Expand All @@ -19,10 +20,14 @@ export const metadata: Metadata = {
"Global records for the Counter-Strike: Source bunnyhop community.",
};

// Pages wait for their data and arrive whole; the progress bar covers the wait.
export const instant = false;

export default function RootLayout({ children }: LayoutProps<"/">) {
return (
<html lang="en" className={`${play.variable} h-full antialiased`}>
<body className="flex min-h-full flex-col">
<NavigationProgress />
{/* The header and page fill at least the window, so the footer starts right at the fold: the page
always scrolls, and the scrollbar doesn't come and go between short and long pages. The space
above the footer is padding in here, not a margin on the footer, so it doesn't push it lower. */}
Expand Down
33 changes: 15 additions & 18 deletions web/src/app/leaderboards/[ranking]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// One leaderboard in full: /leaderboards/points or /leaderboards/completed, with the overview's choices.
import type { Metadata } from "next";
import { notFound } from "next/navigation";
import { Suspense } from "react";
import {
LeaderboardList,
listTitle,
Expand Down Expand Up @@ -31,23 +30,21 @@ export default function LeaderboardListPage({
}: PageProps<"/leaderboards/[ranking]">) {
return (
<Page className="gap-6">
<Suspense>
{Promise.all([params, searchParams]).then(
([{ ranking }, { style, track, view }]) => {
if (!rankings.includes(ranking)) notFound();
return (
<LeaderboardList
ranking={ranking as Ranking}
params={{
style: typeof style === "string" ? style : undefined,
track: typeof track === "string" ? track : undefined,
view: typeof view === "string" ? view : undefined,
}}
/>
);
},
)}
</Suspense>
{Promise.all([params, searchParams]).then(
([{ ranking }, { style, track, view }]) => {
if (!rankings.includes(ranking)) notFound();
return (
<LeaderboardList
ranking={ranking as Ranking}
params={{
style: typeof style === "string" ? style : undefined,
track: typeof track === "string" ? track : undefined,
view: typeof view === "string" ? view : undefined,
}}
/>
);
},
)}
</Page>
);
}
21 changes: 9 additions & 12 deletions web/src/app/leaderboards/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Leaderboards page: the top players by points and by completions, per style and track, and pre-2.0.
import type { Metadata } from "next";
import { Suspense } from "react";
import { Leaderboards } from "@/features/leaderboards/Leaderboards";
import { Page } from "@/ui/Page";

Expand All @@ -15,17 +14,15 @@ export default function LeaderboardsPage({
return (
<Page className="gap-6">
<h1 className="text-3xl font-bold">Leaderboards</h1>
<Suspense>
{searchParams.then(({ style, track, view }) => (
<Leaderboards
params={{
style: typeof style === "string" ? style : undefined,
track: typeof track === "string" ? track : undefined,
view: typeof view === "string" ? view : undefined,
}}
/>
))}
</Suspense>
{searchParams.then(({ style, track, view }) => (
<Leaderboards
params={{
style: typeof style === "string" ? style : undefined,
track: typeof track === "string" ? track : undefined,
view: typeof view === "string" ? view : undefined,
}}
/>
))}
</Page>
);
}
9 changes: 3 additions & 6 deletions web/src/app/maps/[map]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// A map's pages: the banner and header stay while the map's view, its Zones and its Manage view swap beneath them.
import { Suspense } from "react";
import { MapHeader } from "@/features/maps/MapHeader";
import { Page } from "@/ui/Page";

Expand All @@ -9,11 +8,9 @@ export default function MapLayout({
}: LayoutProps<"/maps/[map]">) {
return (
<Page className="gap-6">
<Suspense>
{params.then(({ map }) => (
<MapHeader name={decodeURIComponent(map)} />
))}
</Suspense>
{params.then(({ map }) => (
<MapHeader name={decodeURIComponent(map)} />
))}
{children}
</Page>
);
Expand Down
9 changes: 3 additions & 6 deletions web/src/app/maps/[map]/manage/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// A map's Manage view, for staff, under the map's header. Kept out of search engines, as the staff area is.
import type { Metadata } from "next";
import { Suspense } from "react";
import { ManageMap } from "@/features/staff/maps/ManageMap";
import { PageView } from "@/ui/Page";

Expand All @@ -18,11 +17,9 @@ export default function ManageMapPage({
}: PageProps<"/maps/[map]/manage">) {
return (
<PageView>
<Suspense>
{params.then(({ map }) => (
<ManageMap name={decodeURIComponent(map)} />
))}
</Suspense>
{params.then(({ map }) => (
<ManageMap name={decodeURIComponent(map)} />
))}
</PageView>
);
}
9 changes: 3 additions & 6 deletions web/src/app/maps/[map]/manage/zones/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// The zone editor for a map, under its header, for staff with manage_zones. Kept out of search engines, as the
// staff area is.
import type { Metadata } from "next";
import { Suspense } from "react";
import { ZoneEditorView } from "@/features/staff/maps/ZoneEditorView";
import { PageView } from "@/ui/Page";

Expand All @@ -19,11 +18,9 @@ export default function ZoneEditorPage({
}: PageProps<"/maps/[map]/manage/zones">) {
return (
<PageView>
<Suspense>
{params.then(({ map }) => (
<ZoneEditorView name={decodeURIComponent(map)} />
))}
</Suspense>
{params.then(({ map }) => (
<ZoneEditorView name={decodeURIComponent(map)} />
))}
</PageView>
);
}
9 changes: 3 additions & 6 deletions web/src/app/maps/[map]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// A map's page: its description, leaderboards per style and track, and their WR history, under the map's header.
import type { Metadata } from "next";
import { Suspense } from "react";
import { MapView } from "@/features/maps/MapView";
import { PageView } from "@/ui/Page";

Expand All @@ -13,11 +12,9 @@ export async function generateMetadata({
export default function MapPage({ params }: PageProps<"/maps/[map]">) {
return (
<PageView>
<Suspense>
{params.then(({ map }) => (
<MapView name={decodeURIComponent(map)} />
))}
</Suspense>
{params.then(({ map }) => (
<MapView name={decodeURIComponent(map)} />
))}
</PageView>
);
}
9 changes: 3 additions & 6 deletions web/src/app/maps/[map]/zones/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// A map's Zones view, for everyone, under the map's header.
import type { Metadata } from "next";
import { Suspense } from "react";
import { MapZones } from "@/features/maps/MapZones";
import { PageView } from "@/ui/Page";

Expand All @@ -15,11 +14,9 @@ export default function MapZonesPage({
}: PageProps<"/maps/[map]/zones">) {
return (
<PageView>
<Suspense>
{params.then(({ map }) => (
<MapZones name={decodeURIComponent(map)} />
))}
</Suspense>
{params.then(({ map }) => (
<MapZones name={decodeURIComponent(map)} />
))}
</PageView>
);
}
9 changes: 3 additions & 6 deletions web/src/app/maps/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Maps page: every map with a finished run, searchable, with its world record in a chosen style.
import type { Metadata } from "next";
import { Suspense } from "react";
import { MapList } from "@/features/maps/MapList";
import { Page } from "@/ui/Page";

Expand All @@ -13,11 +12,9 @@ export default function MapsPage({ searchParams }: PageProps<"/maps">) {
return (
<Page className="gap-6">
<h1 className="text-3xl font-bold">Maps</h1>
<Suspense>
{searchParams.then((params) => (
<MapList params={firstValues(params)} />
))}
</Suspense>
{searchParams.then((params) => (
<MapList params={firstValues(params)} />
))}
</Page>
);
}
Expand Down
Loading