Fix dark theme

This commit is contained in:
koalasat
2025-07-28 12:09:51 +02:00
parent 1bf5df500f
commit 1317cd6bc2
4 changed files with 20 additions and 2 deletions

View File

@ -67,7 +67,10 @@ class BaseSettings {
}
getMode = (): 'light' | 'dark' => {
return window?.matchMedia('(prefers-color-scheme: dark)')?.matches ? 'dark' : 'light';
return (systemClient.getSyncItem?.('settings_mode') as 'light' | 'dark') ||
window?.matchMedia('(prefers-color-scheme: dark)')?.matches
? 'dark'
: 'light';
};
public frontend: 'basic' | 'pro' = 'basic';

View File

@ -33,6 +33,12 @@ class SystemWebClient implements SystemClient {
return value ?? '';
};
// Local storage
public getSyncItem: (key: string) => string | undefined = (key) => {
const value = window.localStorage.getItem(key);
return value ?? '';
};
public setItem: (key: string, value: string) => void = (key, value) => {
window.localStorage.setItem(key, value);
};

View File

@ -5,6 +5,7 @@ import SystemAndroidClient from './SystemAndroidClient';
export interface SystemClient {
loading: boolean;
copyToClipboard: (value: string) => void;
getSyncItem?: (key: string) => string | undefined;
getItem: (key: string) => Promise<string | undefined>;
setItem: (key: string, value: string) => void;
deleteItem: (key: string) => void;

View File

@ -63,6 +63,14 @@
color: #c0392b;
text-decoration: underline;
}
/* Dark mode styles based on system preference */
@media (prefers-color-scheme: dark) {
body {
background-color: black;
color: #f0f0f0;
}
}
</style>
</head>
@ -116,4 +124,4 @@
</script>
</body>
</html>
</html>