mirror of
https://github.com/animate-css/animate.css.git
synced 2024-11-11 05:46:32 +01:00
20 lines
539 B
JavaScript
20 lines
539 B
JavaScript
|
const darkModeControl = () => {
|
||
|
const darkCheck = document.getElementById('night-light-checkbox');
|
||
|
|
||
|
darkCheck.addEventListener('click', () => {
|
||
|
if (darkCheck.checked) {
|
||
|
document.body.classList.add('dark');
|
||
|
localStorage.setItem('animate-css', 'dark');
|
||
|
} else {
|
||
|
document.body.classList.remove('dark');
|
||
|
localStorage.removeItem('animate-css');
|
||
|
}
|
||
|
})
|
||
|
|
||
|
if (localStorage.getItem('animate-css')) {
|
||
|
document.body.className = 'dark';
|
||
|
darkCheck.checked = true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default darkModeControl;
|