-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.vue
87 lines (70 loc) · 2.39 KB
/
App.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
<template>
<NuxtPage />
<Footer />
<!-- <va-switch
v-model="colorThemeValue"
color="#5123a1"
off-color="#ffd300"
style="---checker-background-color: #252723;"
>
<template #innerLabel>
<div class="va-text-center">
<va-icon
size="24px"
:name="themeSwitchIcon"
/>
</div>
</template>
</va-switch> -->
</template>
<script setup>
import { ref, watchEffect, toRef, onMounted } from 'vue';
import { useColors } from 'vuestic-ui';
import { localStorageAvailable, setItemInLs, isItemInLs, getItemFromLs } from './services/lsManager';
import { useUiStore, useShoppingCartStore } from './services/stateStore';
// Look at LS and total up the items. Function determines the number in the shopping cart
onMounted(() => {
// Consider checking DB products price against LS and update LS if needed
// Get the total items in user's shopping cart
shoppingCartStore.calculateTotalItemCountInShoppingCart();
});
let themeSwitchIcon = computed(() => { return colorThemeValue ? 'dark_mode' : 'light_mode'})
// Pinia store
const uiStore = useUiStore()
const shoppingCartStore = useShoppingCartStore();
// Vuestic color presets, light/dark mode, theme colors
const { applyPreset } = useColors();
let theme = ref(getItemFromLs('vuestic-docs-theme'));
let colorThemeValue = ref(theme.value == 'dark');
let themeSet = false; // know when the color theme has been set
// If color theme is not yet in local storage, set it
if(localStorageAvailable && !isItemInLs('vuestic-docs-theme')) {
setItemInLs('vuestic-docs-theme', 'light');
uiStore.colorTheme = 'light';
};
watchEffect(() => {
changeColorTheme(colorThemeValue.value)
})
function changeColorTheme() {
// themeSet is initially set to false. If not the theme will change/unchange on app load
if(themeSet) {
theme.value =
theme.value == 'light' ?
theme.value = 'dark' :
theme.value = 'light';
}
themeSet = true;
// If theme color is not in LS, the initial value will be null
if(!theme.value) { theme.value = 'light' }
setItemInLs('vuestic-docs-theme', theme.value);
applyPreset(theme.value);
};
</script>
<style lang="scss">
// TODO: use a computed property for the body background-color
body {
// Relavtive body + absolute footer with bottom: 0 == footer stays at the bottom
position: relative;
min-height: 100vh;
}
</style>