Files
Snigdha-OS.github.io/src/components/layout/Navbar.tsx
2024-12-25 03:38:05 +05:30

84 lines
3.1 KiB
TypeScript

import { useState } from 'react';
import { Link, useLocation } from 'react-router-dom';
import { Menu, X } from 'lucide-react';
import { cn } from '@/lib/utils';
import { navigation } from '@/data/navigation';
function Logo() {
return (
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M16 2L3 9V23L16 30L29 23V9L16 2Z" stroke="#6495ED" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M16 2V16M16 16V30M16 16L29 9M16 16L3 9" stroke="#6495ED" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
);
}
export function Navbar() {
const [isOpen, setIsOpen] = useState(false);
const location = useLocation();
return (
<nav className="fixed w-full z-50 bg-white/80 backdrop-blur-lg border-b border-gray-200">
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div className="flex justify-between h-16">
<div className="flex">
<Link to="/" className="flex-shrink-0 flex items-center">
<Logo />
<span className="ml-2 text-xl font-bold text-gray-900">Snigdha OS</span>
</Link>
</div>
<div className="hidden sm:flex sm:items-center sm:space-x-8">
{navigation.map((item) => (
<Link
key={item.name}
to={item.href}
className={cn(
'px-3 py-2 rounded-md text-sm font-medium transition-colors flex items-center gap-2',
location.pathname === item.href
? 'text-cornflower-blue'
: 'text-gray-600 hover:text-cornflower-blue'
)}
>
<item.icon className="h-4 w-4" />
{item.name}
</Link>
))}
</div>
<div className="flex items-center sm:hidden">
<button
onClick={() => setIsOpen(!isOpen)}
className="inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100"
>
{isOpen ? <X className="h-6 w-6" /> : <Menu className="h-6 w-6" />}
</button>
</div>
</div>
</div>
{isOpen && (
<div className="sm:hidden bg-white/90 backdrop-blur-lg">
<div className="px-2 pt-2 pb-3 space-y-1">
{navigation.map((item) => (
<Link
key={item.name}
to={item.href}
className={cn(
'block px-3 py-2 rounded-md text-base font-medium flex items-center gap-2',
location.pathname === item.href
? 'text-cornflower-blue bg-blue-50'
: 'text-gray-600 hover:text-cornflower-blue hover:bg-blue-50'
)}
onClick={() => setIsOpen(false)}
>
<item.icon className="h-4 w-4" />
{item.name}
</Link>
))}
</div>
</div>
)}
</nav>
);
}