Repository navigation
Expand file tree
/
Copy pathHeader.tsx
More file actions
158 lines (153 loc) · 6.46 KB
/
Copy pathHeader.tsx
File metadata and controls
158 lines (153 loc) · 6.46 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
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
"use client";
import type { ReactNode } from "react";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { motion } from "motion/react";
import { AuthControl } from "./AuthControl";
import { NotificationsBellContainer } from "./NotificationsBell";
import { Icon } from "./Icon";
import { Logo } from "./Logo";
import { Button } from "@/components/ui/button";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { cn } from "@/lib/utils";
import { openCommandPalette, openCalendar } from "@/components/discovery/DiscoveryCommand";
const NAV = [
{ href: "/discover", label: "Discover", icon: "ic:round-explore" },
{ href: "/wallet", label: "My tickets", icon: "ion:ticket" },
{ href: "/dashboard", label: "Dashboard", icon: "material-symbols-light:analytics-rounded" },
];
/**
* App header (desktop only — mobile nav lives in MobileTabBar).
*
* Three zones, like a modern app shell: [logo + nav] · [centered search] ·
* [actions]. The search is a command-palette trigger styled as an input,
* absolutely centered at lg+ (so it stays centered regardless of the left/right
* cluster widths); below lg it collapses to a search icon button in the right
* cluster. Right cluster: Create event, Settings, the notifications bell (#59),
* the optional injection seams, then AuthControl.
*
* `notificationsSlot` / `userAvatarSlot` are optional ReactNode seams so callers
* can inject extra notifications/avatar UI without the Header importing those
* components.
*/
export function Header({
notificationsSlot,
userAvatarSlot,
}: {
notificationsSlot?: ReactNode;
userAvatarSlot?: ReactNode;
} = {}) {
const pathname = usePathname() || "/";
return (
<header className="sticky top-0 z-50 hidden border-b bg-background/80 backdrop-blur supports-[backdrop-filter]:bg-background/60 md:block">
<div className="relative flex h-14 w-full items-center gap-2 px-4 sm:px-6 lg:px-8">
{/* Left: logo + primary nav */}
<div className="flex items-center gap-1">
<Link href="/" className="mr-1 flex flex-none items-center" aria-label="HostIt home">
<Logo size={24} />
</Link>
<nav className="hidden items-center gap-0.5 md:flex" aria-label="Primary">
{NAV.map((n) => {
const active = pathname === n.href || pathname.startsWith(n.href + "/");
return (
<Button
key={n.href}
asChild
variant="ghost"
size="sm"
className={cn(
"relative text-muted-foreground",
active && "bg-accent text-foreground",
)}
>
<Link href={n.href} aria-current={active ? "page" : undefined}>
<Icon icon={n.icon} size={16} />
{n.label}
{active && (
<motion.span
layoutId="nav-active"
className="absolute inset-x-2 -bottom-px h-0.5 rounded-full bg-primary"
transition={{ type: "spring", stiffness: 380, damping: 30 }}
/>
)}
</Link>
</Button>
);
})}
</nav>
</div>
{/* Center: search bar + calendar — absolutely centered (lg+). The wrapper
ignores pointer events so it never blocks the left/right clusters;
only the buttons themselves are interactive. The calendar sits to the
right of the search bar and opens the app-level calendar dialog. */}
<div className="pointer-events-none absolute left-1/2 hidden w-full max-w-md -translate-x-1/2 px-4 lg:block">
<div className="flex items-center gap-2">
<button
type="button"
onClick={openCommandPalette}
aria-label="Search events and commands"
className="pointer-events-auto flex grow items-center gap-2 rounded-lg border bg-muted/40 px-3 py-1.5 text-sm text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground"
>
<Icon icon="ic:round-search" size={16} />
<span>Search events…</span>
<kbd className="ml-auto font-mono text-[11px] text-muted-foreground">⌘K</kbd>
</button>
<Tooltip>
<TooltipTrigger asChild>
<Button
variant="outline"
size="icon-sm"
onClick={openCalendar}
aria-label="Calendar"
className="pointer-events-auto flex-none"
>
<Icon icon="proicons:calendar" size={16} />
</Button>
</TooltipTrigger>
<TooltipContent>Calendar</TooltipContent>
</Tooltip>
</div>
</div>
{/* Right: actions */}
<div className="ml-auto flex items-center gap-2">
{/* search fallback below lg, where the centered bar is hidden */}
<Tooltip>
<TooltipTrigger asChild>
<Button
variant="outline"
size="icon-sm"
onClick={openCommandPalette}
aria-label="Search"
className="text-muted-foreground lg:hidden"
>
<Icon icon="ic:round-search" size={15} />
</Button>
</TooltipTrigger>
<TooltipContent>Search & commands (⌘K)</TooltipContent>
</Tooltip>
<Button asChild size="sm">
<Link href="/create" aria-label="Create event">
<Icon icon="ic:round-add" size={16} />
<span className="hidden lg:inline">Create event</span>
</Link>
</Button>
<Tooltip>
<TooltipTrigger asChild>
<Button asChild variant="outline" size="icon-sm">
<Link href="/settings" aria-label="Settings">
<Icon icon="ic:round-settings" size={16} />
</Link>
</Button>
</TooltipTrigger>
<TooltipContent>Settings</TooltipContent>
</Tooltip>
{/* notifications bell — on-chain-derived inbox (renders nothing signed out) */}
<NotificationsBellContainer />
{notificationsSlot}
{userAvatarSlot}
<AuthControl />
</div>
</div>
</header>
);
}