Spaces:
Build error
Build error
| 'use client'; | |
| import Link from 'next/link'; | |
| import { useSearchParams } from 'next/navigation'; | |
| import { Home, MessageSquareQuote, Gavel, Search, Sparkles, BarChart3, Shield, Menu, X, Moon, Sun } from 'lucide-react'; | |
| import { useState, useEffect } from 'react'; | |
| const navItems = [ | |
| { id: 'home', label: 'Command', icon: Home }, | |
| { id: 'advisor', label: 'Advisor', icon: Gavel }, | |
| { id: 'analyze', label: 'Analyze', icon: MessageSquareQuote }, | |
| { id: 'verify', label: 'Verify', icon: Search }, | |
| ]; | |
| export default function Navbar() { | |
| const searchParams = useSearchParams(); | |
| const activeSection = searchParams.get('section') || 'home'; | |
| const [isOpen, setIsOpen] = useState(false); | |
| const [isDark, setIsDark] = useState(true); | |
| useEffect(() => { | |
| const theme = localStorage.getItem('theme'); | |
| if (theme === 'light') { | |
| setIsDark(false); | |
| document.documentElement.classList.remove('dark'); | |
| } else { | |
| setIsDark(true); | |
| document.documentElement.classList.add('dark'); | |
| } | |
| }, []); | |
| const toggleTheme = () => { | |
| const newTheme = !isDark; | |
| setIsDark(newTheme); | |
| localStorage.setItem('theme', newTheme ? 'dark' : 'light'); | |
| document.documentElement.classList.toggle('dark'); | |
| }; | |
| return ( | |
| <nav className="fixed top-0 w-full z-50 bg-white/90 dark:bg-slate-900/90 backdrop-blur-md shadow-lg"> | |
| <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"> | |
| <div className="flex justify-between items-center h-16"> | |
| <Link href="/" className="flex items-center space-x-2 group"> | |
| <div className="w-10 h-10 bg-gradient-to-br from-primary-500 to-helios-600 rounded-lg flex items-center justify-center"> | |
| <span className="text-white font-bold text-xl">T</span> | |
| </div> | |
| <span className="font-bold text-xl text-slate-800 dark:text-white hidden sm:block"> | |
| Truth<span className="text-primary-600">Anchor</span> | |
| <span className="text-xs ml-1 text-slate-500 font-normal">v11.2</span> | |
| </span> | |
| <a | |
| href="https://huggingface.co/spaces/akhaliq/anycoder" | |
| target="_blank" | |
| rel="noopener noreferrer" | |
| className="text-xs text-slate-400 hover:text-primary-400 transition-colors ml-2" | |
| > | |
| Built with anycoder | |
| </a> | |
| </Link> | |
| <div className="hidden md:flex items-center space-x-1"> | |
| {navItems.map((item) => { | |
| const Icon = item.icon; | |
| const isActive = activeSection === item.id; | |
| return ( | |
| <Link key={item.id} href={`/?section=${item.id}`} | |
| className={`flex items-center space-x-1 px-4 py-2 rounded-lg transition-all duration-200 ${isActive ? 'bg-primary-100 text-primary-700 dark:bg-primary-900/30 dark:text-primary-300' : 'text-slate-600 hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-800'}`}> | |
| <Icon className="w-4 h-4" /> | |
| <span className="font-medium">{item.label}</span> | |
| </Link> | |
| ); | |
| })} | |
| <button onClick={toggleTheme} className="p-2 rounded-lg text-slate-600 hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-800 transition-colors"> | |
| {isDark ? <Sun className="w-5 h-5" /> : <Moon className="w-5 h-5" />} | |
| </button> | |
| </div> | |
| <div className="md:hidden"> | |
| <button onClick={() => setIsOpen(!isOpen)} className="p-2 rounded-lg text-slate-600 hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-800"> | |
| {isOpen ? <X className="w-6 h-6" /> : <Menu className="w-6 h-6" />} | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| {/* Mobile Menu */} | |
| {isOpen && ( | |
| <div className="md:hidden bg-white dark:bg-slate-900 border-t dark:border-slate-700"> | |
| <div className="px-2 pt-2 pb-3 space-y-1"> | |
| {navItems.map((item) => { | |
| const Icon = item.icon; | |
| const isActive = activeSection === item.id; | |
| return ( | |
| <Link | |
| key={item.id} | |
| href={`/?section=${item.id}`} | |
| onClick={() => setIsOpen(false)} | |
| className={`flex items-center space-x-2 px-3 py-2 rounded-lg transition-all duration-200 ${isActive ? 'bg-primary-100 text-primary-700 dark:bg-primary-900/30 dark:text-primary-300' : 'text-slate-600 hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-800'}`}> | |
| <Icon className="w-5 h-5" /> | |
| <span className="font-medium">{item.label}</span> | |
| </Link> | |
| ); | |
| })} | |
| </div> | |
| </div> | |
| )} | |
| </nav> | |
| ); | |
| } |