Skip to content

Commit 950c7b5

Browse files
committed
feat: seasons with themes, decorations and challenges; public page fixes
- Seasons: one registry entry per season (theme, decoration, emblem, challenges, dates) - Winter Lights from 1 Dec, Neon Nights, Colour Rush and Grind Mode after it - /play/season with live challenge progress, feed banner, logo emblem, admin Auto/Off/Force at /admin/seasons - Users can switch seasonal effects off; motion is off under prefers-reduced-motion - Download and About pages rebuilt as lists, landing title no longer breaks mid-word - Articles no longer repeat the title as the first heading - Sign-up copy updated for open sign-up across guide, docs, landing and meta descriptions
1 parent d3922bd commit 950c7b5

49 files changed

Lines changed: 2796 additions & 89 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎src/app/(app)/(academics)/courses/[slug]/page.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ export default async function CourseLandingPage({ params }: Props) {
127127
>
128128
{c.category}
129129
</Link>
130-
<span className="text-muted-foreground/40">/</span>
131-
<span className="truncate max-w-[200px] text-foreground font-medium sm:max-w-md">{c.title}</span>
130+
<span className="hidden text-muted-foreground/40 sm:inline">/</span>
131+
<span className="hidden max-w-md truncate font-medium text-foreground sm:inline">{c.title}</span>
132132
</nav>
133133
<div className="grid gap-8 lg:grid-cols-[1fr_340px]">
134134
<div className="min-w-0">
135135
<p className="text-sm font-semibold text-primary">{c.category}</p>
136-
<h1 className="mt-1 text-3xl font-bold leading-tight tracking-tight text-foreground sm:text-4xl">
136+
<h1 className="mt-1 text-3xl font-extrabold leading-tight tracking-tight text-foreground sm:text-4xl">
137137
{c.title}
138138
</h1>
139139
{c.subtitle && <p className="mt-2 text-lg text-muted-foreground">{c.subtitle}</p>}

‎src/app/(app)/(articles)/articles/[slug]/article-reader-client.tsx‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { Badge } from "@/components/ui/badge";
2525
import { Button } from "@/components/ui/button";
2626
import { getCategoryMeta } from "@/constants/articles";
2727
import { type Byline, EDITORIAL_BIO } from "@/lib/articles/byline";
28-
import { splitAfterSecondSection } from "@/lib/articles/seo";
28+
import { splitAfterSecondSection, stripLeadingTitle } from "@/lib/articles/seo";
2929

3030
export type { InBodyLink };
3131

@@ -134,7 +134,9 @@ export function ArticleReaderClient({
134134
college,
135135
href: byline?.path ?? (handle ? `/@${handle}` : undefined),
136136
};
137-
const bodyParts = inBodyLinks.length > 0 ? splitAfterSecondSection(article.content) : null;
137+
// The h1 already shows the title; many bodies open with the same line as a heading.
138+
const body = stripLeadingTitle(article.content, article.title);
139+
const bodyParts = inBodyLinks.length > 0 ? splitAfterSecondSection(body) : null;
138140

139141
const date = new Date(article.publishedAt || article.createdAt);
140142
const dateLabel = date.toLocaleDateString("en-IN", { month: "long", day: "numeric", year: "numeric" });
@@ -208,7 +210,7 @@ export function ArticleReaderClient({
208210
<div>
209211
<ArticleListenButton title={article.title} content={article.content} />
210212
</div>
211-
<ArticleToc content={article.content} />
213+
<ArticleToc content={body} />
212214
</div>
213215

214216
<div className="max-w-[68ch] text-fg">
@@ -219,7 +221,7 @@ export function ArticleReaderClient({
219221
<MarkdownContent content={bodyParts[1]} autoEmbed className="text-lg leading-[1.7]" />
220222
</>
221223
) : (
222-
<MarkdownContent content={article.content} autoEmbed className="text-lg leading-[1.7]" />
224+
<MarkdownContent content={body} autoEmbed className="text-lg leading-[1.7]" />
223225
)}
224226
</div>
225227

‎src/app/(app)/(main)/colleges/colleges-client.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ export default function CollegesClient({
222222
<main className="mx-auto flex min-h-dvh w-full max-w-3xl flex-col gap-4 pt-4 pb-12">
223223
<header className="flex flex-wrap items-end justify-between gap-3">
224224
<div className="min-w-0">
225-
<h1 className="text-3xl font-bold text-fg">Colleges</h1>
225+
<h1 className="font-display text-3xl font-extrabold text-fg">Colleges</h1>
226226
<p className="mt-1 text-sm text-fg-muted">
227227
{total > 0 ? `${total.toLocaleString("en-IN")} colleges. ` : ""}Find yours and see what students
228228
are posting.

‎src/app/(app)/(main)/feeds/feed-client.tsx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { FeedCaughtUpCard, FeedEmptyState, FeedErrorState } from "@/components/f
1313
import { LocationOptInCard } from "@/components/geo/location-opt-in-card";
1414
import { SignupWallCard } from "@/components/growth/signup-wall-card";
1515
import { SocialProofChips } from "@/components/growth/social-proof-chips";
16+
import { SeasonBanner } from "@/components/seasons/season-banner";
1617
import { Button } from "@/components/ui/button";
1718
import { FeedCard } from "@/components/ui/feed-card";
1819
import { InlineCommunitiesWidget } from "@/components/ui/inline-feed-widgets";
@@ -229,6 +230,8 @@ export function FeedClient({ forcedType }: { forcedType?: string }) {
229230

230231
{!forcedType && <HomeTabs active="feed" className="border-b border-border" />}
231232

233+
{!forcedType && <SeasonBanner className="border-b border-border" />}
234+
232235
{!signedOut && <SocialProofChips className="border-b border-border" />}
233236

234237
{/* Stories only take space when someone has actually posted one. */}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import type { Metadata } from "next";
2+
import { SeasonView } from "@/components/seasons/season-view";
3+
import { PLAY_ROUTES } from "@/constants/play";
4+
import { SEASON_ROUTE } from "@/constants/seasons";
5+
import { challengeProgress, getNextSeason, getSeasonById } from "@/lib/seasons";
6+
import { getSeasonCounts } from "@/lib/seasons/progress";
7+
import { getServerSeason } from "@/lib/seasons/server";
8+
import { breadcrumbJsonLd, buildMetadata } from "@/lib/seo";
9+
import { fitDescription } from "@/lib/seo/describe";
10+
import { JsonLd } from "@/lib/seo/json-ld-script";
11+
import { getCachedAuthUser, getCachedBareProfile } from "@/lib/server-cache";
12+
13+
type Props = { searchParams: Promise<Record<string, string | string[] | undefined>> };
14+
15+
export const dynamic = "force-dynamic";
16+
17+
export async function generateMetadata(): Promise<Metadata> {
18+
const { season } = await getServerSeason();
19+
return buildMetadata({
20+
title: season ? `${season.name}: season challenges` : "Seasons and challenges",
21+
description: fitDescription(
22+
season
23+
? `${season.tagline} ${season.challenges.length} challenges for students on CampusLoop.`
24+
: "Every few weeks CampusLoop gets a new look and a new set of challenges for students.",
25+
["See what is on and how far you are"]
26+
),
27+
path: SEASON_ROUTE,
28+
});
29+
}
30+
31+
export default async function SeasonPage({ searchParams }: Props) {
32+
const [params, live, user] = await Promise.all([searchParams, getServerSeason(), getCachedAuthUser()]);
33+
const profile = user ? await getCachedBareProfile(user.id) : null;
34+
const now = live.now;
35+
36+
// Preview: ?season=<id> (or "off") works in development and for admins only.
37+
const isDev = process.env.NODE_ENV === "development";
38+
const wanted = typeof params.season === "string" ? params.season : null;
39+
let season = live.season;
40+
if (wanted && (isDev || profile?.role === "ADMIN")) {
41+
season = wanted === "off" ? null : (getSeasonById(wanted) ?? live.season);
42+
}
43+
44+
let progress = null;
45+
if (season && profile?.onboardingCompleted) {
46+
progress = challengeProgress(season, await getSeasonCounts(profile.id, season));
47+
}
48+
// Development only: look at the finished state without touching data.
49+
if (isDev && season && params.progress === "complete") {
50+
progress = season.challenges.map((c) => ({ id: c.id, count: c.target, target: c.target, done: true, ratio: 1 }));
51+
}
52+
53+
return (
54+
<>
55+
<JsonLd
56+
data={breadcrumbJsonLd([
57+
{ name: "Play", path: PLAY_ROUTES.hub },
58+
{ name: season ? season.name : "Seasons", path: SEASON_ROUTE },
59+
])}
60+
/>
61+
<SeasonView
62+
season={season}
63+
next={getNextSeason(now, season?.id)}
64+
progress={progress}
65+
now={now}
66+
signInHref={`/sign-in?returnTo=${SEASON_ROUTE}`}
67+
/>
68+
</>
69+
);
70+
}

‎src/app/(app)/(main)/settings/preferences-sections.tsx‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { useEffect, useState } from "react";
44
import { toast } from "sonner";
55
import { SegmentedControl } from "@/components/ui/segmented-control";
6+
import { SEASON_STORAGE } from "@/constants/seasons";
67
import { haptics } from "@/lib/haptics";
78
import { sounds } from "@/lib/sounds";
89
import { SettingsRow, SettingsSection, SwitchRow, useLocalPref } from "./settings-ui";
@@ -138,6 +139,7 @@ export function AppSection() {
138139
"never",
139140
] as const);
140141
const [reducedMotion, setReducedMotion] = useBoolPref("campusloop_reduced_motion", false);
142+
const [seasonFx, setSeasonFx] = useLocalPref(SEASON_STORAGE.effects, "on", ["on", "off"] as const);
141143

142144
useEffect(() => {
143145
try {
@@ -207,6 +209,17 @@ export function AppSection() {
207209
]}
208210
/>
209211
</SettingsRow>
212+
<SwitchRow
213+
label="Seasonal effects"
214+
description="Snow and other moving decoration during a season. Season colours stay."
215+
checked={seasonFx === "on"}
216+
onChange={(v) => {
217+
setSeasonFx(v ? "on" : "off");
218+
// The decoration layer reads this attribute (see the Seasons block in globals.css).
219+
if (v) document.documentElement.removeAttribute("data-season-fx");
220+
else document.documentElement.setAttribute("data-season-fx", "off");
221+
}}
222+
/>
210223
<SwitchRow
211224
label="Reduce motion"
212225
description="Fewer animations."

‎src/app/about/page.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ export default async function AboutPage() {
131131
<h2 id="features" className="text-3xl text-fg md:text-4xl">
132132
What's inside
133133
</h2>
134-
<div className="mt-8 grid gap-x-10 gap-y-10 sm:grid-cols-2 lg:grid-cols-4">
134+
<div className="mt-8 divide-y divide-border rounded-lg border border-border bg-surface">
135135
{FEATURE_GROUPS.map((group) => (
136-
<div key={group.id}>
137-
<h3 className="font-sans text-sm font-semibold text-fg-subtle">{group.group}</h3>
138-
<ul className="mt-3 space-y-1">
136+
<div key={group.id} className="grid gap-x-8 gap-y-2 p-5 sm:p-6 md:grid-cols-[9rem_minmax(0,1fr)]">
137+
<h3 className="font-sans text-base font-semibold text-fg md:pt-2">{group.group}</h3>
138+
<ul className="grid gap-x-6 sm:grid-cols-2 lg:grid-cols-3">
139139
{group.items.map((item) => (
140140
<li key={item.href}>
141141
<Link

‎src/app/admin/seasons/actions.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"use server";
2+
3+
import { revalidatePath } from "next/cache";
4+
import type { SeasonSetting } from "@/lib/seasons";
5+
import { saveSeasonSetting } from "@/lib/seasons/server";
6+
import { requireAdminProfile } from "../_lib/guard";
7+
8+
/** Saves "auto", "off" or a season id. Other Worker isolates pick it up within 60s. */
9+
export async function updateActiveSeason(input: string): Promise<SeasonSetting> {
10+
const { profile } = await requireAdminProfile();
11+
const saved = await saveSeasonSetting(input);
12+
console.info(`[admin/seasons] active season set to "${saved}" by ${profile.id}`);
13+
revalidatePath("/admin/seasons");
14+
return saved;
15+
}

‎src/app/admin/seasons/page.tsx‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { Snowflake } from "lucide-react";
2+
import type { Metadata } from "next";
3+
import { SEASONS } from "@/constants/seasons";
4+
import { istDate } from "@/lib/ist-date";
5+
import { getActiveSeason, istDayStart, seasonLengthDays, seasonStatus } from "@/lib/seasons";
6+
import { getServerSeason, getSeasonSetting } from "@/lib/seasons/server";
7+
import { privateMetadata } from "@/lib/seo";
8+
import { AdminPageHeader } from "../_components/admin-page-header";
9+
import { resolveAdminSession } from "../_lib/guard";
10+
import { type SeasonRow, SeasonsClient } from "./seasons-client";
11+
12+
export const metadata: Metadata = privateMetadata("Seasons");
13+
14+
export const dynamic = "force-dynamic";
15+
16+
const day = (date: string) => istDate(istDayStart(date), { year: true }) ?? date;
17+
18+
export default async function AdminSeasonsPage() {
19+
await resolveAdminSession();
20+
// Read fresh on this page so the admin sees what was last saved.
21+
const setting = await getSeasonSetting({ fresh: true });
22+
const { now } = await getServerSeason();
23+
const byDate = getActiveSeason(now, "auto");
24+
25+
const rows: SeasonRow[] = SEASONS.map((s) => ({
26+
id: s.id,
27+
name: s.name,
28+
tagline: s.tagline,
29+
dates: `${day(s.startsAt)} to ${day(s.endsAt)}`,
30+
days: seasonLengthDays(s),
31+
status: seasonStatus(s, now),
32+
decoration: s.decoration,
33+
challenges: s.challenges.length,
34+
swatches: [
35+
{ label: "Light action", value: s.theme.light["--brand"] },
36+
{ label: "Dark action", value: s.theme.dark["--brand"] },
37+
{ label: "Accent", value: s.theme.light["--season-accent"] },
38+
{ label: "Glow", value: s.theme.light["--season-glow"] },
39+
{ label: "Field", value: s.theme.light["--season-field"] },
40+
].filter((x): x is { label: string; value: string } => Boolean(x.value)),
41+
}));
42+
43+
return (
44+
<div className="space-y-6">
45+
<AdminPageHeader
46+
title="Seasons"
47+
icon={Snowflake}
48+
description="Each season changes the app's colours, adds a light decoration and a set of challenges. Seasons are defined in src/constants/seasons.ts."
49+
/>
50+
<SeasonsClient initial={setting} rows={rows} byDateId={byDate?.id ?? null} />
51+
</div>
52+
);
53+
}

0 commit comments

Comments
 (0)