/* VSHD chrome: Nav, Footer, Enquiry panel, Lightbox */
const { useState, useEffect, useRef } = React;
/* ----- Wordmark (uses vshd-logo.svg vector, falls back to text) ----- */
function VshdMark({ dark }) {
return (
);
}
/* ----- Nav ----- */
function Nav({ route, go, dark, onOpenEnquiry, lang, setLang }) {
const [solid, setSolid] = useState(false);
useEffect(() => {
const onScroll = () => setSolid(window.scrollY > 30);
window.addEventListener("scroll", onScroll, { passive: true });
onScroll();
return () => window.removeEventListener("scroll", onScroll);
}, []);
const NavLink = ({ to, children }) => (
{ e.preventDefault(); go(to); }}
className={route.startsWith(to) && to !== "" ? "is-active" : (route === "" && to === "" ? "is-active" : "")}
>{children}
);
return (
);
}
/* ----- Footer ----- */
function Footer({ onOpenEnquiry, go }) {
return (
);
}
/* ----- Enquiry slide-over ----- */
function EnquiryPanel({ open, onClose }) {
const [submitted, setSubmitted] = useState(false);
const formRef = useRef(null);
useEffect(() => {
const onKey = (e) => { if (e.key === "Escape" && open) onClose(); };
window.addEventListener("keydown", onKey);
return () => window.removeEventListener("keydown", onKey);
}, [open, onClose]);
useEffect(() => {
if (open) {
document.body.style.overflow = "hidden";
} else {
document.body.style.overflow = "";
}
return () => { document.body.style.overflow = ""; };
}, [open]);
const handleSubmit = (e) => {
e.preventDefault();
setSubmitted(true);
};
return (
<>
>
);
}
/* ----- Lightbox ----- */
function Lightbox({ src, caption, onClose }) {
useEffect(() => {
const onKey = (e) => { if (e.key === "Escape") onClose(); };
if (src) window.addEventListener("keydown", onKey);
return () => window.removeEventListener("keydown", onKey);
}, [src, onClose]);
return (
{src &&

}
{caption &&
{caption}
}
);
}
Object.assign(window, { Nav, Footer, EnquiryPanel, Lightbox, VshdMark });