mirror of
https://github.com/frappe/lms.git
synced 2026-04-23 08:47:59 +03:00
16 lines
470 B
TypeScript
16 lines
470 B
TypeScript
import { ref } from 'vue'
|
|
|
|
const theme = ref<'light' | 'dark'>(localStorage.getItem('theme') as 'light' | 'dark' || 'light')
|
|
|
|
const toggleTheme = () => {
|
|
const newTheme: 'light' | 'dark' = theme.value === 'dark' ? 'light' : 'dark'
|
|
applyTheme(newTheme)
|
|
}
|
|
|
|
const applyTheme = (value: 'light' | 'dark') => {
|
|
document.documentElement.setAttribute('data-theme', value)
|
|
localStorage.setItem('theme', value)
|
|
theme.value = value
|
|
}
|
|
|
|
export { applyTheme, toggleTheme, theme } |