refactor: split into component and use global app store

This commit is contained in:
Pihkaal
2024-10-16 02:01:39 +02:00
parent 2cd8512149
commit 80a63a320c
14 changed files with 474 additions and 386 deletions

View File

@@ -0,0 +1,28 @@
<script setup lang="ts">
const colorMode = useColorMode();
const isDark = computed({
get() {
return colorMode.value === "dark";
},
set() {
colorMode.preference = colorMode.value === "dark" ? "light" : "dark";
},
});
</script>
<template>
<ClientOnly>
<UButton
:icon="isDark ? 'i-heroicons-moon-20-solid' : 'i-heroicons-sun-20-solid'"
color="gray"
variant="ghost"
aria-label="Theme"
class="w-8 h-8"
@click="isDark = !isDark"
/>
<template #fallback>
<div class="w-8 h-8" />
</template>
</ClientOnly>
</template>