mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-12 10:12:17 +01:00
add light mode
This commit is contained in:
25
resources/js/utils/theme.ts
Normal file
25
resources/js/utils/theme.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { usePreferredColorScheme, useStorage } from "@vueuse/core";
|
||||
import { computed, watch } from "vue";
|
||||
|
||||
type themeOption = "system" | "light" | "dark";
|
||||
const themeSetting = useStorage<themeOption>("theme", "system");
|
||||
// reload page when themeSettingChanges
|
||||
watch(
|
||||
themeSetting,
|
||||
() => {
|
||||
location.reload();
|
||||
}
|
||||
)
|
||||
const preferredColor = usePreferredColorScheme();
|
||||
const theme = computed(() => {
|
||||
if(themeSetting.value === "system"){
|
||||
console.log(preferredColor.value);
|
||||
if (preferredColor.value === 'no-preference') {
|
||||
return 'dark';
|
||||
}
|
||||
return preferredColor.value;
|
||||
}
|
||||
return themeSetting.value
|
||||
});
|
||||
|
||||
export { type themeOption, themeSetting, theme };
|
||||
Reference in New Issue
Block a user