|
2 | 2 |
|
3 | 3 | import Link from "next/link"; |
4 | 4 | import { useAuth } from "@/contexts/AuthContext"; |
| 5 | +import { usePathname } from "next/navigation"; |
| 6 | +import { useEffect, useState } from "react"; |
5 | 7 |
|
6 | 8 | export default function Nav() { |
7 | 9 | const { user } = useAuth(); |
| 10 | + const pathname = usePathname(); |
| 11 | + const isLanding = pathname === "/"; |
| 12 | + const [scrolled, setScrolled] = useState(false); |
| 13 | + |
| 14 | + useEffect(() => { |
| 15 | + if (!isLanding) return; |
| 16 | + |
| 17 | + const handleScroll = () => { |
| 18 | + setScrolled(window.scrollY > 10); |
| 19 | + }; |
| 20 | + |
| 21 | + handleScroll(); |
| 22 | + window.addEventListener("scroll", handleScroll); |
| 23 | + return () => window.removeEventListener("scroll", handleScroll); |
| 24 | + }, [isLanding]); |
| 25 | + |
| 26 | + const navTheme = isLanding |
| 27 | + ? scrolled |
| 28 | + ? "border-white/10 bg-zinc-950/80 text-white shadow-lg shadow-black/30" |
| 29 | + : "border-transparent bg-transparent text-white" |
| 30 | + : "border-gray-200 bg-white text-gray-900 shadow-sm"; |
| 31 | + const linkTheme = isLanding |
| 32 | + ? "text-sm font-medium text-white/80 hover:text-white" |
| 33 | + : "text-sm font-medium text-gray-700 hover:text-gray-900"; |
| 34 | + const buttonTheme = isLanding |
| 35 | + ? "bg-white text-zinc-950 hover:bg-zinc-100" |
| 36 | + : "bg-blue-600 text-white hover:bg-blue-700"; |
| 37 | + const secondaryLinkTheme = isLanding ? "text-white" : "text-gray-900"; |
| 38 | + |
| 39 | + const landingLinks = [ |
| 40 | + { href: "/#how-it-works", label: "How it works" }, |
| 41 | + { href: "/#features", label: "Features" }, |
| 42 | + { href: "/#demo", label: "Demo" }, |
| 43 | + { href: "/#trust-score", label: "Trust score" }, |
| 44 | + ]; |
8 | 45 |
|
9 | 46 | return ( |
10 | | - <nav className="bg-white shadow-sm border-b"> |
| 47 | + <nav className={`sticky top-0 z-50 border-b backdrop-blur ${navTheme}`}> |
11 | 48 | <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"> |
12 | 49 | <div className="flex justify-between items-center h-16"> |
13 | | - <div className="flex items-center"> |
14 | | - <Link href="/" className="text-xl font-bold text-gray-900"> |
15 | | - Hackathon App |
| 50 | + <div className="flex items-center gap-6"> |
| 51 | + <Link |
| 52 | + href="/" |
| 53 | + className={`text-xl font-bold transition ${secondaryLinkTheme}`} |
| 54 | + > |
| 55 | + Aegis |
16 | 56 | </Link> |
| 57 | + {isLanding && ( |
| 58 | + <div className="hidden md:flex items-center gap-4"> |
| 59 | + {landingLinks.map((link) => ( |
| 60 | + <Link key={link.label} href={link.href} className={linkTheme}> |
| 61 | + {link.label} |
| 62 | + </Link> |
| 63 | + ))} |
| 64 | + </div> |
| 65 | + )} |
17 | 66 | </div> |
18 | 67 |
|
19 | 68 | <div className="flex items-center gap-4"> |
20 | 69 | {user ? ( |
21 | 70 | <> |
22 | 71 | <Link |
23 | 72 | href="/dashboard" |
24 | | - className="text-gray-700 hover:text-gray-900 px-3 py-2 rounded-md text-sm font-medium" |
| 73 | + className={`${linkTheme} rounded-md px-3 py-2`} |
25 | 74 | > |
26 | 75 | Dashboard |
27 | 76 | </Link> |
28 | | - <span className="text-gray-600 text-sm"> |
29 | | - {user.email} |
30 | | - </span> |
31 | 77 | </> |
32 | 78 | ) : ( |
33 | 79 | <> |
34 | | - <Link |
35 | | - href="/" |
36 | | - className="text-gray-700 hover:text-gray-900 px-3 py-2 rounded-md text-sm font-medium" |
37 | | - > |
38 | | - Home |
39 | | - </Link> |
40 | 80 | <Link |
41 | 81 | href="/auth" |
42 | | - className="bg-blue-600 text-white hover:bg-blue-700 px-4 py-2 rounded-md text-sm font-medium" |
| 82 | + className={`${buttonTheme} rounded-full px-4 py-2 text-sm font-medium transition`} |
43 | 83 | > |
44 | 84 | Sign In |
45 | 85 | </Link> |
|
0 commit comments