Skip to content
Permalink
5c0c0342e5
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
21 lines (15 sloc) 458 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;