mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 14:50:32 +00:00
feat: theme preloading and dark mode
This commit is contained in:
@@ -9,7 +9,8 @@
|
|||||||
name="description"
|
name="description"
|
||||||
content="Bigcapital Financial Managment Software"
|
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>
|
<title>Bigcapital</title>
|
||||||
</head>
|
</head>
|
||||||
<body class="bp4-dark">
|
<body class="bp4-dark">
|
||||||
@@ -25,4 +26,3 @@
|
|||||||
<script type="module" src="/src/index.tsx"></script>
|
<script type="module" src="/src/index.tsx"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|||||||
16
packages/webapp/public/preload-theme.js
Normal file
16
packages/webapp/public/preload-theme.js
Normal 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');
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user