-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAppHeader.tsx
More file actions
104 lines (97 loc) · 3.67 KB
/
Copy pathAppHeader.tsx
File metadata and controls
104 lines (97 loc) · 3.67 KB
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
"use client";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { wrappedTheme } from "@/lib/theme";
import { NotificationDropdown } from "@/components/notifications";
function isActiveLink(pathname: string, href: string): boolean {
if (href === "/") return pathname === "/";
// For settings, match any /settings/* path
if (href.startsWith("/settings")) return pathname.startsWith("/settings");
return pathname.startsWith(href);
}
export default function AppHeader(props: {
isAuthed: boolean;
isAdmin?: boolean;
signOut: () => Promise<void>;
}) {
const pathname = usePathname();
if (pathname === "/login") return null;
const baseLinks = props.isAuthed
? [
{ href: "/", label: "My VCP" },
{ href: "/vibes", label: "Repo VCPs" },
{ href: "/settings/repos", label: "Settings" },
{ href: "/methodology", label: "Methodology" },
{ href: "/security", label: "Security" },
]
: [
{ href: "/", label: "Home" },
{ href: "/methodology", label: "Methodology" },
{ href: "/security", label: "Security" },
];
const links = props.isAdmin
? [...baseLinks, { href: "/admin", label: "Admin" }]
: baseLinks;
return (
<header className="sticky top-0 z-50 bg-white/75 backdrop-blur">
<div className="absolute inset-x-0 top-0 h-px bg-gradient-to-r from-violet-500 to-indigo-500" />
<div className="absolute inset-x-0 bottom-0 h-px bg-gradient-to-r from-violet-400 via-indigo-400 to-violet-400 opacity-50" />
<div className="mx-auto flex max-w-6xl items-center justify-between gap-4 px-6 py-4 sm:px-10 lg:px-20">
<div className="flex items-center gap-6">
<Link
href="/"
className="group flex items-center gap-2"
>
<span className={wrappedTheme.dot} />
<span className="text-lg font-bold tracking-tight text-zinc-950">
Vibe Coding Profile
</span>
</Link>
<nav className="flex items-center gap-1 text-sm">
{links.map((l) => {
const isActive = isActiveLink(pathname, l.href);
return (
<Link
key={l.href}
href={l.href}
className={
isActive
? "relative rounded-full bg-violet-100 px-4 py-1.5 font-semibold text-violet-900"
: wrappedTheme.pillLink
}
>
{isActive && (
<span className="absolute inset-x-0 -bottom-[17px] mx-auto h-0.5 w-8 rounded-full bg-gradient-to-r from-violet-500 to-indigo-500" />
)}
{l.label}
</Link>
);
})}
</nav>
</div>
<div className="flex items-center gap-3">
{props.isAuthed ? (
<>
<NotificationDropdown />
<form action={props.signOut}>
<button
type="submit"
className="rounded-full border border-zinc-300/80 bg-white/70 px-4 py-1.5 text-sm font-semibold text-zinc-950 shadow-sm backdrop-blur transition hover:border-zinc-400 hover:bg-white"
>
Sign out
</button>
</form>
</>
) : (
<Link
href="/login"
className="rounded-full bg-gradient-to-r from-violet-600 to-indigo-500 px-4 py-1.5 text-sm font-semibold text-white shadow-sm transition hover:brightness-110"
>
Sign in
</Link>
)}
</div>
</div>
</header>
);
}