forked from cypress-io/cypress-test-tiny
-
Notifications
You must be signed in to change notification settings - Fork 0
/
global-loading.html
59 lines (56 loc) · 1.59 KB
/
global-loading.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
<!doctype html>
<html>
<head>
<title>Obscure me with your favorite app</title>
<style>
#global-loading {
display: none;
top: 0;
left: 0;
right: 0;
bottom: 0;
position: fixed;
background: rgba(0, 0, 0, 0.35);
color: #fff;
align-items: center;
justify-content: center;
}
#global-loading.active {
display: flex;
}
img {
max-width: 400px;
max-height: 400px;
}
</style>
</head>
<body>
<button id="load-content">Load content</button>
<div id="content"></div>
<div id="global-loading">Loading...</div>
<script>
const content = document.getElementById('content')
const loadBtn = document.getElementById('load-content')
const loading = document.getElementById('global-loading')
loadBtn.addEventListener('click', () => {
loading.classList.add('active')
content.replaceChildren()
fetch('https://cataas.com/cat')
.then(response => response.blob())
.then(image => {
const img = document.createElement('img')
img.src = URL.createObjectURL(image)
content.appendChild(img)
const newBtn = document.createElement('button')
newBtn.id = 'new-btn'
newBtn.textContent = 'New button'
content.appendChild(newBtn)
newBtn.addEventListener('click', () => {
content.append('Hello Cypress!')
})
loading.classList.remove('active')
})
})
</script>
</body>
</html>