Skip to content
Permalink
master
Switch branches/tags
Go to file
2 contributors

Users who have contributed to this file

@TiphaineLAURENT @codediodeio
const themeMap = {
dark: "light",
light: "solar",
solar: "dark"
};
const theme = localStorage.getItem('theme')
|| (tmp = Object.keys(themeMap)[0],
localStorage.setItem('theme', tmp),
tmp);
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;