forked from frandiox/vitesse-ssr-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFooter.vue
92 lines (76 loc) · 2.13 KB
/
Footer.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
81
82
83
84
85
86
87
88
89
90
91
92
<script setup lang="ts">
import { watch, computed } from 'vue'
import { useI18n } from 'vue-i18n'
import { useRoute } from 'vue-router'
import { useStorage, usePreferredDark, useToggle } from '@vueuse/core'
import { DEFAULT_LOCALE, SUPPORTED_LOCALES as locales } from '~/i18n'
const colorSchema = useStorage('color-schema', 'auto')
const preferredDark = usePreferredDark()
const isDark = computed({
get() {
return colorSchema.value === 'auto'
? preferredDark.value
: colorSchema.value === 'dark'
},
set(v: boolean) {
if (v === preferredDark.value) colorSchema.value = 'auto'
else colorSchema.value = v ? 'dark' : 'light'
},
})
const toggleDark = useToggle(isDark)
watch(
isDark,
(v) =>
typeof document !== 'undefined' &&
document.documentElement.classList.toggle('dark', v),
{ immediate: true }
)
const { t, locale } = useI18n()
const route = useRoute()
const toggleLocales = () => {
// change to some real logic
const nextLocale =
locales[(locales.indexOf(locale.value) + 1) % locales.length]
const base = nextLocale === DEFAULT_LOCALE ? '' : `/${nextLocale}`
window.location.pathname = base + route.fullPath
}
</script>
<template>
<nav class="text-xl mt-6 space-x-2">
<router-link class="icon-btn" to="/" :title="t('button.home')">
<carbon-campsite />
</router-link>
<a
class="icon-btn"
rel="noreferrer"
href="https://github.com/frandiox/vite-ssr"
target="_blank"
title="Library"
>
<carbon-star />
</a>
<a class="icon-btn" :title="t('button.toggle_dark')" @click="toggleDark">
<carbon-moon v-if="isDark" />
<carbon-sun v-else />
</a>
<a
class="icon-btn"
:title="t('button.toggle_langs')"
@click="toggleLocales"
>
<carbon-language />
</a>
<router-link class="icon-btn" to="/about" :title="t('button.about')">
<carbon-dicom-overlay />
</router-link>
<a
class="icon-btn"
rel="noreferrer"
href="https://github.com/frandiox/vitesse-ssr-template"
target="_blank"
title="Template"
>
<carbon-logo-github />
</a>
</nav>
</template>