From 1aa365177faacdce9f38590d531d51a81c0a5e75 Mon Sep 17 00:00:00 2001 From: cupadev-admin Date: Mon, 9 Mar 2026 14:32:15 +0000 Subject: [PATCH] fix: apply designer agent improvements to src/components/public/PublicHeader.tsx --- src/components/public/PublicHeader.tsx | 194 +++++++++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 src/components/public/PublicHeader.tsx diff --git a/src/components/public/PublicHeader.tsx b/src/components/public/PublicHeader.tsx new file mode 100644 index 0000000..58ce613 --- /dev/null +++ b/src/components/public/PublicHeader.tsx @@ -0,0 +1,194 @@ +'use client' + +import React, { useState, useEffect, useRef } from 'react' +import Link from 'next/link' +import { usePathname } from 'next/navigation' +import { Menu, X, Zap } from 'lucide-react' +import clsx from 'clsx' + +const NAV_LINKS = [ + { label: 'Home', href: '/' }, + { label: 'Blog', href: '/blog' }, + { label: 'About', href: '/about' }, +] as const + +export default function PublicHeader() { + const pathname = usePathname() + const [open, setOpen] = useState(false) + const [scrolled, setScrolled] = useState(false) + const mobileMenuRef = useRef(null) + const hamburgerRef = useRef(null) + + /* Scroll shadow */ + useEffect(() => { + const onScroll = () => setScrolled(window.scrollY > 12) + window.addEventListener('scroll', onScroll, { passive: true }) + return () => window.removeEventListener('scroll', onScroll) + }, []) + + /* Close mobile menu on route change */ + useEffect(() => { setOpen(false) }, [pathname]) + + /* Trap focus inside mobile menu */ + useEffect(() => { + if (!open) return + const focusable = mobileMenuRef.current?.querySelectorAll( + 'a, button, [tabindex]:not([tabindex="-1"])' + ) + focusable?.[0]?.focus() + + const handleKeyDown = (e: KeyboardEvent) => { + if (e.key === 'Escape') { + setOpen(false) + hamburgerRef.current?.focus() + } + } + document.addEventListener('keydown', handleKeyDown) + return () => document.removeEventListener('keydown', handleKeyDown) + }, [open]) + + return ( + <> + {/* Skip link */} + + Skip to main content + + +
+
+
+
+ + {/* Logo */} + + + + CupaDev + CMS + + + + {/* Desktop nav */} + + + {/* Desktop CTA */} +
+ + Admin + +
+ + {/* Mobile hamburger */} + + +
+
+
+ + {/* Mobile menu */} + +
+ + ) +}