/* ═══════════════════════════════════════════════════════════════ 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. Drawn like the featured cards (FeaturedCards.tsx): one continuous block, no gaps and no frame, a colored rule between cells. The paths are a strip of cells along the top, the chosen one filled flat in its accent; under it, the path's blurb and its actions are cells of the same block. ═══════════════════════════════════════════════════════════════ */ import { ArrowRight, ArrowUpRight, BookOpen, CalendarBlank, ChatCircle, Compass, GraduationCap, HandHeart, Heart, House, MapPin, MusicNotes, Sparkle, Star, Tent, UsersThree, type Icon } from '@phosphor-icons/react' import { useId, useRef, useState, type CSSProperties, type KeyboardEvent } from 'react' import HomeLink, { isExternal } from './HomeLink.tsx' import type { FrontPagePath } from '../../../lib/useFrontPage.ts' import { ACCENTS, accentText, readableOn } from '../../../lib/color.ts' type PathfinderProps = { id: string title: string blurb?: string | null paths: FrontPagePath[] } /* One accent per position, cycling. Paths are data; color is presentation, so it's assigned here rather than stored. */ /* A path's icon: a key from src/data/pathIcons.ts, drawn from Phosphor. A path saved before the list existed may hold an emoji; that shows as it is. Nothing set is a dot. */ const ICONS: Record = { heart: Heart, hands: HandHeart, people: UsersThree, calendar: CalendarBlank, tent: Tent, map: MapPin, home: House, book: BookOpen, learn: GraduationCap, chat: ChatCircle, music: MusicNotes, compass: Compass, sparkle: Sparkle, star: Star, } function PathIcon({ value }: { value?: string | null }) { const Glyph = value ? ICONS[value] : null if (Glyph) return return <>{value || '•'} } // The site's accent family, in turn (color.ts). const PATH_ACCENTS = [ACCENTS.teal, ACCENTS.green, ACCENTS.olive, ACCENTS.deep] export default function Pathfinder({ id, title, blurb, paths }: PathfinderProps) { const [selected, setSelected] = useState(0) const tabs = useRef>([]) const base = useId().replace(/:/g, '') if (paths.length === 0) return null const path = paths[Math.min(selected, paths.length - 1)] const accent = PATH_ACCENTS[selected % PATH_ACCENTS.length] const focus = (index: number) => { const next = (index + paths.length) % paths.length setSelected(next) tabs.current[next]?.focus() } const onKeyDown = (e: KeyboardEvent) => { const moves: Record = { 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]) } // A cell's rules: right and bottom, the outer ones clipped off // by the wrapper (the grid runs 4px past it). const cell = 'border-r-4 border-b-4 border-brand' const panelFill = `color-mix(in srgb, ${accent} 12%, var(--color-surface))` return (

{title}

{blurb &&

{blurb}

}
{paths.map((option, index) => { const on = index === selected const color = PATH_ACCENTS[index % PATH_ACCENTS.length] return ( ) })}
{path.blurb && (

{path.blurb}

)} {path.actions.map((action, index) => ( {action.label} {action.description && ( {action.description} )} ))}
) }