-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathNavbar.jsx
More file actions
83 lines (75 loc) · 2.65 KB
/
Copy pathNavbar.jsx
File metadata and controls
83 lines (75 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
"use client"
import { useState } from "react";
import { Menu, X } from "lucide-react";
import { usePathname } from "next/navigation";
import Link from "next/link";
const Navbar = () => {
const [isOpen, setIsOpen] = useState(false);
const pathname = usePathname();
const navLinks = [
{ href: "/", label: "Home" },
{ href: "/about", label: "About" },
{ href: "/contact", label: "Contact" },
{ href: "/components", label: "Components" },
];
const isActive = (path) => pathname === path;
return (
<nav className="bg-card/80 backdrop-blur-lg border-b border-blue-50 sticky top-0 z-50 shadow-sm">
<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 items-center">
<Link href="/" className="text-3xl font-bold text-blue-700">
MyLibrary
</Link>
</div>
{/* Desktop Menu */}
<div className="hidden md:flex items-center space-x-1">
{navLinks.map((link) => (
<Link
key={link.href}
href={link.href}
className={`px-4 py-2 rounded-lg transition-all duration-300 ${isActive(link.href)
? "bg-primary text-white font-medium bg-blue-600"
: "text-foreground hover:bg-secondary hover:text-secondary-foreground"
}`}
>
{link.label}
</Link>
))}
</div>
{/* Mobile Menu Button */}
<div className="flex items-center md:hidden">
<button
onClick={() => setIsOpen(!isOpen)}
className="p-2 rounded-lg text-foreground hover:bg-secondary transition-colors"
aria-label="Toggle menu"
>
{isOpen ? <X size={24} /> : <Menu size={24} />}
</button>
</div>
</div>
</div>
{/* Mobile Menu */}
{isOpen && (
<div className="md:hidden border-t border-border bg-card/95 backdrop-blur-lg">
<div className="px-2 pt-2 pb-3 space-y-1">
{navLinks.map((link) => (
<Link
key={link.href}
href={link.href}
className={`block px-4 py-3 rounded-lg transition-all ${isActive(link.href)
? "bg-blue-700 text-primary font-medium"
: "text-foreground hover:bg-secondary"
}`}
onClick={() => setIsOpen(false)}
>
{link.label}
</Link>
))}
</div>
</div>
)}
</nav>
);
};
export default Navbar;