- Colour tokens in index.css named by role (ink, body, muted, link, brand, action, surface, tint, danger), used everywhere instead of hex - Dark mode: follows the system, a header toggle (site and admin) overrides it and is remembered; set before first paint in index.html - Data colours go through src/lib/color.ts: withAlpha for tints, accentText (lighter on dark) for text in an accent, readableOn for text on one, so an admin's pale colour still reads - Migration 040 drops events.gradient: a card is its photo or plain, with its colour as the border; other decorative gradients are solid - The countdown and a hero event without a photo mix their colour toward ink behind white text Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
127 lines
4 KiB
TypeScript
127 lines
4 KiB
TypeScript
/* ═══════════════════════════════════════════════════════════════
|
|
PAGE SHELL
|
|
Just the chrome that makes pages look alike: a page header, then
|
|
sections with a thin accent banner between them, alternating
|
|
backgrounds, and a left-aligned heading with a blurb and rule.
|
|
|
|
Whatever goes inside a section is passed as `content`, the shell
|
|
doesn't care what it is.
|
|
|
|
No <main> and no footer here, Layout provides both, so a page
|
|
using this shell drops straight into the router's Outlet.
|
|
|
|
Usage:
|
|
<PageShell
|
|
title="Community"
|
|
intro="One line under the page title."
|
|
sections={[
|
|
{
|
|
id: "local", // matches the nav hash, #local
|
|
|
|
title: "Local Chapters",
|
|
blurb: "Optional line under the section heading.",
|
|
accent: "#0f7183", // heading, banner, rule
|
|
background: "var(--color-tint)",
|
|
actions: <SomeButton />, // optional, right of the heading
|
|
content: <YourStuff />,
|
|
},
|
|
]}
|
|
/>
|
|
═══════════════════════════════════════════════════════════════ */
|
|
|
|
import { useEffect, type ReactNode } from "react";
|
|
|
|
import { documentTitle } from "../lib/site.ts";
|
|
import { accentText } from '../lib/color.ts'
|
|
|
|
const TEAL = "#0f7183";
|
|
|
|
export type ShellSection = {
|
|
id: string;
|
|
title: string;
|
|
blurb?: string;
|
|
accent: string;
|
|
background: string;
|
|
actions?: ReactNode;
|
|
content: ReactNode;
|
|
};
|
|
|
|
type PageShellProps = {
|
|
title: ReactNode;
|
|
intro?: ReactNode;
|
|
sections: ShellSection[];
|
|
};
|
|
|
|
export function Section({ section }: { section: ShellSection }) {
|
|
const {
|
|
id,
|
|
title,
|
|
blurb,
|
|
accent,
|
|
background,
|
|
// Optional action bar for this section's heading row, a view
|
|
// toggle, a filter, a link. Whatever the section needs; the
|
|
// shell just gives it a place to sit.
|
|
actions,
|
|
content,
|
|
} = section;
|
|
|
|
return (
|
|
<section
|
|
id={id}
|
|
className="py-20"
|
|
style={{ background, scrollMarginTop: "5rem" }}
|
|
>
|
|
{/* Heading, left aligned, optional actions on the right */}
|
|
<div className="max-w-6xl mx-auto px-6 mb-10">
|
|
<div className="flex flex-wrap items-end justify-between gap-4">
|
|
<div>
|
|
<h2 className="text-4xl md:text-5xl font-extrabold" style={{ color: accentText(accent) }}>
|
|
{title}
|
|
</h2>
|
|
{blurb && <p className="mt-2 text-muted max-w-xl">{blurb}</p>}
|
|
</div>
|
|
{actions}
|
|
</div>
|
|
<div className="mt-6 h-px w-full" style={{ background: accent, opacity: 0.35 }} />
|
|
</div>
|
|
|
|
{content}
|
|
</section>
|
|
);
|
|
}
|
|
|
|
export default function PageShell({ title, intro, sections }: PageShellProps) {
|
|
// The tab's title as the visitor moves around. The first load's
|
|
// comes from the server (pageMeta.js), which also sets the page's
|
|
// description and preview for search and link sharing.
|
|
useEffect(() => {
|
|
if (typeof title === "string") document.title = documentTitle(title);
|
|
}, [title]);
|
|
|
|
return (
|
|
<>
|
|
{/* Page header */}
|
|
<div className="pt-24 pb-12 px-6" style={{ background: "var(--color-tint)" }}>
|
|
<div className="max-w-6xl mx-auto">
|
|
<h1 className="text-5xl md:text-6xl font-extrabold" style={{ color: accentText(TEAL) }}>
|
|
{title}
|
|
</h1>
|
|
{intro && <p className="mt-3 text-lg text-muted max-w-2xl">{intro}</p>}
|
|
</div>
|
|
</div>
|
|
|
|
{sections.map((section, i) => (
|
|
<div key={section.id}>
|
|
{/* Thin solid banner between sections */}
|
|
<div className="h-2" style={{ background: section.accent }} />
|
|
<Section section={section} />
|
|
{i === sections.length - 1 && (
|
|
<div className="h-2" style={{ background: section.accent }} />
|
|
)}
|
|
</div>
|
|
))}
|
|
|
|
</>
|
|
);
|
|
}
|