-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppHeader.vue
80 lines (73 loc) · 1.71 KB
/
AppHeader.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<script setup lang="ts">
defineEmits(['toggleSidebar']);
const { availableLocales } = useI18n();
const preferedDark = usePreferredDark();
const isDark = useStorage('isDark', preferedDark.value);
const body = ref<HTMLBodyElement | null>(null);
const toggleDarkMode = () => {
if (body.value) {
if (isDark.value) {
body.value.classList.remove('dark');
} else {
body.value.classList.add('dark');
}
}
isDark.value = !isDark.value;
};
onMounted(async () => {
await nextTick();
body.value = document.querySelector('body') as HTMLBodyElement;
if (body.value) {
if (isDark.value) body.value.classList.add('dark');
}
});
</script>
<template>
<header>
<nav
class="
w-full
bg-white
text-gray-800
dark:bg-gray-800 dark:text-white
py-4
px-8
shadow-md
dark:shadow-md
flex
items-center
border-b border-gray-400/50
"
>
<router-link :to="{ name: 'home' }">
<div class="font-bold lg:text-xl md:text-lg text-md">MacDee dApp</div>
</router-link>
<div class="ml-auto flex items-center h-full">
<select
id="language"
v-model="$i18n.locale"
class="py-1 focus:outline-none rounded dark:text-gray-800"
>
<option
v-for="locale in availableLocales"
:key="locale"
:value="locale"
>
{{ locale }}
</option>
</select>
<button
class="mx-5 cursor-pointer focus:outline-none"
@click="toggleDarkMode"
>
<icon:bx:bx-moon class="w-6 h-6" v-if="!isDark" />
<icon:bx:bxs-moon class="w-6 h-6" v-else />
</button>
<a href="https://github.com/zynth17/vitailse">
<icon-akar-icons:github-fill />
</a>
</div>
</nav>
</header>
</template>
<style scoped></style>