Skip to content

Commit d758ef5

Browse files
committed
Apply theme
1 parent ab10329 commit d758ef5

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

frontend/src/App.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<script setup>
22
import {onMounted, ref} from 'vue'
33
import {useRoute, useRouter} from 'vue-router'
4+
import {useTheme} from 'vuetify'
45
import {useSQLite} from "@/composables/useSQLite.js";
6+
import {useThemeStore} from '@/stores/theme'
57
import FileUploaderView from '@/components/FileUploaderView.vue'
68
import CoinListView from "@/components/CoinListView.vue";
79
import SettingsView from "@/components/SettingsView.vue";
@@ -25,7 +27,12 @@ const drawer = ref(false)
2527
const router = useRouter()
2628
const route = useRoute()
2729
30+
const themeStore = useThemeStore()
31+
const theme = useTheme()
32+
2833
onMounted(async () => {
34+
theme.change(themeStore.currentTheme)
35+
2936
await router.replace('/')
3037
})
3138

frontend/src/components/SettingsView.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<script setup>
22
import {onMounted, onUnmounted, ref} from "vue";
3+
import { useTheme } from 'vuetify'
34
import { useLocaleStore } from '@/stores/locale'
45
import { useThemeStore } from '@/stores/theme'
56
67
const themeStore = useThemeStore()
78
const localeStore = useLocaleStore()
9+
const appTheme = useTheme()
810
911
const langs = ref([
1012
{lang: 'bg', name: 'Български'},
@@ -37,6 +39,11 @@ onMounted(async () => {
3739
onUnmounted(async () => {
3840
emit('update:title', oldTitle);
3941
})
42+
43+
const handleThemeChange = (theme) => {
44+
themeStore.setTheme(theme)
45+
appTheme.change(theme)
46+
}
4047
</script>
4148

4249
<template>
@@ -47,9 +54,10 @@ onUnmounted(async () => {
4754
v-model="themeStore.currentTheme"
4855
rounded="xl"
4956
border
57+
@update:model-value="handleThemeChange"
5058
>
5159
<v-btn value="dark" icon="mdi-weather-night"></v-btn>
52-
<v-btn value="auto" icon="mdi-brightness-auto"></v-btn>
60+
<v-btn value="system" icon="mdi-brightness-auto"></v-btn>
5361
<v-btn value="light" icon="mdi-weather-sunny"></v-btn>
5462
</v-btn-toggle>
5563
</v-list-item>

frontend/src/main.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { createPinia } from 'pinia'
1010
import * as components from 'vuetify/components'
1111
import * as directives from 'vuetify/directives'
1212
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
13+
import colors from 'vuetify/util/colors'
14+
import { md3 } from 'vuetify/blueprints'
1315

1416
// Components
1517
import App from './App.vue'
@@ -21,6 +23,24 @@ pinia.use(piniaPluginPersistedstate)
2123
const vuetify = createVuetify({
2224
components,
2325
directives,
26+
blueprint: md3,
27+
theme: {
28+
defaultTheme: 'dark',
29+
themes: {
30+
light: {
31+
dark: false,
32+
colors: {
33+
primary: colors.orange.lighten1,
34+
}
35+
},
36+
dark: {
37+
dark: true,
38+
colors: {
39+
primary: colors.orange.darken2,
40+
}
41+
}
42+
}
43+
}
2444
})
2545

2646
const app = createApp(App)

0 commit comments

Comments
 (0)