import { useState, useRef, useEffect } from 'react'; import { Link, useNavigate, useLocation } from 'react-router-dom'; import { useAuthStore } from '../../store/useAuthStore'; import { useProjectStore } from '../../store/useProjectStore'; import { ShareModal } from './ShareModal'; import { trackVisitGitHub, trackVisitDiscord } from '../../utils/analytics'; const GITHUB_URL = 'https://github.com/davidmonterocrespo24/velxio'; const DISCORD_URL = 'https://discord.gg/3mARjJrh4E'; interface AppHeaderProps {} export const AppHeader: React.FC = () => { const user = useAuthStore((s) => s.user); const logout = useAuthStore((s) => s.logout); const navigate = useNavigate(); const location = useLocation(); const currentProject = useProjectStore((s) => s.currentProject); const [dropdownOpen, setDropdownOpen] = useState(false); const [menuOpen, setMenuOpen] = useState(false); const [showShareModal, setShowShareModal] = useState(false); const dropdownRef = useRef(null); useEffect(() => { const handler = (e: MouseEvent) => { if (dropdownRef.current && !dropdownRef.current.contains(e.target as Node)) { setDropdownOpen(false); } }; document.addEventListener('mousedown', handler); return () => document.removeEventListener('mousedown', handler); }, []); // Close mobile menu on route change useEffect(() => { setMenuOpen(false); }, [location.pathname]); const handleLogout = async () => { setDropdownOpen(false); await logout(); navigate('/'); }; const isActive = (path: string) => location.pathname === path ? ' header-nav-link-active' : ''; return (
{/* Brand */}
Velxio
{/* Main nav links (desktop) */}
{/* Right: share + auth + mobile hamburger */}
{/* Share button — visible when a project is loaded */} {currentProject && location.pathname === '/editor' && ( )} {/* Auth UI */} {user ? (
{dropdownOpen && (
setDropdownOpen(false)} style={{ display: 'block', padding: '9px 14px', color: '#ccc', textDecoration: 'none', fontSize: 13 }} > My projects
)}
) : (
Sign in Sign up
)} {/* Mobile hamburger */}
{showShareModal && setShowShareModal(false)} />}
); };