/** * The homepage sections after the hero (WEBSITE-1.0-PLAN §3), each in its variants. Templates * restyle the same markup through globals.css (cc-* classes) and the `t()` choices here. */ import { MessagePlayer } from "../MessagePlayer"; import { media, str, t } from "../load"; import { Button, cx, DateBadge, dayName, fmtDate, fmtTime, Img, Paragraphs, SectionHeading, type ButtonData } from "../parts"; import type { SectionProps, SiteEvent } from "../types"; import { Hero } from "./Hero"; const Section = ({ children, className, id }: { children: React.ReactNode; className?: string; id?: string }) => (
{children}
); const tz = (p: SectionProps) => p.site.church?.timezone ?? "Africa/Johannesburg"; // ─── Service times and location: Panel · Inline strip · With map ───────────────── function addressLines(p: SectionProps): string[] { const a = p.site.church?.contact.address; return a ? [a.line1, a.line2, [a.suburb, a.city].filter(Boolean).join(", ")].filter((x): x is string => !!x) : []; } function directions(p: SectionProps): string | null { const a = p.site.church?.contact.address; if (!a) return null; return a.geo ? `https://www.openstreetmap.org/?mlat=${a.geo.lat}&mlon=${a.geo.lng}#map=17/${a.geo.lat}/${a.geo.lng}` : `https://www.openstreetmap.org/search?query=${encodeURIComponent([a.line1, a.suburb, a.city].filter(Boolean).join(", "))}`; } function Times({ p, className }: { p: SectionProps; className?: string }) { const times = p.site.church?.serviceTimes ?? []; if (!times.length) return

Service times are coming soon.

; return ( ); } function ServiceTimes(p: SectionProps) { const d = p.section.data as { heading: string | null; note: string | null }; const lines = addressLines(p); const dir = directions(p); const heading = d.heading ?? "Service times"; if (p.section.variant === "strip") { const sundays = (p.site.church?.serviceTimes ?? []).filter((s) => s.day === "sunday").map((s) => s.time); return (

{heading}: {sundays.length ? `Sundays ${sundays.join(" & ")}` : "see below"}{lines[0] && <> · {lines.join(", ")}}

{dir && Get directions}
); } const panel = (

{heading}

{d.note &&

{d.note}

} {lines.length > 0 && (
{lines.map((l) => {l})} {dir && Get directions}
)}
); if (p.section.variant === "map") { const geo = p.site.church?.contact.address?.geo; return (
{panel} {geo ? (
{/* OpenStreetMap, loaded only when scrolled to (no Google, no cookies). */}