B: Fix dark theme loading

This commit is contained in:
Ivan 2025-06-19 00:16:02 +03:00
parent e6d0b50833
commit 59fa2c36de

View File

@ -29,6 +29,18 @@
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script>
try {
const preferences = JSON.parse(localStorage.getItem('portal.preferences') || '{}').state;
const isDark = preferences ? preferences.darkMode : window.matchMedia('(prefers-color-scheme: dark)').matches;
if (isDark) {
document.documentElement.classList.add('dark');
} else {
document.documentElement.classList.remove('dark');
}
document.documentElement.setAttribute('data-color-scheme', isDark ? 'dark' : 'light');
} catch (e) {}
</script>
<script type="module" src="/src/main.tsx"></script> <script type="module" src="/src/main.tsx"></script>
</body> </body>
</html> </html>