-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
43 lines (43 loc) · 1.58 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 lang="en">
<head>
<meta charset="utf-8" />
<title>Hapax Legomenon</title>
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<link rel="stylesheet" href="/src/styles.scss" />
<script>
if (
// check if user had saved dark as their
// theme when accessing page before
localStorage.theme === 'dark' ||
// or user's requesting dark color
// scheme through operating system
(!('theme' in localStorage) &&
window.matchMedia('(prefers-color-scheme: dark)').matches)
) {
// then if we have access to the document and the element
// we add the dark class to the html element and
// store the dark value in the localStorage
if (document && document.documentElement) {
document.documentElement.classList.add('dark');
localStorage.setItem('theme', 'dark');
}
} else {
// else if we have access to the document and the element
// we remove the dark class to the html element and
// store the value light in the localStorage
if (document && document.documentElement) {
document.documentElement.classList.remove('dark');
localStorage.setItem('theme', 'light');
}
}
</script>
</head>
<body>
<!-- eslint-disable-next-line @angular-eslint/template/prefer-self-closing-tags -->
<app-root></app-root>
<script type="module" src="/src/main.ts"></script>
</body>
</html>