feat(frontend): add dark/light theme toggle with system detection
- Add ThemeToggle component (Auto / Dark / Light) to all views - Store preference per browser and detect system preference live via prefers-color-scheme - Apply theme before first render in index.html to prevent flash - Extend CSS with light theme variables and refactor glass styles
This commit is contained in:
parent
cb30223fd4
commit
f220d96e3b
11 changed files with 217 additions and 26 deletions
30
frontend/src/components/ThemeToggle.vue
Normal file
30
frontend/src/components/ThemeToggle.vue
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<script setup lang="ts">
|
||||
import { useTheme } from '../lib/theme'
|
||||
|
||||
const { mode, labels, cycle } = useTheme()
|
||||
const icons = { auto: '🌗', dark: '🌙', light: '☀️' } as const
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button
|
||||
class="btn btn-sm theme-toggle"
|
||||
type="button"
|
||||
:title="`Design: ${labels[mode]} – klicken zum Wechseln`"
|
||||
:aria-label="`Design umschalten, aktuell ${labels[mode]}`"
|
||||
@click="cycle"
|
||||
>
|
||||
<span aria-hidden="true">{{ icons[mode] }}</span>
|
||||
<span class="tlabel">{{ labels[mode] }}</span>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.tlabel {
|
||||
margin-left: 7px;
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.tlabel {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Loading…
Add table
Add a link
Reference in a new issue