mirror of
https://github.com/Extroonie/extroonie.com.git
synced 2026-10-13 01:48:06 -07:00
11 lines
418 B
JavaScript
11 lines
418 B
JavaScript
|
|
(() => {
|
||
|
|
let choice = 'system';
|
||
|
|
try {
|
||
|
|
choice = localStorage.getItem('theme') || 'system';
|
||
|
|
} catch {}
|
||
|
|
if (!['light', 'dark', 'system'].includes(choice)) choice = 'system';
|
||
|
|
const dark = choice === 'dark' || (choice === 'system' && matchMedia('(prefers-color-scheme: dark)').matches);
|
||
|
|
document.documentElement.dataset.theme = dark ? 'dark' : 'light';
|
||
|
|
document.documentElement.dataset.themeChoice = choice;
|
||
|
|
})();
|