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
+28 -16
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 {
var openerRoot = window.opener.document.documentElement;
var cs = window.opener.getComputedStyle(openerRoot);
// Copy every CSS variable (--*) from main app to popout
for (var i = 0; i < cs.length; i++) {
var prop = cs[i];
if (prop.startsWith('--')) {
root.style.setProperty(prop, cs.getPropertyValue(prop));
} }
// Fallback: read from localStorage theme key + mode }
var themeKey = localStorage.getItem('obsigate-theme') || 'dark'; // Also copy inline style as backup
var themeMode = localStorage.getItem('obsigate-theme-mode') || 'dark'; root.style.cssText = openerRoot.style.cssText;
document.documentElement.setAttribute('data-theme', themeMode); // Copy data-theme attribute
// Also set inline background/color as absolute fallback root.setAttribute('data-theme', openerRoot.getAttribute('data-theme') || 'dark');
if (!window.opener || !window.opener.document.documentElement.style.cssText) { } catch(e) {
var bg = themeMode === 'light' ? '#ffffff' : '#0f1117'; // Cross-origin or security restriction — use localStorage fallback
var fg = themeMode === 'light' ? '#1a1a1a' : '#e6edf3'; var mode = localStorage.getItem('obsigate-theme-mode') || 'dark';
document.documentElement.style.setProperty('--bg-primary', bg, 'important'); root.setAttribute('data-theme', mode);
document.documentElement.style.setProperty('--text-primary', fg, 'important'); root.style.setProperty('--bg-primary', mode === 'light' ? '#fff' : '#0f1117');
document.body.style.background = bg; root.style.setProperty('--text-primary', mode === 'light' ? '#1a1a1a' : '#e6edf3');
document.body.style.color = fg; }
} 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>