-
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathheader.tsx
More file actions
323 lines (310 loc) · 12.2 KB
/
header.tsx
File metadata and controls
323 lines (310 loc) · 12.2 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
import {
Bot,
ChevronDown,
Copy,
FileSpreadsheet,
Github,
Menu,
Palette,
Receipt,
Search,
X,
} from 'lucide-react';
import { useEffect, useRef, useState } from 'react';
import { Link, useLocation, useNavigate } from 'react-router-dom';
import { BLOCKS } from '../../constants';
import { cn } from '../../lib/utils';
import { ThemeToggle } from '../theme-toggle';
function BlocksDropdown() {
const [open, setOpen] = useState(false);
const ref = useRef<HTMLDivElement>(null);
const navigate = useNavigate();
// Close on outside click
useEffect(() => {
function onClick(e: MouseEvent) {
if (ref.current && !ref.current.contains(e.target as Node)) {
setOpen(false);
}
}
if (open) document.addEventListener('mousedown', onClick);
return () => document.removeEventListener('mousedown', onClick);
}, [open]);
return (
<>
<div ref={ref} className="relative">
<button
type="button"
onClick={() => setOpen(!open)}
className={cn(
'flex items-center gap-1 text-sm transition-colors',
open ? 'text-foreground' : 'text-muted-foreground hover:text-foreground'
)}
>
Blocks
<ChevronDown
className={cn('h-3.5 w-3.5 transition-transform duration-200', open && 'rotate-180')}
/>
</button>
{open && (
<div className="absolute left-0 top-full mt-2.5 z-[100] w-[480px] rounded-xl border bg-popover shadow-xl overflow-hidden">
{/* Panel header */}
<div className="px-4 py-3 border-b bg-muted/30">
<div className="flex items-center gap-2">
<Copy className="h-4 w-4 text-primary" />
<p className="text-xs font-medium text-muted-foreground uppercase tracking-wider">
Pre-Composed Blocks
</p>
</div>
<p className="text-xs text-muted-foreground mt-1">
Copy, paste, and customize. Full design ownership in your codebase.
</p>
</div>
{/* Blocks grid */}
<div className="grid grid-cols-2 gap-2 p-4">
{BLOCKS.map((b) => (
<button
key={b.name}
type="button"
onClick={() => {
if (!b.isDisabled) {
navigate(b.path);
setOpen(false);
}
}}
className={cn(
'group flex flex-col gap-2 rounded-lg border border-border/60 bg-card p-3 text-left hover:border-border hover:bg-muted/40 hover:shadow-sm transition-all duration-150 cursor-pointer',
b.isDisabled && 'opacity-70 cursor-not-allowed'
)}
title={b.isDisabled ? 'Coming soon' : undefined}
>
<div className="flex items-start justify-between">
<div className={cn('rounded-md p-1.5 w-fit', b.bg)}>
<b.icon className={cn('h-4 w-4', b.color)} />
</div>
{b.count > 0 && (
<span className="text-[10px] font-mono text-muted-foreground/70 bg-muted rounded px-1.5 py-0.5">
{b.count} designs
</span>
)}
</div>
<div>
<p className="text-xs font-semibold leading-tight">{b.name}</p>
<p className="text-[11px] text-muted-foreground mt-0.5 leading-snug line-clamp-2">
{b.description}
</p>
</div>
{b.isDisabled && (
<span className="text-[9px] font-medium uppercase tracking-wider text-primary/70 border border-primary/30 rounded px-1.5 py-0.5 w-fit mt-auto">
Coming Soon
</span>
)}
</button>
))}
{/* Request a block card */}
<a
href="https://github.com/akii09/pdfx/discussions"
target="_blank"
rel="noopener noreferrer"
onClick={() => setOpen(false)}
className="group flex flex-col gap-2 rounded-lg border border-dashed border-primary/40 bg-primary/5 p-3 text-left hover:border-primary/70 hover:bg-primary/10 transition-all duration-150"
>
<div className="rounded-md bg-primary/10 p-1.5 w-fit">
<Github className="h-4 w-4 text-primary" />
</div>
<div>
<p className="text-xs font-semibold leading-tight text-primary">
Request a Block
</p>
<p className="text-[11px] text-muted-foreground mt-0.5 leading-snug">
Tell us what designs you need on GitHub Discussions.
</p>
</div>
<span className="text-[9px] font-medium uppercase tracking-wider text-primary/70 border border-primary/30 rounded px-1.5 py-0.5 w-fit group-hover:bg-primary/10 transition-colors">
Open discussion →
</span>
</a>
</div>
</div>
)}
</div>
</>
);
}
export function Header() {
const [mobileOpen, setMobileOpen] = useState(false);
const { pathname } = useLocation();
useEffect(() => {
if (pathname) {
setMobileOpen(false);
}
}, [pathname]);
return (
<header className="sticky top-0 z-50 w-full border-b bg-background/80 backdrop-blur-sm">
<div className="container-fluid mx-auto flex h-14 items-center justify-between px-4">
{/* Left: Logo + primary nav */}
<div className="flex items-center gap-6">
<Link to="/" className="flex items-center gap-2 font-bold text-xl shrink-0">
<img src="/pdfx.png" alt="PDFx" className="h-10 w-auto dark:invert dark:brightness-0" />
<span className="hidden sm:inline-flex items-center rounded-full border border-border/70 bg-muted/50 px-2 py-0.5 text-[10px] font-mono text-muted-foreground">
v{__PDFX_VERSION__}
</span>
</Link>
{/* Desktop primary nav — left side */}
<nav className="hidden md:flex items-center gap-5">
<Link
to="/docs"
className="text-sm text-muted-foreground hover:text-foreground transition-colors"
>
Docs
</Link>
<Link
to="/components"
className="text-sm text-muted-foreground hover:text-foreground transition-colors"
>
Components
</Link>
<BlocksDropdown />
<Link
to="/theme-builder"
className="flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors"
>
<Palette className="h-3.5 w-3.5" />
Theme Builder
</Link>
</nav>
</div>
{/* Right: search, github, theme toggle */}
<div className="hidden md:flex items-center gap-3">
<button
type="button"
onClick={() => {
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'k', metaKey: true }));
}}
className="inline-flex items-center gap-2 rounded-md border bg-muted/50 px-3 py-1.5 text-sm text-muted-foreground hover:bg-accent transition-colors"
>
<Search className="h-3.5 w-3.5" />
Search...
<kbd className="ml-2 rounded border bg-muted px-1.5 py-0.5 font-mono text-[10px]">
⌘K
</kbd>
</button>
<Link
to="/mcp"
className="inline-flex items-center justify-center rounded-md border bg-muted/50 p-2 text-muted-foreground hover:bg-accent hover:text-foreground transition-colors"
aria-label="Open MCP and Skills docs"
title="MCP & Skills"
>
<Bot className="h-4 w-4" />
</Link>
<a
href="https://github.com/akii09/pdfx"
target="_blank"
rel="noopener noreferrer"
className="text-muted-foreground hover:text-foreground transition-colors"
aria-label="View PDFx on GitHub"
>
<Github className="h-5 w-5" aria-hidden="true" />
</a>
<ThemeToggle />
</div>
{/* Mobile toggle */}
<button
type="button"
className="md:hidden p-2 text-muted-foreground hover:text-foreground"
onClick={() => setMobileOpen(!mobileOpen)}
aria-label="Toggle menu"
>
{mobileOpen ? <X className="h-5 w-5" /> : <Menu className="h-5 w-5" />}
</button>
</div>
{/* Mobile nav */}
<div
className={cn(
'md:hidden border-t overflow-hidden transition-all duration-200',
mobileOpen ? 'max-h-[420px]' : 'max-h-0'
)}
aria-hidden={!mobileOpen}
>
<nav className="flex flex-col gap-1 px-4 py-4">
<Link
to="/docs"
onClick={() => setMobileOpen(false)}
className="text-sm text-muted-foreground hover:text-foreground py-2"
>
Docs
</Link>
<Link
to="/components"
onClick={() => setMobileOpen(false)}
className="text-sm text-muted-foreground hover:text-foreground py-2"
>
Components
</Link>
{/* Blocks section (Composition-based) */}
<div className="py-2">
<span className="text-sm font-medium text-foreground">Blocks</span>
<p className="text-[10px] text-muted-foreground/70 mt-0.5">
Copy-paste, customize in your code
</p>
<div className="mt-2 ml-3 flex flex-col gap-1 border-l border-border pl-3">
<Link
to="/blocks/invoices"
onClick={() => setMobileOpen(false)}
className="text-sm text-muted-foreground hover:text-foreground py-1.5 flex items-center gap-2"
>
<Receipt className="h-3.5 w-3.5 text-blue-500" />
Invoices
</Link>
<Link
to="/blocks/receipts"
onClick={() => setMobileOpen(false)}
className="text-sm text-muted-foreground hover:text-foreground py-1.5 flex items-center gap-2"
>
<Receipt className="h-3.5 w-3.5 text-amber-500" />
Receipts
</Link>
<Link
to="/blocks/reports"
onClick={() => setMobileOpen(false)}
className="text-sm text-muted-foreground hover:text-foreground py-1.5 flex items-center gap-2"
>
<FileSpreadsheet className="h-3.5 w-3.5 text-emerald-500" />
Reports
</Link>
</div>
</div>
<Link
to="/theme-builder"
onClick={() => setMobileOpen(false)}
className="text-sm text-muted-foreground hover:text-foreground py-2 flex items-center gap-2"
>
<Palette className="h-3.5 w-3.5" />
Theme Builder
</Link>
<Link
to="/mcp"
onClick={() => setMobileOpen(false)}
className="text-sm text-muted-foreground hover:text-foreground py-2 flex items-center gap-2"
>
<Bot className="h-3.5 w-3.5" />
MCP & Skills
</Link>
<div className="h-px bg-border my-2" />
<a
href="https://github.com/akii09/pdfx"
target="_blank"
rel="noopener noreferrer"
className="text-sm text-muted-foreground hover:text-foreground py-2 flex items-center gap-2"
>
<Github className="h-4 w-4" />
GitHub
</a>
<div className="py-2 flex items-center gap-2">
<ThemeToggle />
<span className="text-xs text-muted-foreground">Toggle theme</span>
</div>
</nav>
</div>
</header>
);
}