2
0
mirror of https://github.com/frappe/books.git synced 2024-11-09 15:20:56 +00:00

feat: Added checks for system theme

This commit is contained in:
pu-raihan 2024-03-27 13:09:53 +05:30
parent 70e3aacbdc
commit 0eb63e5a1a
4 changed files with 11 additions and 5 deletions

View File

@ -32,7 +32,7 @@
@row-change="handleChange"
/>
<div class="mt-4 grid grid-cols-2 gap-4 flex items-end">
<div class="mt-4 grid grid-cols-2 gap-4 items-end">
<Button
class="w-full py-5 bg-red-500 dark:bg-red-700"
@click="$emit('toggleModal', 'ShiftClose', false)"

View File

@ -36,7 +36,7 @@
@row-change="handleChange"
/>
<div class="mt-4 grid grid-cols-2 gap-4 flex items-end">
<div class="mt-4 grid grid-cols-2 gap-4 items-end">
<Button
class="w-full py-5 bg-red-500 dark:bg-red-700"
@click="$router.back()"

View File

@ -21,8 +21,7 @@ import { setDarkMode } from './utils/theme';
}
fyo.store.language = language || 'English';
const darkMode = fyo.config.get('darkMode') as boolean;
setDarkMode(darkMode);
setDarkMode();
registerIpcRendererListeners();
const { isDevelopment, platform, version } = await ipc.getEnv();

View File

@ -11,7 +11,14 @@ export async function toggleDarkMode(): Promise<void> {
fyo.config.set('darkMode', true);
}
export function setDarkMode(darkMode: boolean): void {
export function setDarkMode(): void {
var darkMode = fyo.config.get('darkMode');
/* Fetching system theme */
if (darkMode === undefined){
darkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
fyo.config.set('darkMode', darkMode);
}
if (darkMode) {
document.documentElement.classList.add('dark');
return;