Study/src/components/ui/Navbar.tsx
Elijah 87fc071961
All checks were successful
Automated Container Build / build-and-push (push) Successful in 58s
feat: Add persistent Dark Mode with ThemeToggle component and layout script
2026-06-27 20:56:10 -07:00

52 lines
1.7 KiB
TypeScript

"use client";
import { useRouter } from "next/navigation";
import Link from "next/link";
import { ThemeToggle } from "./ThemeToggle";
export function Navbar() {
const router = useRouter();
async function handleLogout() {
await fetch("/api/auth/logout", { method: "POST" });
router.push("/login");
router.refresh();
}
return (
<nav className="bg-bg-surface border-b border-border-light">
<div className="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8">
<div className="flex items-center justify-between h-14">
<Link
href="/"
className="flex items-center gap-2.5 text-text-heading font-semibold hover:text-primary transition-colors"
>
<svg
className="w-5 h-5 text-primary"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"
/>
</svg>
Study
</Link>
<div className="flex items-center gap-4">
<ThemeToggle />
<button
onClick={handleLogout}
className="text-sm text-text-muted hover:text-text-heading transition-colors cursor-pointer"
>
Sign out
</button>
</div>
</div>
</div>
</nav>
);
}