- 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
30 lines
667 B
Vue
30 lines
667 B
Vue
<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>
|