authelia/docs/assets/js/darkmode-init.js
James Elliott b2c60ef898
feat: major documentation refresh (#3475)
This marks the launch of the new documentation website.
2022-06-15 17:51:47 +10:00

22 lines
507 B
JavaScript

const globalDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
const localMode = localStorage.getItem('theme');
if (globalDark && (localMode === null)) {
localStorage.setItem('theme', 'dark');
document.documentElement.setAttribute('data-dark-mode', '');
}
if (globalDark && (localMode === 'dark')) {
document.documentElement.setAttribute('data-dark-mode', '');
}
if (localMode === 'dark') {
document.documentElement.setAttribute('data-dark-mode', '');
}