mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender-pwa.git
synced 2025-07-19 19:18:50 +02:00
feat:#20 refactored theme switch
This commit is contained in:
@ -54,7 +54,6 @@ const updateMobile = () => {
|
||||
};
|
||||
|
||||
updateMobile();
|
||||
|
||||
window.addEventListener("resize", updateMobile);
|
||||
|
||||
const settings = settingsStore();
|
||||
@ -62,13 +61,13 @@ const emit = defineEmits(["dark-mode-toggled"]);
|
||||
|
||||
onMounted(() => {
|
||||
// set theme matching browser preference
|
||||
setTheme(settings, primeVue, emit, (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches));
|
||||
|
||||
settings.setDarkMode(window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches)
|
||||
setTheme(settings, primeVue, emit);
|
||||
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", (e) => {
|
||||
setTheme(settings, primeVue, emit, e.matches);
|
||||
settings.setDarkMode(e.matches)
|
||||
setTheme(settings, primeVue, emit);
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
Reference in New Issue
Block a user