feat(theme): add postMessage listener for real-time appearance updates in dashboard

This commit is contained in:
Autoblogia Bot 2026-05-15 13:53:48 +00:00
parent 9ea17f6a94
commit f0b0d5cad6
2 changed files with 74 additions and 0 deletions

View file

@ -51,6 +51,43 @@
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<!-- Theme Auto-Updater injected by autoblogia -->
<script>
window.addEventListener('message', (event) => {
if (event.data && event.data.type === 'UPDATE_APPEARANCE') {
const { primaryColor, backgroundColor, fontFamily } = event.data.settings;
const root = document.documentElement;
const style = root.style;
if (primaryColor) {
style.setProperty('--primary', primaryColor);
style.setProperty('--color-primary', primaryColor);
style.setProperty('--color-tech-primary', primaryColor);
style.setProperty('--color-seo-primary', primaryColor);
style.setProperty('--color-finance-primary', primaryColor);
style.setProperty('--color-recipe-primary', primaryColor);
style.setProperty('--color-health-primary', primaryColor);
style.setProperty('--color-corporate-primary', primaryColor);
}
if (backgroundColor) {
style.setProperty('--background', backgroundColor);
style.setProperty('--color-bg', backgroundColor);
style.setProperty('--color-tech-surface', backgroundColor);
style.setProperty('--color-seo-surface', backgroundColor);
style.backgroundColor = backgroundColor;
}
if (fontFamily) {
const fontString = '"' + fontFamily + '", sans-serif';
style.setProperty('--font-family', fontString);
style.setProperty('--font-sans', fontString);
style.fontFamily = fontString;
}
}
});
// Ping parent window that we are ready
window.parent.postMessage({ type: 'IFRAME_READY' }, '*');
</script>
</body>
</html>

View file

@ -51,6 +51,43 @@
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<!-- Theme Auto-Updater injected by autoblogia -->
<script>
window.addEventListener('message', (event) => {
if (event.data && event.data.type === 'UPDATE_APPEARANCE') {
const { primaryColor, backgroundColor, fontFamily } = event.data.settings;
const root = document.documentElement;
const style = root.style;
if (primaryColor) {
style.setProperty('--primary', primaryColor);
style.setProperty('--color-primary', primaryColor);
style.setProperty('--color-tech-primary', primaryColor);
style.setProperty('--color-seo-primary', primaryColor);
style.setProperty('--color-finance-primary', primaryColor);
style.setProperty('--color-recipe-primary', primaryColor);
style.setProperty('--color-health-primary', primaryColor);
style.setProperty('--color-corporate-primary', primaryColor);
}
if (backgroundColor) {
style.setProperty('--background', backgroundColor);
style.setProperty('--color-bg', backgroundColor);
style.setProperty('--color-tech-surface', backgroundColor);
style.setProperty('--color-seo-surface', backgroundColor);
style.backgroundColor = backgroundColor;
}
if (fontFamily) {
const fontString = '"' + fontFamily + '", sans-serif';
style.setProperty('--font-family', fontString);
style.setProperty('--font-sans', fontString);
style.fontFamily = fontString;
}
}
});
// Ping parent window that we are ready
window.parent.postMessage({ type: 'IFRAME_READY' }, '*');
</script>
</body>
</html>