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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
|
"use client";
import { useState, useEffect, useRef } from "react";
import Link from "next/link";
import Image from "next/image";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Badge } from "@/components/ui/badge";
import {
NavigationMenu,
NavigationMenuContent,
NavigationMenuItem,
NavigationMenuLink,
NavigationMenuList,
NavigationMenuTrigger,
} from "@/components/ui/navigation-menu";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger } from "@/components/ui/sheet";
import { ThemeToggle } from "@/components/theme-toggle";
import {
Search,
ShoppingBag,
Heart,
User,
Menu,
Phone,
Truck,
RefreshCw,
Shield,
Globe,
} from "lucide-react";
export function Header() {
const [cartItems] = useState(3);
const [wishlistItems] = useState(5);
const [isMounted, setIsMounted] = useState(false);
const sheetRef = useRef<HTMLDivElement>(null);
const categories = [
{
title: "Women",
items: [
{ name: "Dresses", href: "/women/dresses" },
{ name: "Tops & Blouses", href: "/women/tops" },
{ name: "Pants & Jeans", href: "/women/pants" },
{ name: "Outerwear", href: "/women/outerwear" },
{ name: "Accessories", href: "/women/accessories" },
],
},
{
title: "Men",
items: [
{ name: "T-Shirts", href: "/men/tshirts" },
{ name: "Shirts", href: "/men/shirts" },
{ name: "Pants & Jeans", href: "/men/pants" },
{ name: "Jackets", href: "/men/jackets" },
{ name: "Accessories", href: "/men/accessories" },
],
},
{
title: "Kids",
items: [
{ name: "Boys", href: "/kids/boys" },
{ name: "Girls", href: "/kids/girls" },
{ name: "Baby", href: "/kids/baby" },
{ name: "Shoes", href: "/kids/shoes" },
],
},
];
// Preload both logo variants to ensure smooth loading
useEffect(() => {
setIsMounted(true);
// Add global error handler for scroll-related errors
const handleError = (event: ErrorEvent) => {
if (event.error?.message?.includes('parameter 1 is not of type \'Node\'') ||
event.error?.message?.includes('handleScroll')) {
console.warn('Scroll handling error caught and suppressed:', event.error);
event.preventDefault();
return false;
}
};
window.addEventListener('error', handleError);
const preloadLogos = () => {
if (typeof window !== 'undefined') {
const lightLogo = new window.Image();
const darkLogo = new window.Image();
lightLogo.src = '/black-logo.png';
darkLogo.src = '/white-logo.png';
}
};
preloadLogos();
return () => {
window.removeEventListener('error', handleError);
};
}, []);
// Prevent hydration issues with Sheet component
if (!isMounted) {
return (
<header className="sticky top-0 z-50 w-full bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60">
{/* Top banner */}
<div className="bg-black text-white text-center py-2 px-4">
<p className="text-sm font-medium">
FREE SHIPPING ON ORDERS OVER $100 β’ NEW ARRIVALS EVERY WEEK
</p>
</div>
{/* Announcement bar */}
<div className="bg-neutral-100 dark:bg-neutral-800 text-center py-2 px-4">
<p className="text-sm">
π₯ <span className="font-semibold">WINTER SALE</span> - Up to 50% off on selected items
</p>
</div>
{/* Main header */}
<div className="border-b dark:border-neutral-800">
<div className="container mx-auto px-3 sm:px-4 lg:px-6">
<div className="flex h-14 sm:h-16 items-center justify-between gap-2 sm:gap-4">
{/* Mobile menu placeholder */}
<Button
variant="ghost"
size="icon"
className="md:hidden nav-button-transparent backdrop-blur-sm"
disabled
>
<Menu className="h-5 w-5" />
</Button>
{/* Logo */}
<div className="flex items-center">
<Link href="/" className="flex items-center space-x-2">
<Image
src="/black-logo.png"
alt="blcklst"
width={120}
height={40}
className="h-8 w-auto block dark:hidden"
priority
/>
<Image
src="/white-logo.png"
alt="blcklst"
width={120}
height={40}
className="h-8 w-auto hidden dark:block"
priority
/>
</Link>
</div>
{/* Simplified action buttons for SSR */}
<div className="flex items-center space-x-1 sm:space-x-2">
<Button
variant="ghost"
size="icon"
className="lg:hidden nav-button-transparent backdrop-blur-sm min-w-[44px] min-h-[44px]"
disabled
>
<Search className="h-5 w-5" />
</Button>
<Button
variant="ghost"
size="icon"
className="relative nav-button-transparent backdrop-blur-sm min-w-[44px] min-h-[44px]"
disabled
>
<ShoppingBag className="h-5 w-5" />
</Button>
</div>
</div>
</div>
</div>
</header>
);
}
return (
<header className="sticky top-0 z-50 w-full bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60">
{/* Top banner */}
<div className="bg-black text-white text-center py-2 px-4">
<p className="text-sm font-medium">
FREE SHIPPING ON ORDERS OVER $100 β’ NEW ARRIVALS EVERY WEEK
</p>
</div>
{/* Announcement bar */}
<div className="bg-neutral-100 dark:bg-neutral-800 text-center py-2 px-4">
<p className="text-sm">
π₯ <span className="font-semibold">WINTER SALE</span> - Up to 50% off on selected items
</p>
</div>
{/* Main header */}
<div className="border-b dark:border-neutral-800">
<div className="container mx-auto px-3 sm:px-4 lg:px-6">
<div className="flex h-14 sm:h-16 items-center justify-between gap-2 sm:gap-4">
{/* Mobile menu */}
<Sheet>
<SheetTrigger asChild>
<Button
variant="ghost"
size="icon"
className="md:hidden nav-button-transparent backdrop-blur-sm"
>
<Menu className="h-5 w-5" />
</Button>
</SheetTrigger>
<SheetContent
ref={sheetRef}
side="left"
className="w-[280px] xs:w-[320px] sm:w-[380px] p-0 border-r dark:border-neutral-800"
onOpenAutoFocus={(event) => {
// Prevent auto focus to avoid scroll handling issues
event.preventDefault();
}}
onCloseAutoFocus={(event) => {
// Prevent auto focus to avoid scroll handling issues
event.preventDefault();
}}
onEscapeKeyDown={(event) => {
// Handle escape key gracefully
try {
// Default behavior
} catch (error) {
console.warn('Escape key handling error:', error);
event.preventDefault();
}
}}
onPointerDownOutside={(event) => {
// Handle pointer events gracefully
try {
// Default behavior
} catch (error) {
console.warn('Pointer down outside error:', error);
event.preventDefault();
}
}}
>
<div className="flex flex-col h-full">
{/* Header Section */}
<SheetHeader className="px-6 py-4 border-b dark:border-neutral-800 bg-neutral-50 dark:bg-neutral-900">
<SheetTitle className="text-left text-lg font-semibold">
Menu
</SheetTitle>
</SheetHeader>
{/* Navigation Section */}
<div className="flex-1 overflow-y-auto">
<nav className="px-4 py-6 space-y-6">
{categories.map((category) => (
<div key={category.title} className="space-y-3">
{/* Category Header */}
<h3 className="px-2 text-sm font-semibold text-foreground uppercase tracking-wider border-b border-neutral-200 dark:border-neutral-700 pb-2">
{category.title}
</h3>
{/* Category Items */}
<div className="space-y-1">
{category.items.map((item) => (
<Link
key={item.name}
href={item.href}
className="flex items-center px-3 py-3 text-sm text-muted-foreground hover:text-foreground hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded-lg transition-all duration-200 touch-manipulation min-h-[44px]"
>
<span className="flex-1">{item.name}</span>
<svg
className="w-4 h-4 opacity-40"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5l7 7-7 7" />
</svg>
</Link>
))}
</div>
</div>
))}
{/* Sale Section */}
<div className="space-y-3 pt-4 border-t border-neutral-200 dark:border-neutral-700">
<h3 className="px-2 text-sm font-semibold text-red-600 uppercase tracking-wider">
Special
</h3>
<Link
href="/sale"
className="flex items-center px-3 py-3 text-sm font-medium text-red-600 hover:text-red-700 hover:bg-red-50 dark:hover:bg-red-950/30 rounded-lg transition-all duration-200 touch-manipulation min-h-[44px]"
>
<span className="flex-1">Sale Items</span>
<svg
className="w-4 h-4"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5l7 7-7 7" />
</svg>
</Link>
</div>
</nav>
</div>
{/* Footer Section */}
<div className="border-t dark:border-neutral-800 bg-neutral-50 dark:bg-neutral-900 px-4 py-4">
<div className="grid grid-cols-2 gap-3">
{/* Search Button */}
<Button
variant="outline"
size="sm"
className="flex items-center justify-center gap-2 h-10 text-xs font-medium"
>
<Search className="h-4 w-4" />
Search
</Button>
{/* Account Button */}
<Button
variant="outline"
size="sm"
className="flex items-center justify-center gap-2 h-10 text-xs font-medium"
>
<User className="h-4 w-4" />
Account
</Button>
</div>
{/* Quick Actions */}
<div className="flex items-center justify-center space-x-6 mt-4 pt-3 border-t border-neutral-200 dark:border-neutral-700">
<button className="flex flex-col items-center space-y-1 p-2 rounded-lg hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors touch-manipulation relative">
<Heart className="h-5 w-5 text-muted-foreground" />
<span className="text-xs text-muted-foreground">Wishlist</span>
{wishlistItems > 0 && (
<Badge className="absolute -top-1 -right-1 h-4 w-4 rounded-full p-0 text-xs">
{wishlistItems}
</Badge>
)}
</button>
<button className="flex flex-col items-center space-y-1 p-2 rounded-lg hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors touch-manipulation relative">
<ShoppingBag className="h-5 w-5 text-muted-foreground" />
<span className="text-xs text-muted-foreground">Cart</span>
{cartItems > 0 && (
<Badge className="absolute -top-1 -right-1 h-4 w-4 rounded-full p-0 text-xs">
{cartItems}
</Badge>
)}
</button>
<button className="flex flex-col items-center space-y-1 p-2 rounded-lg hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors touch-manipulation">
<Globe className="h-5 w-5 text-muted-foreground" />
<span className="text-xs text-muted-foreground">USD</span>
</button>
</div>
</div>
</div>
</SheetContent>
</Sheet>
{/* Logo */}
<div className="flex items-center">
<Link href="/" className="flex items-center space-x-2">
{/* Light theme logo - visible by default, hidden in dark mode */}
<Image
src="/black-logo.png"
alt="blcklst"
width={120}
height={40}
className="h-8 w-auto block dark:hidden"
priority
/>
{/* Dark theme logo - hidden by default, visible in dark mode */}
<Image
src="/white-logo.png"
alt="blcklst"
width={120}
height={40}
className="h-8 w-auto hidden dark:block"
priority
/>
</Link>
</div>
{/* Desktop Navigation */}
<NavigationMenu className="hidden md:flex">
<NavigationMenuList>
{categories.map((category) => (
<NavigationMenuItem key={category.title}>
<NavigationMenuTrigger
className="font-medium nav-button-transparent backdrop-blur-sm"
>
{category.title}
</NavigationMenuTrigger>
<NavigationMenuContent>
<div className="grid w-[400px] gap-3 p-4 md:w-[500px] md:grid-cols-2 lg:w-[600px] nav-dropdown-transparent">
{category.items.map((item) => (
<NavigationMenuLink key={item.name} asChild>
<Link
href={item.href}
className="block select-none space-y-1 rounded-md p-3 leading-none no-underline outline-none transition-colors nav-dropdown-item backdrop-blur-sm"
>
<div className="text-sm font-medium leading-none">{item.name}</div>
</Link>
</NavigationMenuLink>
))}
</div>
</NavigationMenuContent>
</NavigationMenuItem>
))}
<NavigationMenuItem>
<NavigationMenuLink asChild>
<Link href="/sale" className="font-medium text-red-600 hover:text-red-700 px-4 py-2 rounded-md nav-button-transparent backdrop-blur-sm transition-colors">
Sale
</Link>
</NavigationMenuLink>
</NavigationMenuItem>
</NavigationMenuList>
</NavigationMenu>
{/* Search Bar */}
<div className="hidden lg:flex flex-1 max-w-sm mx-8">
<div className="relative w-full">
<Search className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
<Input
placeholder="Search products..."
className="pl-10 pr-4"
/>
</div>
</div>
{/* Action buttons */}
<div className="flex items-center space-x-1 sm:space-x-2">
{/* Search icon for mobile */}
<Button
variant="ghost"
size="icon"
className="lg:hidden nav-button-transparent backdrop-blur-sm min-w-[44px] min-h-[44px]"
>
<Search className="h-5 w-5" />
</Button>
{/* Theme toggle */}
<div className="hidden sm:block">
<ThemeToggle />
</div>
{/* User menu - Hidden on small mobile, visible on larger screens */}
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
variant="ghost"
size="icon"
className="hidden sm:flex nav-button-transparent backdrop-blur-sm min-w-[44px] min-h-[44px]"
>
<User className="h-5 w-5" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-56 nav-dropdown-transparent">
<DropdownMenuItem className="nav-dropdown-item">
<User className="mr-2 h-4 w-4" />
My Account
</DropdownMenuItem>
<DropdownMenuItem className="nav-dropdown-item">
<Truck className="mr-2 h-4 w-4" />
Orders
</DropdownMenuItem>
<DropdownMenuItem className="nav-dropdown-item">
<Heart className="mr-2 h-4 w-4" />
Wishlist
</DropdownMenuItem>
<DropdownMenuSeparator className="bg-white/20 dark:bg-neutral-800/50" />
<DropdownMenuItem className="nav-dropdown-item">
Sign In
</DropdownMenuItem>
<DropdownMenuItem className="nav-dropdown-item">
Create Account
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
{/* Wishlist - Hidden on small mobile */}
<Button
variant="ghost"
size="icon"
className="relative hidden xs:flex nav-button-transparent backdrop-blur-sm min-w-[44px] min-h-[44px]"
>
<Heart className="h-5 w-5" />
{wishlistItems > 0 && (
<Badge className="absolute -top-1 -right-1 h-5 w-5 rounded-full p-0 text-xs">
{wishlistItems}
</Badge>
)}
</Button>
{/* Cart - Always visible */}
<Button
variant="ghost"
size="icon"
className="relative nav-button-transparent backdrop-blur-sm min-w-[44px] min-h-[44px]"
>
<ShoppingBag className="h-5 w-5" />
{cartItems > 0 && (
<Badge className="absolute -top-1 -right-1 h-5 w-5 rounded-full p-0 text-xs">
{cartItems}
</Badge>
)}
</Button>
{/* Language/Currency - Hidden on mobile */}
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
variant="ghost"
size="icon"
className="hidden md:flex nav-button-transparent backdrop-blur-sm min-w-[44px] min-h-[44px]"
>
<Globe className="h-5 w-5" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="nav-dropdown-transparent">
<DropdownMenuItem className="nav-dropdown-item">πΊπΈ USD</DropdownMenuItem>
<DropdownMenuItem className="nav-dropdown-item">πͺπΊ EUR</DropdownMenuItem>
<DropdownMenuItem className="nav-dropdown-item">π¬π§ GBP</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
</div>
</div>
</div>
{/* Service features */}
<div className="hidden md:block border-b dark:border-neutral-800 bg-neutral-50 dark:bg-neutral-900">
<div className="container mx-auto px-4">
<div className="grid grid-cols-4 gap-4 py-2 text-xs text-muted-foreground">
<div className="flex items-center justify-center space-x-1">
<Truck className="h-3 w-3" />
<span>Free Shipping</span>
</div>
<div className="flex items-center justify-center space-x-1">
<RefreshCw className="h-3 w-3" />
<span>30-Day Returns</span>
</div>
<div className="flex items-center justify-center space-x-1">
<Shield className="h-3 w-3" />
<span>Secure Payment</span>
</div>
<div className="flex items-center justify-center space-x-1">
<Phone className="h-3 w-3" />
<span>24/7 Support</span>
</div>
</div>
</div>
</div>
</header>
);
}
|