-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
23 lines (19 loc) · 740 Bytes
/
script.js
File metadata and controls
23 lines (19 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
* Nord Theme Originally by Arctic Ice Studio
* https://nordtheme.com
*
* Ported for PrismJS by Zane Hitchcoxc (@zwhitchcox) and Gabriel Ramos (@gabrieluizramos)
* Ported for Stoplight Elements by Yurii Kadirov (@sirkadirov)
*
* Script by Yurii Kadirov (@sirkadirov), licensed under MIT.
*/
const mql = window.matchMedia('(prefers-color-scheme: dark)');
function applyDarkModeSwitching(e) {
const isDark = e.matches;
if (isDark) document.documentElement.setAttribute('data-theme', 'dark');
else document.documentElement.removeAttribute('data-theme');
}
// Initial switching of the color scheme
applyDarkModeSwitching(mql);
// Live updates when OS theme changes
mql.addEventListener('change', applyDarkModeSwitching);