Skip to content

Commit ab10329

Browse files
committed
Store theme settings
1 parent 56cb4fa commit ab10329

2 files changed

Lines changed: 25 additions & 8 deletions

File tree

frontend/src/components/SettingsView.vue

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<script setup>
22
import {onMounted, onUnmounted, ref} from "vue";
33
import { useLocaleStore } from '@/stores/locale'
4+
import { useThemeStore } from '@/stores/theme'
45
6+
const themeStore = useThemeStore()
57
const localeStore = useLocaleStore()
68
79
const langs = ref([
@@ -35,23 +37,20 @@ onMounted(async () => {
3537
onUnmounted(async () => {
3638
emit('update:title', oldTitle);
3739
})
38-
39-
const changeLanguage = (lang) => {
40-
localeStore.setLocale(lang)
41-
}
4240
</script>
4341

4442
<template>
4543
<v-container>
4644
<v-list>
4745
<v-list-item>
4846
<v-btn-toggle
47+
v-model="themeStore.currentTheme"
4948
rounded="xl"
5049
border
5150
>
52-
<v-btn icon="mdi-weather-night"></v-btn>
53-
<v-btn icon="mdi-brightness-auto"></v-btn>
54-
<v-btn icon="mdi-weather-sunny"></v-btn>
51+
<v-btn value="dark" icon="mdi-weather-night"></v-btn>
52+
<v-btn value="auto" icon="mdi-brightness-auto"></v-btn>
53+
<v-btn value="light" icon="mdi-weather-sunny"></v-btn>
5554
</v-btn-toggle>
5655
</v-list-item>
5756
<v-list-item>
@@ -60,7 +59,6 @@ const changeLanguage = (lang) => {
6059
:items="langs"
6160
item-title="name"
6261
item-value="lang"
63-
@update:modelValue="changeLanguage"
6462
></v-select>
6563
</v-list-item>
6664
</v-list>

frontend/src/stores/theme.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { defineStore } from 'pinia'
2+
import { ref } from 'vue'
3+
4+
export const useThemeStore = defineStore('theme', () => {
5+
const currentTheme = ref('light')
6+
7+
const setTheme = (theme) => {
8+
currentTheme.value = theme
9+
10+
localStorage.setItem('app-theme', theme)
11+
}
12+
13+
return {
14+
currentTheme,
15+
setTheme,
16+
}
17+
}, {
18+
persist: true,
19+
})

0 commit comments

Comments
 (0)