-
Notifications
You must be signed in to change notification settings - Fork 38
/
index.html
43 lines (38 loc) · 1.14 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>ClubHouse | Developed by @callmearta</title>
<link rel="stylesheet" href="index.css" />
</head>
<body>
<div id="app">
<router-view></router-view>
</div>
<script src="app/a.js"></script>
<script src="app/main.js" type="module"></script>
<script type="text/javascript">
const THEME_AUTO = "auto";
const THEME_LIGHT = "light";
const THEME_DARK = "dark";
const setTheme = (theme) => {
window.theme = theme;
const systemTheme = matchMedia(`(prefers-color-scheme: ${THEME_LIGHT})`).matches ? THEME_LIGHT : THEME_DARK;
document.body.setAttribute("data-theme", theme === THEME_AUTO ? systemTheme : theme);
};
matchMedia(`(prefers-color-scheme: ${THEME_DARK})`)
.addListener((e) => {
let storedTheme = localStorage.getItem("theme");
if (storedTheme === THEME_AUTO) {
setTheme(e.matches ? THEME_DARK : THEME_LIGHT);
}
});
let storedTheme = localStorage.getItem("theme");
if (!storedTheme) {
storedTheme = THEME_AUTO;
localStorage.setItem("theme", THEME_AUTO);
}
setTheme(storedTheme);
</script>
</body>
</html>