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