import { useEffect, useRef, useState, type MouseEvent, type ReactNode } from 'react' import { Link, useNavigate } from 'react-router-dom' import { ChevronDownIcon } from '@heroicons/react/24/outline' import { homeExploreSectionHash, type HomeQuickNavGroupId } from '../data/exploreActionPhases' import { flyoutIcons, homeQuickNavFlyoutItems, resolveHomeFlyoutHref, type HomeFlyoutItem, } from '../data/homeQuickNavFlyouts' const T = { tealDark: '#1b3c39', tealMid: '#2d6b65', tealLight: '#4a9e96', tealPale: '#e6f3f2', accent: '#f0a500', accentPale: '#fff4d6', white: '#ffffff', textDark: '#1a2e2d', textMid: '#4a6665', textLight: '#8aabaa', border: '#ddecea', } as const /** Outline nav icons (reference: light gray idle, white on teal hover) */ function NavIcon({ children, stroke }: { children: ReactNode; stroke: string }) { return ( {children} ) } const NAV_ROW_ICONS: Record ReactNode> = { cause: (stroke) => ( ), plan: (stroke) => ( ), find: (stroke) => ( ), track: (stroke) => ( ), build: (stroke) => ( ), } const MARKETING_ROWS: { id: HomeQuickNavGroupId; label: string; sub: string }[] = [ { id: 'cause', label: 'Choose a Cause', sub: 'Pick what matters to you first' }, { id: 'plan', label: 'Make a Plan', sub: 'Personal and community paths, allies, and outcomes' }, { id: 'find', label: 'Find Help', sub: 'Nonprofits, programs, and family supports' }, { id: 'track', label: 'Track Decisions', sub: 'Meetings, budgets, maps, and verification' }, { id: 'build', label: 'Build With Data', sub: 'Open datasets & API' }, ] /** Drill-down links: compact rows with a light motion on hover. */ function DrilldownLinkRow({ item, onPick, styleDelay }: { item: HomeFlyoutItem; onPick: () => void; styleDelay: number }) { const href = resolveHomeFlyoutHref(item.to) const icon = flyoutIcons[item.iconKey]('currentColor') const className = 'group/drill flex items-center gap-2.5 rounded-lg px-2 py-1.5 text-left text-sm font-medium text-slate-800 transition-[background-color,transform,box-shadow] duration-200 hover:bg-white hover:shadow-sm hover:ring-1 hover:ring-slate-200/80 active:scale-[0.99]' const iconWrap = ( {icon} ) const label = {item.label} const motionStyle = { transitionDelay: `${styleDelay}ms` } as const if (item.external) { return ( {iconWrap} {label} ) } return ( {iconWrap} {label} ) } type HomeExploreQuickNavProps = { /** e.g. close app layout mobile drawer after following a link */ onNavigate?: () => void /** * When > 0, clicking a section title waits this many ms before navigating to Explore. * A second click while waiting cancels navigation and toggles the shortcut panel (same as the chevron). * Use on Data explorer (and similar) so two quick taps expand without leaving the page first. */ deferSectionNavigationMs?: number } export default function HomeExploreQuickNav({ onNavigate, deferSectionNavigationMs = 0, }: HomeExploreQuickNavProps) { const navigate = useNavigate() const [expandedId, setExpandedId] = useState(null) const pendingSectionNavRef = useRef | null>(null) useEffect( () => () => { if (pendingSectionNavRef.current) clearTimeout(pendingSectionNavRef.current) }, [], ) const closePanels = () => { setExpandedId(null) onNavigate?.() } function toggleExpanded(id: HomeQuickNavGroupId) { setExpandedId((cur) => (cur === id ? null : id)) } function handleSectionTitleClick(rowId: HomeQuickNavGroupId, exploreHref: string, e: MouseEvent) { if (deferSectionNavigationMs <= 0) { closePanels() return } e.preventDefault() if (pendingSectionNavRef.current != null) { clearTimeout(pendingSectionNavRef.current) pendingSectionNavRef.current = null toggleExpanded(rowId) return } pendingSectionNavRef.current = setTimeout(() => { pendingSectionNavRef.current = null closePanels() navigate(exploreHref) }, deferSectionNavigationMs) } return (

Quick Navigation

) }