-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR introduces a theme toggle that overwrites user preferences. Depends on #926 that introduces class based theme management. # UI preview https://github.com/user-attachments/assets/5a220d2b-d201-4787-98a2-db0b5c9917f7
- Loading branch information
Showing
24 changed files
with
557 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,71 @@ | ||
<script setup lang="ts"> | ||
import { onBeforeUnmount, onMounted, ref } from "vue"; | ||
import { RouterView, useRoute, useRouter } from "vue-router"; | ||
import AppToolbar from "@/components/AppToolbar.vue"; | ||
import LoadingBars from "@/components/LoadingBars.vue"; | ||
import ModalDialog from "@/components/ModalDialog.vue"; | ||
import NavigationButton from "@/components/NavigationButton.vue"; | ||
import ToastNotificationArea from "@/components/ToastNotificationArea.vue"; | ||
import { isUserInDarkMode } from "./services/utils"; | ||
import { useThemesStore } from "@/stores/themes"; | ||
import AppToolbar from "@/views/AppToolbar.vue"; | ||
const route = useRoute(); | ||
const router = useRouter(); | ||
const theme = ref(isUserInDarkMode() ? "skore-dark" : "skore-light"); | ||
function switchTheme(m: MediaQueryListEvent) { | ||
theme.value = m.matches ? "skore-dark" : "skore-light"; | ||
} | ||
const preferredColorScheme = window.matchMedia("(prefers-color-scheme: dark)"); | ||
onMounted(() => { | ||
preferredColorScheme.addEventListener("change", switchTheme); | ||
}); | ||
onBeforeUnmount(() => { | ||
preferredColorScheme.removeEventListener("change", switchTheme); | ||
}); | ||
const themesStore = useThemesStore(); | ||
</script> | ||
|
||
<template> | ||
<div class="skore" :class="[theme]"> | ||
<AppToolbar> | ||
<NavigationButton | ||
v-for="(r, i) in router.getRoutes()" | ||
:key="i" | ||
:icon="`${r.meta['icon']}`" | ||
:is-selected="r.name == route.name" | ||
:to="r.path" | ||
/> | ||
</AppToolbar> | ||
<RouterView v-slot="{ Component, route }"> | ||
<template v-if="Component"> | ||
<Transition name="fade" mode="out-in"> | ||
<Suspense timeout="0"> | ||
<template #default> | ||
<component :is="Component" :key="route.path" /> | ||
</template> | ||
<template #fallback> | ||
<div class="loader"> | ||
<LoadingBars /> | ||
</div> | ||
</template> | ||
</Suspense> | ||
</Transition> | ||
</template> | ||
</RouterView> | ||
<div class="skore" :class="themesStore.currentThemeClass"> | ||
<div class="app-shell"> | ||
<AppToolbar> | ||
<NavigationButton | ||
v-for="(r, i) in router.getRoutes()" | ||
:key="i" | ||
:icon="`${r.meta['icon']}`" | ||
:is-selected="r.name == route.name" | ||
:to="r.path" | ||
/> | ||
</AppToolbar> | ||
<RouterView v-slot="{ Component, route }"> | ||
<template v-if="Component"> | ||
<Transition name="fade" mode="out-in"> | ||
<Suspense timeout="0"> | ||
<template #default> | ||
<component :is="Component" :key="route.path" /> | ||
</template> | ||
<template #fallback> | ||
<div class="loader"> | ||
<LoadingBars /> | ||
</div> | ||
</template> | ||
</Suspense> | ||
</Transition> | ||
</template> | ||
</RouterView> | ||
</div> | ||
<ToastNotificationArea /> | ||
<ModalDialog /> | ||
</div> | ||
<ToastNotificationArea /> | ||
<ModalDialog /> | ||
</template> | ||
|
||
<style scoped> | ||
.skore { | ||
display: flex; | ||
flex-direction: row; | ||
background-color: var(--color-background-primary); | ||
& .app-shell { | ||
display: flex; | ||
flex-direction: row; | ||
background-color: var(--color-background-primary); | ||
main { | ||
width: calc(100dvw - var(--width-toolbar)); | ||
height: 100vh; | ||
} | ||
main { | ||
width: calc(100dvw - var(--width-toolbar)); | ||
height: 100vh; | ||
} | ||
.loader { | ||
display: flex; | ||
height: 100dvh; | ||
flex: 1; | ||
align-items: center; | ||
justify-content: center; | ||
.loader { | ||
display: flex; | ||
height: 100dvh; | ||
flex: 1; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.