Skip to content
Permalink
fcdfc4b531
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
18 lines (14 sloc) 445 Bytes
const themeMap = {
dark: "light",
light: "dark",
};
const theme = localStorage.getItem('theme') || Object.keys(themeMap)[0];
const bodyClass = document.body.classList;
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;