-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
250 lines (222 loc) · 8.82 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<!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">
<link rel="stylesheet" href="./public/css/tailwind.css">
<title>Smart house</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;500&display=swap');
body {
margin: 0;
font-family: 'Poppins', sans-serif;
}
.glassmorphism {
background: rgba( 255, 255, 255, 0.25 );
box-shadow: 0 8px 32px 0 rgba( 31, 38, 135, 0.37 );
backdrop-filter: blur( 4px );
-webkit-backdrop-filter: blur( 4px );
border-radius: 10px;
border: 1px solid rgba( 255, 255, 255, 0.18 );
}
.controls {
min-height: 300px;
}
.controls img {
margin: 0.5rem;
}
#lights-toggle-button:checked + label,
#cleaning-toggle-button:checked + label,
#music-toggle-button:checked + label,
#motion-sensor-toggle-button:checked + label {
background-color: MediumSpringGreen;
}
label .toggle-dot {
transition: transform 0.3s ease;
}
#lights-toggle-button:checked + label .toggle-dot,
#cleaning-toggle-button:checked + label .toggle-dot,
#music-toggle-button:checked + label .toggle-dot,
#motion-sensor-toggle-button:checked + label .toggle-dot {
transform: translateX(1.3rem);
}
.light {
width: 0.4rem;
height: 0.4rem;
background: rgb(253 230 138);
-webkit-box-shadow: 10px 10px 50px 30px rgb(253 230 138);
-moz-box-shadow: 10px 10px 50px 30px rgb(253 230 138);
box-shadow: 10px 10px 50px 30px rgb(253 230 138);
}
.light-1 {
top: 11%;
left: 24%;
}
.light-2 {
top: 11%;
left: 46%;
}
.light-3 {
top: 16%;
left: 59%;
}
.vacuum-start {
bottom: 22%;
right: 12%;
width: 5%;
}
.vacuum {
animation: vacuum 5s ease infinite;
}
@keyframes vacuum {
0% {
transform: translate(0%) rotate(-360deg);
}
25% {
transform: translateY(-350%);
}
50% {
transform: translateY(-350%) translateX(-500%) rotate(360deg);
}
75% {
transform: translateY(-350%);
}
100% {
transform: translate(0%) rotate(360deg);
}
}
.sensor {
bottom: 49%;
left: 89%;
width: 0.4rem;
height: 0.4rem;
background: red;
-webkit-box-shadow: 10px 10px 50px 30px red;
-moz-box-shadow: 10px 10px 50px 30px red;
box-shadow: 10px 10px 50px 30px red;
}
@media (max-width: 1024px) {
.controls {
width: 100%;
min-height: 100px;
}
}
@media (max-width: 767px) {
.controls {
max-width: 300px;
min-height: 200px;
}
}
</style>
</head>
<body>
<div class="grid place-items-center bg-plant bg-center bg-cover box-border min-h-screen w-full p-8 lg:p-0">
<div class="glassmorphism flex flex-col p-8 lg:p-16 box-border max-w-screen-lg w-full lg:w-8/12">
<p class="text-base lg:text-xl mt-0 mb-2 text-center">You are controlling</p>
<h1 class="text-2xl lg:text-4xl m-0 text-center font-bold">Main Lounge & Dining Room</h1>
<div class="flex flex-col lg:flex-row lg:gap-5 justify-center items-center w-full mt-8 lg:mt-16 mb-0 lg:my-16">
<div class="relative grid place-items-center w-full lg:w-4/6">
<img class="w-full " src="https://i.ibb.co/09fmVRK/plan.png" alt="plan">
<div id="light-1" class="light-1 absolute rounded-full"></div>
<div id="light-2" class="light-2 absolute rounded-full"></div>
<div id="light-3" class="light-3 absolute rounded-full"></div>
<img id="vacuum" class="vacuum-start absolute" src="https://img.icons8.com/external-vitaliy-gorbachev-flat-vitaly-gorbachev/58/000000/external-robot-vacuum-cleaner-internet-technology-vitaliy-gorbachev-flat-vitaly-gorbachev.png"/>
<audio id="audio" src="./public/bensound-happyrock.mp3"></audio>
<div id="sensor" class="absolute rounded-full"></div>
</div>
<div class="controls grid place-items-center w-full lg:w-2/6 mt-8 lg:mt-0">
<div class="controls grid gap-5 grid-cols-2 md:grid-cols-4 lg:grid-cols-2 grid-rows-2 md:grid-rows-1 lg:grid-rows-2 max-w-full w-full">
<div class="glassmorphism relative grid place-items-center py-3 box-border w-full h-full cursor-pointer">
<p class="m-0 text-sm">Lights</p>
<img class="w-8 m-2" src="https://img.icons8.com/pastel-glyph/64/000000/light--v1.png"/>
<input id="lights-toggle-button" type="checkbox" class="absolute w-full h-full opacity-0">
<label for="lights-toggle-button" class="flex items-center bg-gray-400 h-6 w-12 rounded-full">
<div class="toggle-dot bg-white m-1 h-5 w-5 rounded-full"></div>
</label>
</div>
<div class="glassmorphism relative grid place-items-center py-3 box-border w-full h-full cursor-pointer">
<p class="m-0 text-sm">Cleaning</p>
<img class="w-8 m-2" src="https://img.icons8.com/external-vitaliy-gorbachev-lineal-vitaly-gorbachev/60/000000/external-robot-vacuum-cleaner-internet-of-things-vitaliy-gorbachev-lineal-vitaly-gorbachev.png"/>
<input id="cleaning-toggle-button" type="checkbox" class="absolute w-full h-full opacity-0">
<label for="cleaning-toggle-button" class="flex items-center bg-gray-400 h-6 w-12 rounded-full">
<div class="toggle-dot bg-white m-1 h-5 w-5 rounded-full"></div>
</label>
</div>
<div class="glassmorphism relative grid place-items-center py-3 box-border w-full h-full cursor-pointer">
<p class="m-0 text-sm">Music</p>
<img class="w-8 m-2" src="https://img.icons8.com/ios/96/000000/portable-speaker2.png"/>
<input id="music-toggle-button" type="checkbox" class="absolute w-full h-full opacity-0">
<label for="music-toggle-button" class="flex items-center bg-gray-400 h-6 w-12 rounded-full">
<div class="toggle-dot bg-white m-1 h-5 w-5 rounded-full"></div>
</label>
</div>
<div class="glassmorphism relative grid place-items-center py-3 box-border w-full h-full cursor-pointer">
<p class="m-0 text-sm">Motion sensor</p>
<img class="w-8 m-2" src="https://img.icons8.com/ios-glyphs/90/000000/infrared-beam-sending.png"/>
<input id="motion-sensor-toggle-button" type="checkbox" class="absolute w-full h-full opacity-0">
<label for="motion-sensor-toggle-button" class="flex items-center bg-gray-400 h-6 w-12 rounded-full">
<div class="toggle-dot bg-white m-1 h-5 w-5 rounded-full"></div>
</label>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script>
// LIGHTS
const lightsToggleButton = document.getElementById('lights-toggle-button')
const light1 = document.getElementById('light-1')
const light2 = document.getElementById('light-2')
const light3 = document.getElementById('light-3')
function turnOnLights() {
lightsToggleButton.addEventListener('change', () => {
light1.classList.toggle('light')
light2.classList.toggle('light')
light3.classList.toggle('light')
})
}
turnOnLights()
// VACUUM
const cleaningToggleButton = document.getElementById('cleaning-toggle-button')
const vacuum = document.getElementById('vacuum')
function turnOnVaccum() {
cleaningToggleButton.addEventListener('change', () => {
vacuum.classList.toggle('vacuum')
})
}
turnOnVaccum()
// MUSIC
const musicToggleButton = document.getElementById('music-toggle-button')
const audio = document.getElementById('audio')
const audioContext = new AudioContext()
const source = audioContext.createMediaElementSource(audio)
source.connect(audioContext.destination)
let paused = true
function turnOnMusic() {
musicToggleButton.addEventListener('change', () => {
if (paused) {
audio.play()
paused = false
audioContext.resume() // For best practice (https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Best_practices)
} else {
audio.pause()
paused = true
audioContext.resume() // For best practice (https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Best_practices)
}
})
}
turnOnMusic()
// SENSOR
const motionSensorToggleButton = document.getElementById('motion-sensor-toggle-button')
const sensor = document.getElementById('sensor')
function turnOnSensor() {
motionSensorToggleButton.addEventListener('change', () => {
sensor.classList.toggle('sensor')
})
}
turnOnSensor()
</script>
</html>