function Header({ onSearch, onToggleDark, dark, favCount }) {
const [scrolled, setScrolled] = useState(false);
const [hover, setHover] = useState(null);
const [searchOpen, setSearchOpen] = useState(false);
const [menuOpen, setMenuOpen] = useState(false);
const mobile = useMobile();
useEffect(() => {
const on = () => setScrolled(window.scrollY > 30);
window.addEventListener("scroll", on);
return () => window.removeEventListener("scroll", on);
}, []);
return (
);
}
function SearchOverlay({ onClose }) {
const [q, setQ] = useState("");
const inputRef = useRef();
useEffect(() => { inputRef.current?.focus(); }, []);
const all = useMemo(() => [
...STORIES.map(s => ({ type: s.cat, title: s.title, dek: s.dek })),
...EVENTS.map(e => ({ type: "Evento", title: e.title, dek: `${e.place} · ${e.day} ${e.month}` })),
...MAP_POINTS.map(p => ({ type: "Luogo", title: p.name, dek: p.province })),
], []);
const results = q.length > 1
? all.filter(x => (x.title + x.dek).toLowerCase().includes(q.toLowerCase())).slice(0, 8)
: [];
return (
Cerca in Calabria Svelata
setQ(e.target.value)}
placeholder="Cerca luoghi, eventi, storie..."
style={{
flex: 1, border: "none", background: "transparent", outline: "none",
fontFamily: "'Fraunces', Georgia, serif", fontSize: "clamp(22px, 4vw, 48px)", color: "var(--ink)",
}} />
{q.length > 1 ? (
{results.length === 0 &&
Nessun risultato
}
{results.map((r, i) => (
{r.type}
))}
) : (
Ricerche suggerite
{["Tropea", "Sila", "Bronzi di Riace", "Bergamotto", "Aspromonte", "Borghi arbëresh"].map(s => (
))}
)}
);
}
window.Header = Header;