diff --git a/cshare-app/src/components/Navbar.jsx b/cshare-app/src/components/Navbar.jsx new file mode 100644 index 0000000..be71edb --- /dev/null +++ b/cshare-app/src/components/Navbar.jsx @@ -0,0 +1,165 @@ +import { useState, useEffect } from 'react'; +import { useNavigate, useLocation } from 'react-router-dom'; +import { MenuIcon, XIcon } from './Icons'; + +export default function Navbar() { + const navigate = useNavigate(); + const { pathname } = useLocation(); + const [mobileOpen, setMobileOpen] = useState(false); + const [scrolled, setScrolled] = useState(false); + + useEffect(() => { + const onScroll = () => setScrolled(window.scrollY > 20); + window.addEventListener('scroll', onScroll, { passive: true }); + return () => window.removeEventListener('scroll', onScroll); + }, []); + + const links = [ + { path: '/', label: 'Home' }, + { path: '/upload', label: 'Upload' }, + { path: '/dashboard', label: 'Dashboard' }, + { path: '/preview', label: 'Preview' }, + ]; + + const extraLinks = [ + { + label: 'Features', + action: () => { + navigate('/'); + setTimeout(() => document.getElementById('features')?.scrollIntoView({ behavior: 'smooth' }), 150); + }, + }, + { + label: 'How it Works', + action: () => { + navigate('/'); + setTimeout(() => document.getElementById('how-it-works')?.scrollIntoView({ behavior: 'smooth' }), 150); + }, + }, + { label: 'Pricing', action: () => go('/pricing') }, + { label: 'Docs', action: () => go('/docs') }, + ]; + + const go = (path) => { + navigate(path); + setMobileOpen(false); + window.scrollTo({ top: 0, behavior: 'smooth' }); + }; + + return ( + <> + + {mobileOpen && ( +
+ )} + > + ); +}