feat: theme preloading and dark mode

This commit is contained in:
Ahmed Bouhuolia
2025-11-26 21:27:42 +02:00
parent 8817be4813
commit 74e46364ac
2 changed files with 18 additions and 2 deletions

View File

@@ -9,7 +9,8 @@
name="description"
content="Bigcapital Financial Managment Software"
/>
<link rel="manifest" href="/manifest.json" />
<link rel="modulepreload" href="/manifest.json" />
<script type="module" src="/public/preload-theme.js"></script>
<title>Bigcapital</title>
</head>
<body class="bp4-dark">
@@ -25,4 +26,3 @@
<script type="module" src="/src/index.tsx"></script>
</body>
</html>

View File

@@ -0,0 +1,16 @@
const theme =
localStorage.getItem('theme') ||
(window.matchMedia('(prefers-color-scheme: dark)').matches
? 'dark'
: 'light');
if (theme === 'dark') {
document.documentElement.classList.add('bp4-dark');
document.body.classList.add('bp4-dark');
}
// Remove dark mode for payment portal pages
if (window.location.pathname.startsWith('/payment')) {
document.documentElement.classList.remove('bp4-dark');
document.body.classList.remove('bp4-dark');
}