Theme switcher and BULMA

This commit is contained in:
2026-09-11 13:30:02 +02:00
parent fb152bd023
commit fcd4d4743b
13 changed files with 123 additions and 54 deletions
+21
View File
@@ -0,0 +1,21 @@
import { ref } from 'vue';
const theme = ref(localStorage.getItem('theme') || 'auto');
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)');
export function applyTheme() {
const resolved = theme.value === 'auto' ? (prefersDark.matches ? 'dark' : 'light') : theme.value;
document.documentElement.setAttribute('data-theme', resolved);
}
export function setTheme(value) {
theme.value = value;
localStorage.setItem('theme', value);
applyTheme();
}
prefersDark.addEventListener('change', () => {
if (theme.value === 'auto') applyTheme();
});