2020-12-28 19:56:11 +00:00
|
|
|
export function toggleTheme() {
|
|
|
|
document.documentElement.classList.toggle('dark-theme');
|
|
|
|
document.documentElement.classList.toggle('light-theme');
|
|
|
|
localStorage.setItem('theme', document.documentElement.classList.contains('dark-theme') ? "dark" : "light");
|
|
|
|
}
|
|
|
|
|
|
|
|
export function loadTheme() {
|
2021-01-03 21:13:37 +00:00
|
|
|
const theme = localStorage.getItem("theme");
|
|
|
|
if (theme == "dark") {
|
2020-12-28 19:56:11 +00:00
|
|
|
document.documentElement.classList.add('dark-theme');
|
|
|
|
document.documentElement.classList.remove('light-theme');
|
2021-01-03 21:13:37 +00:00
|
|
|
} else if (theme == "light") {
|
|
|
|
document.documentElement.classList.add('light-theme');
|
|
|
|
document.documentElement.classList.remove('dark-theme');
|
2020-12-28 19:56:11 +00:00
|
|
|
}
|
|
|
|
}
|