// Tweaks panel — toggled from toolbar
const { useState, useEffect } = React;
const DEFAULTS = /*EDITMODE-BEGIN*/{
"palette": "amber",
"heroVariant": "both",
"showIndices": true
}/*EDITMODE-END*/;
function applyPalette(p) {
if (p === "amber") document.documentElement.removeAttribute("data-palette");
else document.documentElement.setAttribute("data-palette", p);
try { localStorage.setItem("ai_palette", p); } catch (e) {}
}
function applyHero(v) {
if (window.__heroSetVariant) window.__heroSetVariant(v);
}
function applyIndices(show) {
document.body.classList.toggle("hide-indices", !show);
}
function TweaksApp() {
const [open, setOpen] = useState(false);
const [t, setT] = useState(DEFAULTS);
useEffect(() => {
function onMsg(e) {
const d = e.data || {};
if (d.type === "__activate_edit_mode") setOpen(true);
if (d.type === "__deactivate_edit_mode") setOpen(false);
}
window.addEventListener("message", onMsg);
window.parent.postMessage({ type: "__edit_mode_available" }, "*");
// Apply initial
applyPalette(t.palette);
applyHero(t.heroVariant);
applyIndices(t.showIndices);
return () => window.removeEventListener("message", onMsg);
// eslint-disable-next-line
}, []);
function set(key, val) {
const next = { ...t, [key]: val };
setT(next);
if (key === "palette") applyPalette(val);
if (key === "heroVariant") applyHero(val);
if (key === "showIndices") applyIndices(val);
window.parent.postMessage({ type: "__edit_mode_set_keys", edits: { [key]: val } }, "*");
}
function close() {
setOpen(false);
window.parent.postMessage({ type: "__edit_mode_dismissed" }, "*");
}
if (!open) return null;
return (
TWEAKS
set("palette", v)} />
set("heroVariant", v)} />
set("showIndices", v === "on")} />
);
}
function Group({ label, children }) {
return (
);
}
function Seg({ val, options, onChange }) {
return (
{options.map(o => (
))}
);
}
const panelStyles = {
wrap: {
position: "fixed", right: 20, bottom: 20, zIndex: 999,
width: 280, background: "#0a0a0a",
border: "1px solid #3a3429",
boxShadow: "0 24px 60px rgba(0,0,0,0.6)",
fontFamily: "JetBrains Mono, ui-monospace, monospace",
color: "#f3f1ea",
},
header: {
display: "flex", justifyContent: "space-between", alignItems: "center",
padding: "10px 14px",
borderBottom: "1px solid #26221c",
background: "#111110",
},
title: {
fontSize: 11, letterSpacing: "0.12em", color: "#d97706", fontWeight: 600
},
close: {
background: "none", border: "none", color: "#7a756a",
fontSize: 22, lineHeight: 1, cursor: "pointer", padding: 0
},
body: { padding: 14, display: "flex", flexDirection: "column", gap: 16 },
group: { display: "flex", flexDirection: "column", gap: 8 },
groupLabel: {
fontSize: 10, letterSpacing: "0.12em", color: "#7a756a", fontWeight: 500
},
seg: {
display: "flex", border: "1px solid #26221c"
},
segBtn: {
flex: 1, padding: "8px 10px", background: "transparent",
border: "none", borderRight: "1px solid #26221c",
color: "#b9b3a5", cursor: "pointer",
fontFamily: "inherit", fontSize: 10, letterSpacing: "0.08em",
textTransform: "uppercase", fontWeight: 500
},
segBtnActive: {
background: "#d97706", color: "#0a0a0a"
}
};
ReactDOM.createRoot(document.getElementById("__tweaks_root")).render();