- Text contrast: teal text and button fills use #0f7183 (5.7:1), section accents darkened to pass on white, solid CTA buttons instead of the gradient, footer and subnav text raised to white/65, event and region colours kept on borders and swatches with ink text - Hidden carousel slides and collapsed past events are inert - Admin list rows carry a real link for keyboard use - Mobile menu is a modal dialog: focus, Escape, inert background, above the header - Skip to content link, one focus-visible ring, reduced-motion rule, focus rings on the calendar inputs - Region headings hold their button instead of sitting inside it - font-700 style classes (not Tailwind v4 utilities) replaced with named weights, and the 700/800 font files loaded - Migration 038: alt text for blog covers and schedule graphics; event logos next to their title are decorative - Drop the Church Center script from index.html; Giving loads it itself Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
147 lines
5 KiB
TypeScript
147 lines
5 KiB
TypeScript
/* ═══════════════════════════════════════════════════════════════
|
||
HOME: /
|
||
|
||
Not a PageShell page: the front page has no title bar, and each
|
||
band draws its own heading in its own style.
|
||
|
||
Driven by the admin's Front page editor through GET /front-page.
|
||
The hero comes first, always. After it, the bands in the order
|
||
the admin dragged them into, minus any they hid. Which component
|
||
draws a band is decided here, in SECTIONS, keyed on the same list
|
||
the CHECK on front_page_sections holds, the database says "retreats,
|
||
third, called National Retreats"; this file says what a retreats
|
||
band looks like.
|
||
|
||
A band with nothing to show draws nothing: the countdown with no
|
||
upcoming event, the numbers with no numbers, the timeline with
|
||
nothing featured, the pathfinder with no paths, the featured band
|
||
with no cards.
|
||
|
||
If /front-page fails, the hero still draws (empty) and the error
|
||
takes the place of the bands, with a retry. There's deliberately
|
||
no default page to fall back to: it would look fine and hide a
|
||
broken server.
|
||
═══════════════════════════════════════════════════════════════ */
|
||
|
||
import { useEffect, type ReactNode } from 'react'
|
||
|
||
import HeroStage from './sections/home/HeroStage.tsx'
|
||
import NextEventCountdown from './sections/home/NextEventCountdown.tsx'
|
||
import RetreatsBand from './sections/home/RetreatsBand.tsx'
|
||
import CalendarBand from './sections/home/CalendarBand.tsx'
|
||
import StatsBand from './sections/home/StatsBand.tsx'
|
||
import FeaturedBand from './sections/home/FeaturedBand.tsx'
|
||
import FeaturedTimelineRail from './sections/home/FeaturedTimelineRail.tsx'
|
||
import Pathfinder from './sections/home/Pathfinder.tsx'
|
||
import { documentTitle } from '../lib/site.ts'
|
||
import {
|
||
useFrontPage,
|
||
type FrontPage,
|
||
type FrontPageSection,
|
||
type FrontPageSectionKey,
|
||
} from '../lib/useFrontPage.ts'
|
||
import './sections/home/home.css'
|
||
|
||
type BandProps = {
|
||
page: FrontPage
|
||
section: FrontPageSection
|
||
title: string
|
||
/** Position among the visible bands, 0 = straight after the hero. */
|
||
position: number
|
||
}
|
||
|
||
/* Default headings for a band the admin didn't title, and how each
|
||
one renders. The ids are the page anchors, #connect is what the
|
||
hero's second button points at out of the box. */
|
||
const SECTIONS: Record<
|
||
FrontPageSectionKey,
|
||
{ title: string; render: (props: BandProps) => ReactNode }
|
||
> = {
|
||
countdown: {
|
||
title: 'Next up',
|
||
render: ({ page, position }) =>
|
||
page.countdown && <NextEventCountdown event={page.countdown} overlap={position === 0} />,
|
||
},
|
||
retreats: {
|
||
title: 'National Retreats',
|
||
render: ({ section, title }) => (
|
||
<RetreatsBand id="retreats" title={title} blurb={section.blurb} />
|
||
),
|
||
},
|
||
calendar: {
|
||
title: 'What’s on',
|
||
render: ({ section, title }) => (
|
||
<CalendarBand id="calendar" title={title} blurb={section.blurb} />
|
||
),
|
||
},
|
||
stats: {
|
||
title: 'By the numbers',
|
||
render: ({ page, section, title }) =>
|
||
page.stats.length > 0 && (
|
||
<StatsBand id="numbers" title={title} blurb={section.blurb} stats={page.stats} />
|
||
),
|
||
},
|
||
timeline: {
|
||
title: 'Our story so far',
|
||
render: ({ section, title }) => (
|
||
<FeaturedTimelineRail id="story" title={title} blurb={section.blurb} />
|
||
),
|
||
},
|
||
connect: {
|
||
title: 'Find your way in',
|
||
render: ({ page, section, title }) => (
|
||
<Pathfinder id="connect" title={title} blurb={section.blurb} paths={page.paths} />
|
||
),
|
||
},
|
||
featured: {
|
||
title: 'Featured',
|
||
render: ({ page, section, title }) =>
|
||
page.featured.length > 0 && (
|
||
<FeaturedBand id="featured" title={title} blurb={section.blurb} cards={page.featured} />
|
||
),
|
||
},
|
||
}
|
||
|
||
export default function Home() {
|
||
const { data: page, error, reload } = useFrontPage()
|
||
|
||
// Back to the site name when a visitor returns here from a page.
|
||
useEffect(() => {
|
||
document.title = documentTitle()
|
||
}, [])
|
||
|
||
return (
|
||
<>
|
||
<HeroStage hero={page?.hero ?? null} />
|
||
|
||
{error && (
|
||
<section className="px-6 py-24 text-center">
|
||
<p className="text-[#b3261e]">Couldn’t load the front page. {error}</p>
|
||
<button
|
||
type="button"
|
||
onClick={reload}
|
||
className="mt-4 rounded-full border border-[#138ba0] px-5 py-2 font-semibold text-[#0f7183] hover:bg-[#eef9fb]"
|
||
>
|
||
Try again
|
||
</button>
|
||
</section>
|
||
)}
|
||
|
||
{page?.sections.map((section, position) => {
|
||
const band = SECTIONS[section.section]
|
||
// A key the CHECK has gained since this file was written.
|
||
if (!band) return null
|
||
return (
|
||
<div key={section.section}>
|
||
{band.render({
|
||
page,
|
||
section,
|
||
title: section.title || band.title,
|
||
position,
|
||
})}
|
||
</div>
|
||
)
|
||
})}
|
||
</>
|
||
)
|
||
}
|