// app.jsx — root composition + Tweaks // White-base palette. Tweak swaps the live "pink + gold" pair against the // hard-coded brand defaults via an !important stylesheet that targets the // exact hex values used inline. const DEFAULTS = /*EDITMODE-BEGIN*/{ "palette": ["#EF859A", "#E5B34F"], "headingFont": "Cormorant Garamond" }/*EDITMODE-END*/; // Authoritative defaults — these MUST match the BRAND constants in site.jsx. // The override sheet targets these specific hex codes; if BRAND changes, so // must this map. const DEFAULT_PINK = '#EF859A'; const DEFAULT_GOLD = '#E5B34F'; function App() { const [t, setTweak] = useTweaks(DEFAULTS); React.useEffect(() => { let el = document.getElementById('__tweak-overrides'); if (!el) { el = document.createElement('style'); el.id = '__tweak-overrides'; document.head.appendChild(el); } const [pink, gold] = t.palette; // Helper: build property override blocks for every inline-style form a // hex code can take. CSS attribute selectors require exact matches, and // React serializes inline styles as `color: rgb(...)` for named props, // but `background: #HEX` for string literals — so we cover both. const hexAlts = (hex) => { const h = hex.replace('#', ''); const r = parseInt(h.slice(0, 2), 16); const g = parseInt(h.slice(2, 4), 16); const b = parseInt(h.slice(4, 6), 16); return [hex.toUpperCase(), hex.toLowerCase(), `rgb(${r}, ${g}, ${b})`]; }; const swap = (orig, repl) => { const alts = hexAlts(orig); const sels = (prop) => alts.flatMap((a) => [ `[style*="${prop}: ${a}"]`, `[style*="${prop}:${a}"]`, ]).join(','); return ` ${sels('color')} { color: ${repl} !important; } ${sels('background')} { background: ${repl} !important; } ${sels('background-color')} { background-color: ${repl} !important; } ${sels('border-color')} { border-color: ${repl} !important; } ${sels('border: 1px solid')} { border-color: ${repl} !important; } ${sels('fill')} { fill: ${repl} !important; } `; }; el.textContent = ` h1, h2, h3, h4 { font-family: "${t.headingFont}", "Cormorant Garamond", serif !important; } ${swap(DEFAULT_PINK, pink)} ${swap(DEFAULT_GOLD, gold)} `; }, [t.headingFont, t.palette]); return ( <>