fix: copy ALL CSS custom properties via getComputedStyle from opener
CI / lint (push) Successful in 23s
CI / security (push) Successful in 13s
CI / test (push) Successful in 31s
CI / build (push) Successful in 9s
CI / e2e (push) Failing after 29s

- Iterates through ALL computed CSS variables (--*) from main app
- Uses getComputedStyle which works even if setProperty was used (themes.js)
- Sets properties via setProperty on popout root — EXACT theme match
- Fallback: localStorage obsigate-theme-mode for direct popout access
- Fixed typo in --text-primary (was 'teext-primary')
This commit is contained in:
2026-07-24 15:36:00 -04:00
parent 21ee86ffa0
commit b09a642f66
+29 -17
View File
@@ -5,24 +5,36 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ObsiGate - Popout</title> <title>ObsiGate - Popout</title>
<script> <script>
// Copy theme from opener window (uses themes.js inline styles via setProperty)
(function() { (function() {
if (window.opener && window.opener.document.documentElement.style.cssText) { var root = document.documentElement;
// Copy all CSS variable inline styles from main app // Primary: copy ALL CSS custom properties from main app's <html> element
document.documentElement.style.cssText = window.opener.document.documentElement.style.cssText; if (window.opener) {
} try {
// Fallback: read from localStorage theme key + mode var openerRoot = window.opener.document.documentElement;
var themeKey = localStorage.getItem('obsigate-theme') || 'dark'; var cs = window.opener.getComputedStyle(openerRoot);
var themeMode = localStorage.getItem('obsigate-theme-mode') || 'dark'; // Copy every CSS variable (--*) from main app to popout
document.documentElement.setAttribute('data-theme', themeMode); for (var i = 0; i < cs.length; i++) {
// Also set inline background/color as absolute fallback var prop = cs[i];
if (!window.opener || !window.opener.document.documentElement.style.cssText) { if (prop.startsWith('--')) {
var bg = themeMode === 'light' ? '#ffffff' : '#0f1117'; root.style.setProperty(prop, cs.getPropertyValue(prop));
var fg = themeMode === 'light' ? '#1a1a1a' : '#e6edf3'; }
document.documentElement.style.setProperty('--bg-primary', bg, 'important'); }
document.documentElement.style.setProperty('--text-primary', fg, 'important'); // Also copy inline style as backup
document.body.style.background = bg; root.style.cssText = openerRoot.style.cssText;
document.body.style.color = fg; // Copy data-theme attribute
root.setAttribute('data-theme', openerRoot.getAttribute('data-theme') || 'dark');
} catch(e) {
// Cross-origin or security restriction — use localStorage fallback
var mode = localStorage.getItem('obsigate-theme-mode') || 'dark';
root.setAttribute('data-theme', mode);
root.style.setProperty('--bg-primary', mode === 'light' ? '#fff' : '#0f1117');
root.style.setProperty('--text-primary', mode === 'light' ? '#1a1a1a' : '#e6edf3');
}
} else {
var mode = localStorage.getItem('obsigate-theme-mode') || 'dark';
root.setAttribute('data-theme', mode);
root.style.setProperty('--bg-primary', mode === 'light' ? '#fff' : '#0f1117');
root.style.setProperty('--text-primary', mode === 'light' ? '#1a1a1a' : '#e6edf3');
} }
})(); })();
</script> </script>