-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
105 lines (105 loc) · 3.5 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DarkMode By Rosux</title>
<style>
:root{
--text-color: hsl(0, 0%, 83%);
--background-color: hsl(0, 0%, 9%);
}
body, html{
min-height: 100vh;
padding: 0;
margin: 0;
color: var(--text-color);
background-color: var(--background-color);
font-family: "Roboto";
font-weight: 300;
display: flex;
flex-direction: column;
transition: background-color .4s linear;
}
p, a, h1, h2, h3, h4, h5, h6, ul{
padding: 0;
margin: 0;
text-decoration: none;
color: inherit;
}
*{
box-sizing: border-box;
}
.center{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
/* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- button -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
.button-switch{
width: fit-content;
height: fit-content;
user-select: none;
margin-top: 1rem;
}
.button-switch > input{
display: none;
}
.button-switch > label{
cursor: pointer;
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
grid-template-rows: 1fr;
border: solid 1px var(--text-color);
border-radius: 10em;
position: relative;
}
.button-switch > label::after{
display: block;
position: absolute;
content: "";
width: 50%;
height: 100%;
border-radius: 10em;
box-shadow: 0 0 0 1px var(--text-color);
transition: all .4s cubic-bezier(.86,0,.07,1);
background-color: #00000020;
}
.button-switch > label > p{
font-size: inherit;
color: inherit;
padding: .5em 1em;
text-align: center;
}
.button-switch > input:checked + label::after{
margin-left: 50%;
}
</style>
<script src="DarkMode.js"></script> <!-- as you might be able to see there is no defer needed -->
</head>
<body>
<script>
const dmt = "--text-color: hsl(0, 0%, 83%);--background-color: hsl(0, 0%, 9%);";
const lmt = "--text-color: hsl(0, 0%, 13%);--background-color: hsl(0, 0%, 89%);";
const darkmode = new DarkMode(dmt, lmt);
</script>
<div class="center">
<button darkmode-button="switch">switch</button>
<button darkmode-button="on">dark</button>
<button darkmode-button="off">light</button>
<button darkmode-button="default">default to prefered color scheme</button>
<input type="checkbox" darkmode-selector="true">
<input type="checkbox" darkmode-selector="false">
<div class="button-switch uwu">
<input type="checkbox" id="darkmode" darkmode-selector="false">
<label for="darkmode"><p>Dark</p><p>Bright</p></label>
</div>
<div class="button-switch uwu">
<input type="checkbox" id="darkmode" darkmode-selector="true">
<label for="darkmode"><p>Bright</p><p>Dark</p></label>
</div>
</div>
</body>
</html>