import { useState, useEffect } from 'react'; import { Link as RouterLink, useLocation } from 'react-router-dom'; import { AppBar, Toolbar, Typography, Button, Box, IconButton, Drawer, List, ListItem, ListItemButton, ListItemText, useMediaQuery, useTheme, Link, Container, } from '@mui/material'; import MenuIcon from '@mui/icons-material/Menu'; import CloseIcon from '@mui/icons-material/Close'; import OpenInNewIcon from '@mui/icons-material/OpenInNew'; const navItems = [ { label: 'Apps', href: '/apps' }, { label: 'Get Started', href: '/getting-started' }, { label: 'Download', href: '/download' }, { label: 'Build', href: '/build' }, { label: 'FAQ', href: '/faq' }, { label: 'Community', href: 'https://discord.gg/2bAhWfXme9', external: true }, ]; export default function Header({ transparent = false }) { const [mobileOpen, setMobileOpen] = useState(false); const [scrolled, setScrolled] = useState(false); const theme = useTheme(); const isMobile = useMediaQuery(theme.breakpoints.down('md')); const location = useLocation(); // Track scroll position for transparent header useEffect(() => { if (!transparent) return; const handleScroll = () => { setScrolled(window.scrollY > 80); }; window.addEventListener('scroll', handleScroll); return () => window.removeEventListener('scroll', handleScroll); }, [transparent]); const handleDrawerToggle = () => { setMobileOpen(!mobileOpen); }; const handleNavClick = () => { setMobileOpen(false); }; // Determine colors based on transparent mode and scroll state const isTransparentMode = transparent && !scrolled; const textColor = isTransparentMode ? 'white' : 'text.primary'; const bgColor = isTransparentMode ? 'transparent' : 'rgba(255, 255, 255, 0.85)'; const backdropFilter = isTransparentMode ? 'none' : 'saturate(180%) blur(20px)'; const drawer = ( Reachy Mini {navItems.map((item) => ( handleNavClick(item)} sx={{ py: 1.5, px: 2, borderRadius: 2, '&:hover': { backgroundColor: 'rgba(0,0,0,0.04)', }, }} > {item.label} {item.external && ( )} } /> ))} ); return ( <> {/* Logo */} Reachy Mini {isMobile ? ( ) : ( {/* Nav Links */} {navItems.map((item) => ( item.external ? ( {item.label} ) : ( handleNavClick(item)} sx={{ color: textColor, textDecoration: location.pathname === item.href ? 'underline' : 'none', textUnderlineOffset: 6, textDecorationThickness: 2, fontSize: 15, fontWeight: location.pathname === item.href ? 600 : 500, opacity: location.pathname === item.href ? 1 : 0.85, transition: 'opacity 0.2s', whiteSpace: 'nowrap', '&:hover': { opacity: 1, }, }} > {item.label} ) ))} {/* CTA Button */} )} {/* Mobile Drawer */} {drawer} {/* Spacer for fixed AppBar - only show if not transparent */} {!transparent && } ); }