nfp_sites/app/darkmode.js

26 lines
524 B
JavaScript
Raw Normal View History

const storageName = 'darkmode'
const Darkmode = {
darkIsOn: false,
setDarkMode: function(setOn) {
if (setOn) {
localStorage.setItem(storageName, true)
document.body.className = 'darkmodeon'
Darkmode.darkIsOn = true
} else {
localStorage.removeItem(storageName)
2019-10-01 03:45:44 +00:00
document.body.className = 'daymode'
Darkmode.darkIsOn = false
}
},
isOn: function() {
return Darkmode.darkIsOn
},
}
Darkmode.darkIsOn = localStorage.getItem(storageName)
module.exports = Darkmode