/* global React, ReactDOM,
Header, Hero, TrustStrip, Treatments, TreatmentDrawer,
Dentists, Reviews, Contact, BookingModal, Footer, Floats,
TweaksPanel, TweakSection, TweakRadio, TweakSelect, TweakToggle, TweakColor, useTweaks */
const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{
"palette": "teal",
"density": "comfortable",
"displayFont": "Cormorant Garamond",
"showAccent": true,
"tab": "all"
}/*EDITMODE-END*/;
function App() {
const [t, setTweak] = useTweaks(TWEAK_DEFAULTS);
// apply palette + density to :root
React.useEffect(() => {
document.documentElement.setAttribute("data-palette", t.palette === "teal" ? "" : t.palette);
document.documentElement.setAttribute("data-density", t.density === "comfortable" ? "" : t.density);
document.documentElement.style.setProperty("--serif", `"${t.displayFont}", "Fraunces", Georgia, serif`);
}, [t.palette, t.density, t.displayFont]);
// scroll-spy
const SECTIONS = ["home", "treatments", "dentists", "reviews", "contact"];
const [active, setActive] = React.useState("home");
React.useEffect(() => {
const onScroll = () => {
const y = window.scrollY + window.innerHeight * 0.35;
let cur = SECTIONS[0];
for (const id of SECTIONS) {
const el = document.getElementById(id);
if (!el) continue;
const top = el.offsetTop;
if (y >= top) cur = id;
}
setActive(cur);
};
onScroll();
window.addEventListener("scroll", onScroll, { passive: true });
return () => window.removeEventListener("scroll", onScroll);
}, []);
const onNav = (id) => {
const el = document.getElementById(id);
if (el) el.scrollIntoView({ behavior: "smooth", block: "start" });
};
// booking modal
const [bookOpen, setBookOpen] = React.useState(false);
const [prefillTx, setPrefillTx] = React.useState(null);
const openBook = (txId) => { setPrefillTx(txId || null); setBookOpen(true); };
const closeBook = () => setBookOpen(false);
// treatment drawer
const [drawerTx, setDrawerTx] = React.useState(null);
const openTx = (tx) => setDrawerTx(tx);
const closeTx = () => setDrawerTx(null);
return (
openBook()} />
openBook()} />
openBook()} />
openBook()} />
openBook()} />
);
}
ReactDOM.createRoot(document.getElementById("root")).render();