Skip to content
Permalink
a5f653b470
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
19 lines (15 sloc) 509 Bytes
const themeMap = {
dark: 'light',
light: 'solar',
solar: 'dark'
};
const theme = localStorage.getItem('theme');
const bodyClass = document.body.classList;
theme && bodyClass.add(theme) || (bodyClass.add("dark"), localStorage.setItem('theme', "dark"));
function toggleTheme() {
const current = localStorage.getItem('theme');
const next = themeMap[current];
bodyClass.replace(current, next);
localStorage.setItem('theme', next);
}
document.getElementById('themeButton').onclick = toggleTheme;