Spaces:
Sleeping
Sleeping
| import { useState } from 'react'; | |
| import { Link, useLocation } from 'react-router-dom'; | |
| import { Menu, X } from 'lucide-react'; | |
| const Navbar = () => { | |
| const [isMenuOpen, setIsMenuOpen] = useState(false); | |
| const location = useLocation(); | |
| const toggleMenu = () => { | |
| setIsMenuOpen(!isMenuOpen); | |
| }; | |
| const navLinks = [ | |
| { name: 'Home', path: '/' }, | |
| { name: 'Vehicles', path: '/vehicles' }, | |
| { name: 'Plans', path: '/pricing' }, | |
| { name: 'Locations', path: '/locations' }, | |
| { name: 'About', path: '/about' }, | |
| ]; | |
| return ( | |
| <header className="bg-[#0a0a0a]/80 backdrop-blur-md sticky top-0 z-50 border-b border-gray-800"> | |
| <div className="container mx-auto px-4 md:px-6 py-4"> | |
| <div className="flex items-center justify-between"> | |
| <Link to="/" className="flex items-center space-x-2"> | |
| <span className="text-blue-500 text-2xl font-bold">Unity Fleet</span> | |
| </Link> | |
| {/* Desktop Navigation */} | |
| <nav className="hidden md:flex items-center space-x-10"> | |
| {navLinks.map((link) => ( | |
| <Link | |
| key={link.path} | |
| to={link.path} | |
| className={`text-sm font-medium transition-colors hover:text-blue-500 ${ | |
| location.pathname === link.path ? 'text-blue-500' : 'text-gray-300' | |
| }`} | |
| > | |
| {link.name} | |
| </Link> | |
| ))} | |
| </nav> | |
| <div className="hidden md:flex items-center space-x-4"> | |
| <Link | |
| to="/dashboard" | |
| className="bg-blue-600 hover:bg-blue-700 px-4 py-2 rounded-md text-white text-sm font-medium transition-colors" | |
| > | |
| Dashboard | |
| </Link> | |
| </div> | |
| {/* Mobile Menu Button */} | |
| <button | |
| onClick={toggleMenu} | |
| className="md:hidden text-gray-300 hover:text-white" | |
| aria-label="Toggle Menu" | |
| > | |
| {isMenuOpen ? <X size={24} /> : <Menu size={24} />} | |
| </button> | |
| </div> | |
| </div> | |
| {/* Mobile Navigation */} | |
| {isMenuOpen && ( | |
| <div className="md:hidden bg-[#0a0a0a] border-t border-gray-800"> | |
| <div className="container mx-auto px-4 py-4"> | |
| <nav className="flex flex-col space-y-4"> | |
| {navLinks.map((link) => ( | |
| <Link | |
| key={link.path} | |
| to={link.path} | |
| className={`text-sm font-medium transition-colors hover:text-blue-500 ${ | |
| location.pathname === link.path ? 'text-blue-500' : 'text-gray-300' | |
| }`} | |
| onClick={() => setIsMenuOpen(false)} | |
| > | |
| {link.name} | |
| </Link> | |
| ))} | |
| <Link | |
| to="/dashboard" | |
| className="bg-blue-600 hover:bg-blue-700 px-4 py-2 rounded-md text-white text-sm font-medium transition-colors text-center" | |
| onClick={() => setIsMenuOpen(false)} | |
| > | |
| Dashboard | |
| </Link> | |
| </nav> | |
| </div> | |
| </div> | |
| )} | |
| </header> | |
| ); | |
| }; | |
| export default Navbar; | |