Replace the front page with an admin-driven home
The home page is rebuilt from scratch and configured from a new Front page tab in the admin, backed by migration 017 and served by GET /api/front-page. Hero: brand, photos (crossfading slideshow with progress and pause) or livestream (YouTube/Facebook/Vimeo embed with a LIVE badge), switched by hand. After it, bands the admin can reorder, retitle or hide: a countdown to the next event (series-aware), the National Retreats carousel, a numbers band (typed in or counted from the database), a horizontal rail of featured timeline entries, and a "Find your way in" pathfinder replacing the old connect section. The CRUD engine gains a `singleton` flag: the entity has one row, made by its migration, and create and delete are refused. The list screen opens that row and the editor drops the slug, back link and delete. shapeSeries moves to shape.js so /front-page can share it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b4b013209b
commit
6a69084de2
25 changed files with 2299 additions and 494 deletions
186
src/pages/sections/home/Pathfinder.tsx
Normal file
186
src/pages/sections/home/Pathfinder.tsx
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
PATHFINDER — "Find your way in"
|
||||
|
||||
The connect section as a question rather than a wall of forms:
|
||||
pick what you're here for, and that path's actions arrive. Paths
|
||||
and actions are the admin's (Front page → Find your way in);
|
||||
a path with no actions never reaches this component.
|
||||
|
||||
The choices are a real tablist: arrow keys move between them,
|
||||
Home and End jump to the ends, and only the selected tab is in
|
||||
the tab order. Selection follows focus, which is right when
|
||||
showing a panel costs nothing.
|
||||
|
||||
Re-keying the panel on the selected index is what replays the
|
||||
entrance animation for each choice.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { useId, useRef, useState, type KeyboardEvent } from 'react'
|
||||
|
||||
import HomeLink, { isExternal } from './HomeLink.tsx'
|
||||
import type { FrontPagePath } from '../../../lib/useFrontPage.ts'
|
||||
|
||||
type PathfinderProps = {
|
||||
id: string
|
||||
title: string
|
||||
blurb?: string | null
|
||||
paths: FrontPagePath[]
|
||||
}
|
||||
|
||||
/* One accent per position, cycling. Paths are data; colour is
|
||||
presentation, so it's assigned here rather than stored. */
|
||||
const ACCENTS = ['#138ba0', '#10a36e', '#c7972b', '#7a5ea8', '#d0643c']
|
||||
|
||||
export default function Pathfinder({ id, title, blurb, paths }: PathfinderProps) {
|
||||
const [selected, setSelected] = useState(0)
|
||||
const tabs = useRef<Array<HTMLButtonElement | null>>([])
|
||||
const base = useId().replace(/:/g, '')
|
||||
|
||||
if (paths.length === 0) return null
|
||||
|
||||
const path = paths[Math.min(selected, paths.length - 1)]
|
||||
const accent = ACCENTS[selected % ACCENTS.length]
|
||||
|
||||
const focus = (index: number) => {
|
||||
const next = (index + paths.length) % paths.length
|
||||
setSelected(next)
|
||||
tabs.current[next]?.focus()
|
||||
}
|
||||
|
||||
const onKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {
|
||||
const moves: Record<string, number> = {
|
||||
ArrowRight: selected + 1,
|
||||
ArrowDown: selected + 1,
|
||||
ArrowLeft: selected - 1,
|
||||
ArrowUp: selected - 1,
|
||||
Home: 0,
|
||||
End: paths.length - 1,
|
||||
}
|
||||
if (!(e.key in moves)) return
|
||||
e.preventDefault()
|
||||
focus(moves[e.key])
|
||||
}
|
||||
|
||||
return (
|
||||
<section id={id} className="py-24" style={{ background: '#ffffff' }}>
|
||||
<div className="mx-auto max-w-6xl px-6">
|
||||
<div className="grid gap-12 lg:grid-cols-12">
|
||||
<div className="lg:col-span-5">
|
||||
<p className="text-xs font-bold uppercase tracking-[0.3em] text-[#138ba0]">
|
||||
I’m looking to…
|
||||
</p>
|
||||
<h2 className="mt-3 font-display text-4xl font-extrabold text-[#073d4a] md:text-5xl">
|
||||
{title}
|
||||
</h2>
|
||||
{blurb && <p className="mt-4 text-lg text-[#4a6b72]">{blurb}</p>}
|
||||
|
||||
<div
|
||||
role="tablist"
|
||||
aria-label={title}
|
||||
aria-orientation="vertical"
|
||||
className="mt-10 flex flex-col gap-3"
|
||||
onKeyDown={onKeyDown}
|
||||
>
|
||||
{paths.map((option, index) => {
|
||||
const on = index === selected
|
||||
const color = ACCENTS[index % ACCENTS.length]
|
||||
return (
|
||||
<button
|
||||
key={`${option.label}-${index}`}
|
||||
ref={(el) => {
|
||||
tabs.current[index] = el
|
||||
}}
|
||||
id={`${base}-tab-${index}`}
|
||||
role="tab"
|
||||
type="button"
|
||||
aria-selected={on}
|
||||
aria-controls={`${base}-panel`}
|
||||
tabIndex={on ? 0 : -1}
|
||||
onClick={() => setSelected(index)}
|
||||
className="group flex items-center gap-4 rounded-2xl border-2 px-5 py-4 text-left transition-all duration-300"
|
||||
style={{
|
||||
borderColor: on ? color : 'rgba(19,139,160,0.12)',
|
||||
background: on ? `${color}12` : '#ffffff',
|
||||
transform: on ? 'translateX(8px)' : undefined,
|
||||
}}
|
||||
>
|
||||
<span
|
||||
className="flex h-12 w-12 shrink-0 items-center justify-center rounded-xl text-2xl transition-transform duration-300 group-hover:scale-110"
|
||||
style={{ background: on ? color : `${color}1f` }}
|
||||
aria-hidden="true"
|
||||
>
|
||||
{option.icon || '•'}
|
||||
</span>
|
||||
<span className="font-display text-xl font-bold" style={{ color: on ? color : '#073d4a' }}>
|
||||
{option.label}
|
||||
</span>
|
||||
<span
|
||||
className="ml-auto text-xl transition-opacity"
|
||||
style={{ color, opacity: on ? 1 : 0 }}
|
||||
aria-hidden="true"
|
||||
>
|
||||
→
|
||||
</span>
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
key={selected}
|
||||
id={`${base}-panel`}
|
||||
role="tabpanel"
|
||||
aria-labelledby={`${base}-tab-${selected}`}
|
||||
className="relative overflow-hidden rounded-[2rem] p-8 md:p-10 lg:col-span-7"
|
||||
style={{ background: `linear-gradient(155deg, ${accent}14, ${accent}05 60%, #ffffff)` }}
|
||||
>
|
||||
<span
|
||||
className="pointer-events-none absolute -right-6 -top-10 select-none text-[10rem] leading-none opacity-10"
|
||||
aria-hidden="true"
|
||||
>
|
||||
{path.icon}
|
||||
</span>
|
||||
|
||||
{path.blurb && (
|
||||
<p className="hp-pop relative max-w-md font-display text-2xl font-semibold leading-snug text-[#073d4a]">
|
||||
{path.blurb}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<ul className="relative mt-8 grid gap-4 sm:grid-cols-2">
|
||||
{path.actions.map((action, index) => (
|
||||
<li
|
||||
key={`${action.url}-${index}`}
|
||||
className="hp-pop"
|
||||
style={{ animationDelay: `${120 + index * 90}ms` }}
|
||||
>
|
||||
<HomeLink
|
||||
url={action.url}
|
||||
className="group flex h-full flex-col rounded-2xl bg-white p-6 shadow-sm ring-1 ring-black/5 transition-all duration-300 hover:-translate-y-1 hover:shadow-xl"
|
||||
>
|
||||
<span className="flex items-start gap-2 font-display text-lg font-bold text-[#073d4a]">
|
||||
{action.label}
|
||||
<span
|
||||
className="ml-auto transition-transform group-hover:translate-x-1"
|
||||
style={{ color: accent }}
|
||||
aria-hidden="true"
|
||||
>
|
||||
{isExternal(action.url) ? '↗' : '→'}
|
||||
</span>
|
||||
</span>
|
||||
{action.description && (
|
||||
<span className="mt-2 text-sm leading-relaxed text-[#4a6b72]">
|
||||
{action.description}
|
||||
</span>
|
||||
)}
|
||||
</HomeLink>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue