-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.vue
136 lines (119 loc) · 3.32 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<script setup lang="ts">
import { useSettingsDataStore } from '~/stores/settingsData';
const settingsDataStore = useSettingsDataStore();
const fontFamily = computed(() => settingsDataStore.settingsData?.font);
const primaryBgColor = computed(
() => settingsDataStore.settingsData?.primary_background_color,
);
const primaryBgTextColor = computed(
() => settingsDataStore.settingsData?.primary_background_text_color,
);
const secondaryBgColor = computed(
() => settingsDataStore.settingsData?.secondary_background_color,
);
const secondaryBgTextColor = computed(
() => settingsDataStore.settingsData?.secondary_background_text_color,
);
const positiveFontColor = computed(
() => settingsDataStore.settingsData?.text_positive_color,
);
// Function to convert hex to RGB
function hexToRgb(hex: string) {
try {
let bigint = parseInt(hex.slice(1), 16);
let r = (bigint >> 16) & 255;
let g = (bigint >> 8) & 255;
let b = bigint & 255;
return `${r}, ${g}, ${b}`;
} catch (error) {
return '255, 255, 255';
}
}
const textPositiveColor = ref(positiveFontColor);
let primaryColor = '#297F78';
let primaryColorRgb = hexToRgb(primaryColor);
let primaryTextColor = '#fff';
let secondaryColor = '#FBD800';
let secondaryTextColor = '#000';
onBeforeMount(() => {
if (settingsDataStore.settingsData === null) {
settingsDataStore.getSettingsData();
}
if (fontFamily.value) {
const fontValue = fontFamily.value;
if (fontValue === 'Roboto') {
document.documentElement.style.setProperty(
'--body-font-family',
"'Roboto Slab', sans-serif",
);
document.documentElement.style.setProperty(
'--heading-font-family',
"'Roboto', sans-serif",
);
document.documentElement.style.setProperty('--body-font-weight', '300');
} else {
document.documentElement.style.setProperty(
'--body-font-family',
"'" + fontValue + "', sans-serif",
);
document.documentElement.style.setProperty(
'--heading-font-family',
"'" + fontValue + "', sans-serif",
);
}
}
if (primaryBgColor.value) {
primaryColor = primaryBgColor.value;
primaryColorRgb = hexToRgb(primaryColor);
}
if (primaryBgTextColor.value) {
primaryTextColor = primaryBgTextColor.value;
}
if (secondaryBgColor.value) {
secondaryColor = secondaryBgColor.value;
}
if (secondaryBgTextColor.value) {
secondaryTextColor = secondaryBgTextColor.value;
}
document.documentElement.style.setProperty('--color-primary', primaryColor);
document.documentElement.style.setProperty(
'--color-primary-rgb',
primaryColorRgb,
);
document.documentElement.style.setProperty(
'--color-primary-text',
primaryTextColor,
);
document.documentElement.style.setProperty(
'--color-secondary',
secondaryColor,
);
document.documentElement.style.setProperty(
'--color-secondary-text',
secondaryTextColor,
);
if (textPositiveColor.value) {
document.documentElement.style.setProperty(
'--color-text',
textPositiveColor.value,
);
}
});
</script>
<template>
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</template>
<style>
/* Page transition when routing */
.page-enter-active,
.page-leave-active {
transition: all 0.3s;
}
.page-enter-from,
.page-leave-to {
opacity: 0;
filter: blur(1rem);
}
</style>