Repository navigation
Expand file tree
/
Copy pathguidelines.html
More file actions
50 lines (50 loc) · 1.87 KB
/
Copy pathguidelines.html
File metadata and controls
50 lines (50 loc) · 1.87 KB
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
44
45
46
47
48
49
50
<!doctype html>
<html lang="en" data-theme="light">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, viewport-fit=cover"
/>
<title>solid-kit — UX guidelines</title>
<!--
The stored theme choice, applied before first paint (see
src/ui/theme.ts). It cannot wait for the module script: a dark choice
would flash light on every load. Light needs nothing: it is stamped on
<html> above. "system" is resolved here, contrast first, and followed
while the page is open. Keep the key, the choices and the resolution in
step with theme.ts: its test runs this script to check.
-->
<script>
(function () {
var root = document.documentElement;
function stored() {
try { return localStorage.getItem("solid-kit:theme"); } catch (e) { return null; }
}
function device() {
if (!window.matchMedia) return "light";
if (matchMedia("(prefers-contrast: more)").matches) return "contrast";
if (matchMedia("(prefers-color-scheme: dark)").matches) return "dark";
return "light";
}
function apply() {
var c = stored();
if (c === "dark") root.dataset.theme = "dark";
else if (c === "system") root.dataset.theme = device();
}
apply();
if (!window.matchMedia) return;
["(prefers-contrast: more)", "(prefers-color-scheme: dark)"].forEach(function (q) {
var m = matchMedia(q);
if (m.addEventListener)
m.addEventListener("change", function () { if (stored() === "system") apply(); });
});
})();
</script>
</head>
<body>
<div id="guidelines"></div>
<script type="module" src="/src/guidelines.ts"></script>
</body>
</html>