We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e58fa36 commit 648257aCopy full SHA for 648257a
1 file changed
assets/js/dark.js
@@ -0,0 +1,18 @@
1
+/*******************************************************************************
2
+ * Theme interaction
3
+ */
4
+
5
+var prefersDark = window.matchMedia("(prefers-color-scheme: dark)");
6
7
+/**
8
+ * set the the body theme to the one specified by the user browser
9
+ *
10
+ * @param {event} e
11
12
+function autoTheme(e) {
13
+ targetTheme = prefersDark.matches ? "dark" : "light";
14
+ document.documentElement.setAttribute("data-theme", targetTheme);
15
+}
16
17
+autoTheme();
18
+prefersDark.onchange = autoTheme;
0 commit comments