/* global React */
function TweaksPanel({ visible, onClose }) {
const [tweaks, setTweaks] = React.useState(() => ({ ...(window.__TWEAKS__ || {}) }));
function set(k, v) {
const next = { ...tweaks, [k]: v };
setTweaks(next);
window.__TWEAKS__ = next;
applyTweaks(next);
window.parent?.postMessage?.({ type: "__edit_mode_set_keys", edits: { [k]: v } }, "*");
}
if (!visible) return null;
return (
Tweaks
set("showPreviewDesktop", !tweaks.showPreviewDesktop)}>
WhatsApp preview rail (desktop)
);
}
function applyTweaks(tweaks) {
const root = document.documentElement;
if (tweaks.accent) root.style.setProperty("--ws-yellow", tweaks.accent);
if (tweaks.background) root.style.setProperty("--ws-bg", tweaks.background);
const densityGap = tweaks.density === "compact" ? "10px" : "14px";
root.style.setProperty("--density-gap", densityGap);
// Preview rail toggle
document.body.classList.toggle("hide-preview-rail", !tweaks.showPreviewDesktop);
}
// Style: hide preview rail if tweaked off
const style = document.createElement("style");
style.textContent = `
body.hide-preview-rail .wizard-shell { grid-template-columns: 1fr !important; max-width: 820px; }
body.hide-preview-rail .preview-rail { display: none !important; }
`;
document.head.appendChild(style);
Object.assign(window, { TweaksPanel, applyTweaks });