Skip to content

Commit c363398

Browse files
committed
set settings
1 parent 86e5c6c commit c363398

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

app/composables/useSettings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { BACKGROUND_THEMES } from '#shared/utils/constants'
55
import type { AccentColorId, BackgroundThemeId, AppSettings } from '#shared/schemas/app-settings'
66

77
const DEFAULT_SETTINGS: AppSettings = {
8+
theme: 'system',
89
relativeDates: false,
910
includeTypesInInstall: true,
1011
accentColorId: null,
@@ -116,7 +117,6 @@ export function useBackgroundTheme() {
116117
document.documentElement.removeAttribute('data-bg-theme')
117118
}
118119
settings.value.preferredBackgroundTheme = id
119-
syncSettings(settings.value)
120120
}
121121

122122
return {

app/pages/settings.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup lang="ts">
22
const router = useRouter()
3+
34
const { settings } = useSettings()
45
const { locale, locales, setLocale: setNuxti18nLocale } = useI18n()
56
const colorMode = useColorMode()
@@ -33,6 +34,8 @@ defineOgImageComponent('Default', {
3334
primaryColor: '#60a5fa',
3435
})
3536
37+
watch(settings.value, syncSettings)
38+
3639
const setLocale: typeof setNuxti18nLocale = locale => {
3740
settings.value.selectedLocale = locale
3841
return setNuxti18nLocale(locale)
@@ -78,14 +81,14 @@ const setLocale: typeof setNuxti18nLocale = locale => {
7881
</label>
7982
<select
8083
id="theme-select"
81-
:value="colorMode.preference"
8284
class="w-full sm:w-auto min-w-48 bg-bg border border-border rounded-md px-3 py-2 text-sm text-fg cursor-pointer duration-200 transition-colors hover:border-fg-subtle"
8385
@change="
8486
colorMode.preference = ($event.target as HTMLSelectElement).value as
8587
| 'light'
8688
| 'dark'
8789
| 'system'
8890
"
91+
v-model="settings.theme"
8992
>
9093
<option value="system">
9194
{{ $t('settings.theme_system') }}

shared/schemas/app-settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const backgroundThemeIds = Object.keys(BACKGROUND_THEMES) as [
1111
]
1212

1313
export const AppSettingsSchema = v.object({
14+
theme: v.picklist(['light', 'dark', 'system']),
1415
relativeDates: v.boolean(),
1516
includeTypesInInstall: v.boolean(),
1617
accentColorId: v.nullable(v.picklist(accentColorIds)),

0 commit comments

Comments
 (0)