theme: obsidian-prism

This commit is contained in:
Per Stark
2026-01-17 08:45:47 +01:00
parent fa7f407306
commit a9fda67209
4 changed files with 169 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ const handleSystemThemeChange = (e) => {
if (themePreference === 'system') {
document.documentElement.setAttribute('data-theme', e.matches ? 'dark' : 'light');
}
// For explicit themes like 'obsidian-prism', 'light', 'dark' - do nothing on system change
};
const initializeTheme = () => {
@@ -57,11 +58,12 @@ const initializeTheme = () => {
isSystemListenerAttached = true;
}
} else {
// Explicit theme: 'light', 'dark', 'obsidian-prism', etc.
if (isSystemListenerAttached) {
systemMediaQuery.removeEventListener('change', handleSystemThemeChange);
isSystemListenerAttached = false;
}
// Ensure data-theme matches preference
// Ensure data-theme matches preference exactly
if (themePreference && document.documentElement.getAttribute('data-theme') !== themePreference) {
document.documentElement.setAttribute('data-theme', themePreference);
}