/* Sobha Realty campaign microsite — main app + tweaks */ const { useState, useEffect } = React; const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{ "locale": "EN", "accent": "Green primary", "showLeadBand": true, "density": "comfortable", "showFAB": true, "heroOverlay": "Dusk", "scale": 100 }/*EDITMODE-END*/; const ACCENTS = { "Green primary": { primary:"#1F6B4E", primaryDeep:"#114334", signal:"#B51E23", primaryTint:"#E7EFE9", accent:"#A8844F" }, "Red primary": { primary:"#B51E23", primaryDeep:"#7C1418", signal:"#1F6B4E", primaryTint:"#FCEAEC", accent:"#A8844F" }, "Stone primary": { primary:"#A8844F", primaryDeep:"#6C5026", signal:"#B51E23", primaryTint:"#F1E9DA", accent:"#1F6B4E" } }; const HERO_OVERLAYS = { "Dusk": "media/render-sobha-one-night-overview.webp", "Morning": "media/render-sobha-one-morning.webp", "Twilight": "media/render-sobha-one-dusk.webp", "Master": "media/community-sobha-one.webp" }; function applyAccent(name){ const c = ACCENTS[name] || ACCENTS["Green primary"]; const r = document.documentElement.style; r.setProperty("--primary", c.primary); r.setProperty("--primary-deep", c.primaryDeep); r.setProperty("--signal", c.signal); r.setProperty("--primary-tint", c.primaryTint); r.setProperty("--accent", c.accent); } function applyDensity(d){ document.documentElement.style.setProperty("--gutter", d === "tight" ? "clamp(16px,3vw,40px)" : d === "loose" ? "clamp(28px,5vw,88px)" : "clamp(20px,4vw,64px)"); } function App() { const [t, setTweak] = useTweaks(TWEAK_DEFAULTS); const [modal, setModal] = useState(null); useEffect(() => { applyAccent(t.accent); }, [t.accent]); useEffect(() => { applyDensity(t.density); }, [t.density]); useEffect(() => { document.documentElement.setAttribute("data-locale", t.locale.toLowerCase()); }, [t.locale]); // override featured heroImg based on tweak const i18n = window.SR_DATA.i18n[t.locale] || window.SR_DATA.i18n.EN; // patch the featured hero image live window.SR_DATA.featured.heroImg = HERO_OVERLAYS[t.heroOverlay] || HERO_OVERLAYS.Dusk; const open = (name) => setModal(name); const close = () => setModal(null); return ( <> setTweak("locale", v)} openRegister={()=>open("register")} t={i18n} /> open("register")} openBrochure={()=>open("brochure")} openViewing={()=>open("viewing")} t={i18n} /> open("brochure")} openViewing={()=>open("viewing")} t={i18n} /> {t.showLeadBand && open("broker")} />} open("register")} openBroker={()=>open("broker")} openViewing={()=>open("viewing")} /> {t.showFAB && } {modal === "register" && } {modal === "brochure" && } {modal === "viewing" && } {modal === "broker" && } setTweak("locale", v)} /> setTweak("accent", v)} /> setTweak("heroOverlay", v)} /> setTweak("density", v)} /> setTweak("showLeadBand", v)} /> setTweak("showFAB", v)} /> ); } ReactDOM.createRoot(document.getElementById("root")).render();