feat(theme): add postMessage listener for real-time appearance updates in dashboard
This commit is contained in:
parent
02aeb97aa5
commit
735f2da8a0
1 changed files with 37 additions and 0 deletions
|
|
@ -62,6 +62,43 @@
|
||||||
|
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
<script type="module" src="/src/main.tsx"></script>
|
<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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue