Fix: correctly initiate theme so it doesn't get overwritten. And follow correct naming.

This commit is contained in:
ernstmul
2025-02-17 11:50:09 +01:00
parent 936e0256b3
commit 5f3a89638b
+9 -7
View File
@@ -60,9 +60,9 @@
showAccountMenu: boolean;
};
function updateTheme(theme: 'light' | 'dark' | 'system') {
function updateTheme(theme: 'light' | 'dark' | 'auto') {
const themeInUse =
theme === 'system'
theme === 'auto'
? window.matchMedia('(prefers-color-scheme: dark)').matches
? 'dark'
: 'light'
@@ -70,7 +70,7 @@
app.update(() => ({
themeInUse: themeInUse,
theme: theme === 'system' ? 'auto' : theme
theme: theme
}));
}
@@ -88,10 +88,12 @@
export let sideBarIsOpen: $$Props['sideBarIsOpen'] = false;
export let showAccountMenu = false;
let activeTheme = 'dark';
let activeTheme = $app.theme;
$: {
updateTheme(activeTheme);
if (activeTheme) {
updateTheme(activeTheme);
}
}
$: currentOrg = organizations.find((org) => org.isSelected);
$: selectedProject = currentOrg?.projects.find((project) => project.isSelected);
@@ -215,7 +217,7 @@
{ id: 'light', label: 'Light', icon: IconSun },
{ id: 'dark', label: 'Dark', icon: IconMoon },
{
id: 'system',
id: 'auto',
label: 'System',
icon: IconMode
}
@@ -282,7 +284,7 @@
name: 'System',
leadingIcon: IconMode,
onClick: () => {
updateTheme('system');
updateTheme('auto');
}
}
]