feat(frontend): add light/dark theme switcher

Add persisted theme mode (light, dark, system) with a header menu.
Rework the light and dark palettes for stronger contrast and drop the
high-contrast theme.
This commit is contained in:
Rafał Tyński
2026-10-03 18:54:13 +02:00
parent 2b6a9f5433
commit 1ad16fb35b
4 changed files with 128 additions and 52 deletions
+32
View File
@@ -0,0 +1,32 @@
import { computed, watch } from 'vue'
import { usePreferredDark, useStorage } from '@vueuse/core'
import { useTheme } from 'vuetify'
export type ThemeMode = 'light' | 'dark' | 'system'
export type ResolvedTheme = 'light' | 'dark'
export interface ThemeOption {
value: ThemeMode
title: string
icon: string
}
export const themeOptions: ThemeOption[] = [
{ value: 'light', title: 'Jasny', icon: 'mdi-white-balance-sunny' },
{ value: 'dark', title: 'Ciemny', icon: 'mdi-weather-night' },
{ value: 'system', title: 'Systemowy', icon: 'mdi-theme-light-dark' },
]
export function useThemeMode() {
const theme = useTheme()
const preferredDark = usePreferredDark()
const mode = useStorage<ThemeMode>('tarninahub-theme', 'system')
const resolved = computed<ResolvedTheme>(() =>
mode.value === 'system' ? (preferredDark.value ? 'dark' : 'light') : mode.value,
)
watch(resolved, (value) => theme.change(value), { immediate: true })
return { mode, resolved, preferredDark, themeOptions }
}