diff --git a/src/lib/components/AppLayout.svelte b/src/lib/components/AppLayout.svelte
index 3c10d44..11e3680 100644
--- a/src/lib/components/AppLayout.svelte
+++ b/src/lib/components/AppLayout.svelte
@@ -21,7 +21,6 @@
showSearch,
showCommandPalette,
theme,
- customThemes,
focusMode,
readOnly,
activeNote,
@@ -63,7 +62,7 @@
const isMac = navigator.platform.startsWith('Mac');
const isMobile = $derived($platformIsMobile);
import { loadVaultState, saveVaultState, readNote, createDailyNote, createBackup, getPendingOpenFile, addQuickAccess, removeQuickAccess, getQuickAccess, setTheme, syncNow, setTaskDone, setTaskPriority, setTaskDue, findOrphanedAttachments, trashOrphanedAttachments } from '$lib/api';
- import { applyTheme, isAndroid } from '$lib/platform';
+ import { darkThemes, isAndroid } from '$lib/platform';
import { debounce } from '$lib/utils/debounce';
import { openNoteWindow } from '$lib/utils/window';
import { get } from 'svelte/store';
@@ -510,8 +509,21 @@
}
}
+ function applyTheme(t: string) {
+ const namedThemes = ['solarized-light', 'solarized-dark', 'catppuccin', 'nord', 'tokyo-night', 'github-light', 'github-dark', 'dracula', 'blueberry', 'forest-green', 'gruvbox', 'midnight-tide', 'cherry-blossom', 'synthwave', 'ember', 'moonlit', 'light-coffee', 'dark-coffee', 'cotton-candy', 'crimson', 'cloud', 'peach', 'material-dark', 'material-light', 'monokai', 'rose-pine', 'everforest', 'horizon', 'cyberpunk', 'black', 'one-dark'];
+ const root = document.documentElement;
+ root.classList.remove('dark');
+ root.removeAttribute('data-theme');
+ if (namedThemes.includes(t)) {
+ root.setAttribute('data-theme', t);
+ if (darkThemes.includes(t)) root.classList.add('dark');
+ } else if (t === 'dark' || (t === 'system' && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
+ root.classList.add('dark');
+ }
+ }
+
$effect(() => {
- applyTheme($theme, $customThemes);
+ applyTheme($theme);
});
$effect(() => {
@@ -593,10 +605,10 @@
prefetchPromise = readNote(lastNotePath).catch(() => null);
}
- applyTheme($theme, $customThemes);
+ applyTheme($theme);
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
- if ($theme === 'system') applyTheme('system', $customThemes);
+ if ($theme === 'system') applyTheme('system');
});
// Run sidebar and note list refresh in parallel
diff --git a/src/lib/components/CommandPalette.svelte b/src/lib/components/CommandPalette.svelte
index a35545c..75289bf 100644
--- a/src/lib/components/CommandPalette.svelte
+++ b/src/lib/components/CommandPalette.svelte
@@ -1,7 +1,7 @@
{#if $showCommandPalette}
diff --git a/src/lib/components/NoteWindow.svelte b/src/lib/components/NoteWindow.svelte
index 95a15b0..4634cee 100644
--- a/src/lib/components/NoteWindow.svelte
+++ b/src/lib/components/NoteWindow.svelte
@@ -9,8 +9,7 @@
editorDirty,
readOnly,
sourceMode,
- theme,
- customThemes
+ theme
} from '$lib/stores/app';
import { readNote } from '$lib/api';
import { keybindings, matchAction } from '$lib/keybindings';
@@ -18,7 +17,7 @@
let { notePath }: { notePath: string } = $props();
- import { applyTheme } from '$lib/platform';
+ import { darkThemes } from '$lib/platform';
const appWindow = getCurrentWindow();
const isMac = navigator.platform.startsWith('Mac');
@@ -38,7 +37,17 @@
});
$effect(() => {
- applyTheme($theme || 'system', $customThemes);
+ const t = $theme || 'system';
+ const namedThemes = ['solarized-light', 'solarized-dark', 'catppuccin', 'nord', 'tokyo-night', 'github-light', 'github-dark', 'dracula', 'blueberry', 'forest-green', 'gruvbox', 'midnight-tide', 'cherry-blossom', 'synthwave', 'ember', 'moonlit', 'light-coffee', 'dark-coffee', 'cotton-candy', 'crimson', 'cloud', 'peach', 'material-dark', 'material-light', 'monokai', 'rose-pine', 'everforest', 'horizon', 'cyberpunk', 'black', 'one-dark'];
+ const root = document.documentElement;
+ root.classList.remove('dark');
+ root.removeAttribute('data-theme');
+ if (namedThemes.includes(t)) {
+ root.setAttribute('data-theme', t);
+ if (darkThemes.includes(t)) root.classList.add('dark');
+ } else if (t === 'dark' || (t === 'system' && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
+ root.classList.add('dark');
+ }
});
let lastMouseDown = 0;
diff --git a/src/lib/components/SettingsPanel.svelte b/src/lib/components/SettingsPanel.svelte
index 0689941..2ee8bcd 100644
--- a/src/lib/components/SettingsPanel.svelte
+++ b/src/lib/components/SettingsPanel.svelte
@@ -1,7 +1,7 @@