feat(theme): add postMessage listener for real-time appearance updates in dashboard
This commit is contained in:
parent
803f5b8a0b
commit
7c9fb33489
2 changed files with 74 additions and 0 deletions
|
|
@ -31,6 +31,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>
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,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>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue