forked from Gyanthakur/component-library
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNavbar.jsx
More file actions
110 lines (100 loc) · 4.56 KB
/
Copy pathNavbar.jsx
File metadata and controls
110 lines (100 loc) · 4.56 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
"use client";
import { useState } from "react";
import { Menu, X } from "lucide-react";
import { usePathname } from "next/navigation";
import Link from "next/link";
import ThemeToggle from './ThemeToggle';
import LanguageSwitcher from '../components/LanguageSwitcher';
const navLinks = [
{ href: "/", label: "Home" },
{ href: "/about", label: "About" },
{ href: "/contact", label: "Contact" },
{ href: "/components", label: "Components" },
{ href: "/playground", label: "🎮 Playground" },
{ href: "/game", label: "🎮 Game" },
{ href: "/analytics", label: "Analytics" },
{ href: "/feedback", label: "Feedback" },
{href: "/racing", label: "🏁 Racing Game" },
];
const Navbar = () => {
const [isOpen, setIsOpen] = useState(false);
const pathname = usePathname();
const isActive = (path) => pathname === path;
return (
<nav className="bg-white dark:bg-gray-900 backdrop-blur-xl sticky top-0 z-50 border-b border-gray-200 dark:border-gray-700 shadow-lg dark:shadow-gray-900/30 transition-all duration-300">
<div className="max-w-7xl mx-auto px-4 sm:px-8">
<div className="flex justify-between h-16">
{/* Logo */}
<div className="flex items-center">
<Link href="/" className="text-3xl font-bold bg-gradient-to-r from-blue-600 to-violet-600 dark:from-blue-400 dark:to-violet-400 bg-clip-text text-transparent select-none hover:from-blue-700 hover:to-violet-700 dark:hover:from-blue-300 dark:hover:to-violet-300 transition-all duration-200">
MyLibrary
</Link>
</div>
{/* Desktop Menu */}
<div className="hidden lg:flex items-center space-x-1">
{navLinks.map((link) => (
<Link
key={link.href}
href={link.href}
className={`relative px-4 py-2.5 rounded-xl transition-all duration-300 text-sm font-medium
${isActive(link.href)
? "text-blue-700 dark:text-blue-300"
: "text-gray-800 dark:text-gray-100 hover:text-blue-600 dark:hover:text-blue-400 hover:bg-gray-100/50 dark:hover:bg-gray-800/50"
}`}
tabIndex={0}
>
<span>{link.label}</span>
{isActive(link.href) && (
<span className="absolute left-2 right-2 -bottom-1 h-[3px] rounded-full bg-gradient-to-r from-blue-500 to-violet-500 dark:from-blue-400 dark:to-violet-400"></span>
)}
</Link>
))}
{/* Language Switcher */}
<div className="ml-2">
<LanguageSwitcher />
</div>
{/* Theme Toggle Button */}
<div className="ml-2">
<ThemeToggle />
</div>
</div>
{/* Mobile Menu Button, Language Switcher & Theme Toggle */}
<div className="flex items-center space-x-2 lg:hidden">
<LanguageSwitcher />
<ThemeToggle />
<button
onClick={() => setIsOpen(!isOpen)}
className="p-2.5 rounded-xl text-gray-800 dark:text-gray-200 hover:text-blue-600 dark:hover:text-blue-400 hover:bg-gray-100/50 dark:hover:bg-gray-800/50 transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:ring-offset-2 dark:focus:ring-offset-gray-900"
aria-label="Open main menu"
>
{isOpen ? <X size={28} /> : <Menu size={28} />}
</button>
</div>
</div>
</div>
{/* Mobile Menu Overlay */}
{isOpen && (
<div className="lg:hidden absolute top-16 left-0 right-0 border-t border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 backdrop-blur-xl shadow-xl transition-all animate-fade-in-down">
<div className="px-3 pt-3 pb-4 space-y-1">
{navLinks.map((link) => (
<Link
key={link.href}
href={link.href}
className={`block px-4 py-3 rounded-xl transition-all duration-200 font-medium
${isActive(link.href)
? "bg-gradient-to-r from-blue-500 to-violet-500 text-white shadow-md font-semibold"
: "text-gray-800 dark:text-gray-100 hover:text-blue-600 dark:hover:text-blue-400 hover:bg-gray-100/50 dark:hover:bg-gray-800/50"
}`}
onClick={() => setIsOpen(false)}
tabIndex={0}
>
{link.label}
</Link>
))}
</div>
</div>
)}
</nav>
);
};
export default Navbar;