import { Menu, ShoppingBag, X } from 'lucide-react'; import { useEffect, useState } from 'react'; import { cn } from '@/lib/utils'; import { useStorefront } from '../context'; import { storefrontText } from '../text'; import type { HeaderSection } from '../types'; import { Container, SfButton, SfLink } from '../ui'; export function Header({ section, }: { section: Pick; }) { const { logoText, links, cta } = section.content; const centered = section.variant === 'centered'; const { cart, language } = useStorefront(); const t = storefrontText(language); const [open, setOpen] = useState(false); // Escape closes the phone menu. useEffect(() => { if (!open) { return; } const close = (event: KeyboardEvent) => { if (event.key === 'Escape') { setOpen(false); } }; window.addEventListener('keydown', close); return () => window.removeEventListener('keydown', close); }, [open]); const cartLink = ( ); // Only on phones: opens the list of links. const menuButton = links.length > 0 || cta ? ( ) : (