Spaces:
Running
Running
File size: 777 Bytes
f871fed |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
// This script runs before React hydration to prevent theme flash
export const themeScript = `
(function() {
try {
var theme = JSON.parse(localStorage.getItem('theme-storage') || '{}').state?.theme || 'system';
var systemPrefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
var effectiveTheme = theme === 'system' ? (systemPrefersDark ? 'dark' : 'light') : theme;
document.documentElement.classList.remove('light', 'dark');
document.documentElement.classList.add(effectiveTheme);
document.documentElement.setAttribute('data-theme', effectiveTheme);
} catch (e) {
// Fallback to light theme
document.documentElement.classList.add('light');
document.documentElement.setAttribute('data-theme', 'light');
}
})();
` |