Spaces:
Sleeping
Sleeping
File size: 5,864 Bytes
a0da743 | 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 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | 'use client';
import Link from 'next/link';
import { usePathname, useRouter } from 'next/navigation';
import { motion } from 'framer-motion';
import { useAuth } from '@/context/AuthContext';
import { Brain, Home, BarChart3, Settings, LogIn, LogOut, User, Award } from 'lucide-react';
export default function Navbar() {
const pathname = usePathname();
const router = useRouter();
const { user, isAuthenticated, logout } = useAuth();
const isActive = (path: string) => pathname === path;
const handleLogout = () => {
logout();
router.push('/');
};
return (
<motion.nav
initial={{ y: -20, opacity: 0 }}
animate={{ y: 0, opacity: 1 }}
transition={{ duration: 0.5 }}
className="glass fixed top-0 left-0 right-0 z-50"
style={{ borderBottom: '1px solid var(--border)' }}
>
<div className="max-w-7xl mx-auto px-6 h-16 flex items-center justify-between">
{/* Logo */}
<Link href="/" className="flex items-center gap-3 group">
<div
className="w-10 h-10 rounded-xl flex items-center justify-center glow-primary"
style={{ background: 'var(--gradient-primary)' }}
>
<Brain className="w-5 h-5 text-white" />
</div>
<span className="font-bold text-lg tracking-tight">
<span className="text-gradient">InterviewAI</span>
</span>
</Link>
{/* Navigation */}
<div className="flex items-center gap-1">
<NavLink href="/" active={isActive('/')}>
<Home className="w-4 h-4" />
<span className="hidden sm:inline">Home</span>
</NavLink>
<NavLink href="/interview" active={isActive('/interview') || isActive('/interview/session')}>
<Brain className="w-4 h-4" />
<span className="hidden sm:inline">Interview</span>
</NavLink>
<NavLink href="/dashboard" active={isActive('/dashboard')}>
<BarChart3 className="w-4 h-4" />
<span className="hidden sm:inline">Dashboard</span>
</NavLink>
<NavLink href="/results" active={isActive('/results')}>
<Award className="w-4 h-4" />
<span className="hidden sm:inline">Results</span>
</NavLink>
</div>
{/* User Area */}
<div className="flex items-center gap-2">
{isAuthenticated && user ? (
<div className="flex items-center gap-3">
{/* User Badge */}
<div className="flex items-center gap-2 px-3 py-1.5 rounded-lg"
style={{ background: 'rgba(108, 92, 231, 0.08)', border: '1px solid rgba(108, 92, 231, 0.15)' }}
>
<div className="w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold"
style={{ background: 'var(--gradient-primary)', color: 'white' }}>
{user.displayName.charAt(0).toUpperCase()}
</div>
<span className="text-sm font-medium hidden sm:inline" style={{ color: 'var(--primary-light)' }}>
{user.displayName.split(' ')[0]}
</span>
</div>
{/* Settings */}
<Link
href="/settings"
className="p-2 rounded-lg transition-all duration-300"
style={{ color: 'var(--muted)' }}
onMouseEnter={(e) => { e.currentTarget.style.color = 'var(--foreground)'; }}
onMouseLeave={(e) => { e.currentTarget.style.color = 'var(--muted)'; }}
>
<Settings className="w-4 h-4" />
</Link>
{/* Logout */}
<button
onClick={handleLogout}
className="p-2 rounded-lg transition-all duration-300 cursor-pointer"
style={{ color: 'var(--muted)' }}
onMouseEnter={(e) => { e.currentTarget.style.color = 'var(--danger)'; }}
onMouseLeave={(e) => { e.currentTarget.style.color = 'var(--muted)'; }}
title="Logout"
>
<LogOut className="w-4 h-4" />
</button>
</div>
) : (
<Link
href="/login"
className="flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-all duration-300"
style={{ background: 'var(--gradient-primary)', color: 'white' }}
>
<LogIn className="w-4 h-4" />
<span className="hidden sm:inline">Sign In</span>
</Link>
)}
</div>
</div>
</motion.nav>
);
}
function NavLink({
href,
active,
children,
}: {
href: string;
active: boolean;
children: React.ReactNode;
}) {
return (
<Link
href={href}
className="relative flex items-center gap-2 px-3 sm:px-4 py-2 rounded-lg text-sm font-medium transition-all duration-300"
style={{
color: active ? 'var(--primary-light)' : 'var(--muted)',
background: active ? 'rgba(108, 92, 231, 0.1)' : 'transparent',
}}
onMouseEnter={(e) => {
if (!active) {
e.currentTarget.style.color = 'var(--foreground)';
e.currentTarget.style.background = 'rgba(255,255,255,0.03)';
}
}}
onMouseLeave={(e) => {
if (!active) {
e.currentTarget.style.color = 'var(--muted)';
e.currentTarget.style.background = 'transparent';
}
}}
>
{children}
{active && (
<motion.div
layoutId="navbar-indicator"
className="absolute bottom-0 left-2 right-2 h-0.5 rounded-full"
style={{ background: 'var(--gradient-primary)' }}
transition={{ type: 'spring', stiffness: 400, damping: 30 }}
/>
)}
</Link>
);
}
|