-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
87 lines (80 loc) · 1.69 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html
lang="en"
data-mode="dark"
>
<head>
<meta charset="UTF-8" />
<link
rel="icon"
type="image/svg+xml"
href="/vite.svg"
/>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0"
/>
<title>Vite + React + TS</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: #f0f0f0;
}
[data-mode="dark"] body {
background-color: hsl(240, 3.7%, 5.88%);
color: #fff;
}
.container {
width: 100%;
height: 100vh;
margin: 0 auto;
display: flex;
justify-content: center;
align-items: start;
padding-top: 100px;
}
.card {
max-width: 400px;
width: 100%;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
}
[data-mode="dark"] .card {
background-color: hsl(240, 3.7%, 9.88%);
color: #fff;
}
</style>
</head>
<body>
<button
onclick="toggleTheme()"
class="fixed top-0 right-0 m-5 p-2 bg-blue-500 text-white rounded-md"
>
Toggle Theme
</button>
<div class="container">
<div class="card">
<div id="root"></div>
</div>
</div>
<script
type="module"
src="/src/demo.tsx"
></script>
<script>
const toggleTheme = () => {
document.documentElement.setAttribute(
"data-mode",
document.documentElement.getAttribute("data-mode") === "dark"
? "light"
: "dark"
);
};
</script>
</body>
</html>