Files
cats/client/src/components/Navbar.tsx

56 lines
2.3 KiB
TypeScript

import { Link, useNavigate } from 'react-router-dom';
import { useAuth } from '@/hooks/useAuth';
import { Avatar, AvatarFallback } from '@/components/ui/avatar';
import { Button } from '@/components/ui/button';
import { LogOut, Plus, Home, Cat } from 'lucide-react';
export default function Navbar() {
const { user, logout } = useAuth();
const navigate = useNavigate();
if (!user) return null;
return (
<nav className="sticky top-0 z-50 border-b bg-white/80 backdrop-blur-md shadow-sm">
<div className="mx-auto flex h-14 max-w-5xl items-center justify-between px-4">
<Link to="/feed" className="flex items-center gap-2 group">
<div className="flex h-8 w-8 items-center justify-center rounded-xl bg-gradient-to-br from-orange-400 to-rose-500 shadow-sm transition-transform group-hover:scale-105">
<Cat className="h-4.5 w-4.5 text-white" />
</div>
<span className="text-base font-bold tracking-tight text-foreground">
Catstagram
</span>
</Link>
<div className="flex items-center gap-0.5">
<Link to="/feed">
<Button variant="ghost" size="icon" className="h-9 w-9 rounded-xl text-muted-foreground hover:text-foreground hover:bg-secondary">
<Home className="h-4.5 w-4.5" />
</Button>
</Link>
<Link to="/upload">
<Button variant="ghost" size="icon" className="h-9 w-9 rounded-xl text-muted-foreground hover:text-foreground hover:bg-secondary">
<Plus className="h-4.5 w-4.5" />
</Button>
</Link>
<Link to="/profile">
<Button variant="ghost" size="icon" className="h-9 w-9 rounded-xl">
<Avatar className="h-7 w-7">
<AvatarFallback className="text-[10px] bg-gradient-to-br from-orange-400 to-rose-500 text-white">
{user.username.charAt(0).toUpperCase()}
</AvatarFallback>
</Avatar>
</Button>
</Link>
<button
onClick={() => { logout(); navigate('/login'); }}
className="flex h-9 w-9 items-center justify-center rounded-xl text-muted-foreground hover:text-foreground hover:bg-secondary transition-colors"
>
<LogOut className="h-4 w-4" />
</button>
</div>
</div>
</nav>
);
}