import React from 'react'; import AppBar from '@mui/material/AppBar'; import Toolbar from '@mui/material/Toolbar'; import Box from '@mui/material/Box'; import Drawer from '@mui/material/Drawer'; import List from '@mui/material/List'; import ListItemButton from '@mui/material/ListItemButton'; import ListItemText from '@mui/material/ListItemText'; import useMediaQuery from '@mui/material/useMediaQuery'; import MenuIcon from '@mui/icons-material/Menu'; import CloseIcon from '@mui/icons-material/Close'; import type { SxProps, Theme } from '@mui/material/styles'; import { IconButton } from '../../atoms/IconButton'; import { Link } from '../../atoms/Link'; import { Button } from '../../atoms/Button'; import { Typography } from '../../atoms/Typography'; import { Divider } from '../../atoms/Divider'; // ─── Types ─────────────────────────────────────────────────────────────────── /** A navigation link item */ export interface NavItem { /** Display label */ label: string; /** URL to navigate to */ href: string; /** Click handler (alternative to href for SPA navigation) */ onClick?: () => void; } /** Props for the FA Navigation organism */ export interface NavigationProps { /** Site logo — rendered on the left (desktop) or centre (mobile) */ logo: React.ReactNode; /** Click handler for the logo (navigate to home) */ onLogoClick?: () => void; /** Navigation links displayed in the header */ items?: NavItem[]; /** Optional CTA button (e.g. "Start planning") on desktop */ ctaLabel?: string; /** Click handler for the CTA button */ onCtaClick?: () => void; /** MUI sx prop for the root AppBar */ sx?: SxProps; } // ─── Component ─────────────────────────────────────────────────────────────── /** * Site header navigation for the FA design system. * * Responsive header with logo, navigation links, and optional CTA. * Desktop shows links inline; mobile collapses to hamburger + drawer. * * Maps to Figma "Main Nav" (14:108) desktop and "Mobile Header" * (2391:41508) mobile patterns. * * Composes AppBar + Link + IconButton + Button + Divider + Drawer. * * Usage: * ```tsx * } * onLogoClick={() => navigate('/')} * items={[ * { label: 'FAQ', href: '/faq' }, * { label: 'Contact Us', href: '/contact' }, * { label: 'Log in', href: '/login' }, * ]} * ctaLabel="Start planning" * onCtaClick={() => navigate('/arrange')} * /> * ``` */ export const Navigation = React.forwardRef( ({ logo, onLogoClick, items = [], ctaLabel, onCtaClick, sx }, ref) => { const [drawerOpen, setDrawerOpen] = React.useState(false); const isMobile = useMediaQuery((theme: Theme) => theme.breakpoints.down('md')); const handleDrawerToggle = () => setDrawerOpen((prev) => !prev); return ( <> {/* Left: hamburger (mobile) + logo */} {isMobile && ( )} { e.preventDefault(); onLogoClick(); } : undefined } sx={{ display: 'flex', alignItems: 'center', cursor: onLogoClick ? 'pointer' : 'default', textDecoration: 'none', color: 'inherit', }} aria-label={onLogoClick ? 'Home' : undefined} > {logo} {/* Right: nav links (desktop) or trailing content (mobile) */} {!isMobile ? ( {items.map((item) => ( {item.label} ))} {ctaLabel && ( )} ) : null} {/* Mobile drawer */} {isMobile && ( {/* Drawer header */} {logo} {/* Nav items */} {items.map((item) => ( { if (item.onClick) { e.preventDefault(); item.onClick(); } setDrawerOpen(false); }} sx={{ py: 1.5, px: 3, minHeight: 44, '&:hover': { bgcolor: 'var(--fa-color-brand-100)', }, }} > ))} {ctaLabel && ( )} {/* Footer */} Need help? Call us on 1800 987 888 )} ); }, ); Navigation.displayName = 'Navigation'; export default Navigation;