diff --git a/artifacts/ehsan-poc/public/opengraph.jpg b/artifacts/ehsan-poc/public/opengraph.jpg index a79711a..a7915ab 100644 Binary files a/artifacts/ehsan-poc/public/opengraph.jpg and b/artifacts/ehsan-poc/public/opengraph.jpg differ diff --git a/artifacts/ehsan-poc/src/components/layout/Header.tsx b/artifacts/ehsan-poc/src/components/layout/Header.tsx index 8207dda..463f965 100644 --- a/artifacts/ehsan-poc/src/components/layout/Header.tsx +++ b/artifacts/ehsan-poc/src/components/layout/Header.tsx @@ -1,15 +1,8 @@ -import { useState } from "react"; +import { useEffect, useRef, useState } from "react"; import { Link, useLocation } from "wouter"; import { useLanguage } from "../../contexts/LanguageContext"; import { useAuth } from "../../contexts/AuthContext"; import { Button } from "../ui/button"; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuSeparator, - DropdownMenuTrigger, -} from "../ui/dropdown-menu"; import { Search, ShoppingCart, @@ -36,11 +29,42 @@ export function Header() { const { isAuthenticated, logout } = useAuth(); const [location, setLocation] = useLocation(); const [mobileOpen, setMobileOpen] = useState(false); + const [servicesOpen, setServicesOpen] = useState(false); + const servicesTriggerRef = useRef(null); + const servicesPanelRef = useRef(null); const toggleLanguage = () => setLanguage(language === "ar" ? "en" : "ar"); const isActive = (path: string) => location === path; + const handleServiceClick = (path: string) => { + setServicesOpen(false); + setLocation(path); + }; + + useEffect(() => { + if (!servicesOpen) return; + const onPointerDown = (e: MouseEvent) => { + const target = e.target as Node; + if ( + servicesPanelRef.current?.contains(target) || + servicesTriggerRef.current?.contains(target) + ) { + return; + } + setServicesOpen(false); + }; + const onKeyDown = (e: KeyboardEvent) => { + if (e.key === "Escape") setServicesOpen(false); + }; + document.addEventListener("mousedown", onPointerDown); + document.addEventListener("keydown", onKeyDown); + return () => { + document.removeEventListener("mousedown", onPointerDown); + document.removeEventListener("keydown", onKeyDown); + }; + }, [servicesOpen]); + const services = [ { key: "ghiras", label: t.serviceItems.ghiras, icon: Sprout }, { key: "zakat", label: t.serviceItems.zakat, icon: HandCoins }, @@ -53,7 +77,7 @@ export function Header() { ]; return ( -
+
{/* Logo */} @@ -89,39 +113,23 @@ export function Header() { - - - - - - {services.map((s) => ( - setLocation("/opportunities")} - data-testid={`nav-service-${s.key}`} - className="gap-2 cursor-pointer" - > - - {s.label} - - ))} - - setLocation("/request")} - data-testid="nav-requestSupport" - className="gap-2 cursor-pointer" - > - - {t.nav.requestSupport} - - - + {t.nav.about} @@ -200,6 +208,46 @@ export function Header() {
+ {/* Services mega-menu (desktop) */} + {servicesOpen && ( + + )} + {/* Mobile nav panel */} {mobileOpen && (