animate.css/docs/modules/darkMode.mjs
Mehmet Sağır 3d9aef2ba6
Dark Mode (#1217)
* corrections were made

* added dark-mode

* back-to-top-button added

* back-to-top button edited

* back-to-top button edited

* last edit

* last edit

* arrangements were made

* dark-mode-button-updated

* dark-mode-option-added
2021-07-06 11:12:49 +01:00

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;