feat: daisyui theme toggle

This commit is contained in:
Alisa | Side.one 2023-05-04 23:38:36 +08:00
parent b6a4b9e362
commit dbddd6beb6
2 changed files with 3 additions and 1 deletions

View File

@ -29,10 +29,12 @@ const changeMode = (val: 'dark' | 'light' | 'system') => {
if (value === 'dark') { if (value === 'dark') {
document.documentElement.classList.add('dark'); document.documentElement.classList.add('dark');
document.documentElement.classList.remove('light'); document.documentElement.classList.remove('light');
} else { } else {
document.documentElement.classList.add('light'); document.documentElement.classList.add('light');
document.documentElement.classList.remove('dark'); document.documentElement.classList.remove('dark');
} }
document.documentElement.setAttribute("data-theme", value);
}; };
// Update icon if theme is changed from other sources // Update icon if theme is changed from other sources
watch(theme, (val: 'dark' | 'light' | 'system') => { watch(theme, (val: 'dark' | 'light' | 'system') => {

View File

@ -20,6 +20,6 @@ const themes: ThemeSwitcherTheme[] = [
<template> <template>
<div> <div>
<NewThemeSwitcher :themes="themes"/> <NewThemeSwitcher :themes="themes"/>
<ThemeSwitcher :themes="themes" /> <!-- <ThemeSwitcher :themes="themes" /> -->
</div> </div>
</template> </template>