Skip to content

Commit b73886c

Browse files
author
Hugues Signamarcheix
committed
update style
1 parent ab01379 commit b73886c

File tree

7 files changed

+159
-4
lines changed

7 files changed

+159
-4
lines changed

front/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
<h1>Javascript workers in action</h1>
1111
<div class="container">
1212
<button id="refresh" class="btn">Génerer de nouvelles données</button>
13-
<div id="text-placeholder"></div>
13+
<div id="text-placeholder" class="is-empty"></div>
14+
<div class="loader">
15+
<div class="lds-ring"><div></div><div></div><div></div><div></div></div>
16+
</div>
1417
</div>
1518
<script src="javascript/script.js"></script>
1619
</body>

front/javascript/script.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,20 @@ document.addEventListener("DOMContentLoaded",() => {
44

55
let btnRefresh = document.getElementById("refresh");
66
let textPlaceholder = document.getElementById("text-placeholder");
7+
let container = document.getElementsByClassName("container")[0];
78

89
btnRefresh.addEventListener("click",() => {
10+
textPlaceholder.innerHTML = '';
11+
textPlaceholder.classList.add('is-empty');
12+
container.classList.add('is-loading');
913
worker.postMessage('test');
10-
console.log('Message envoyé au worker');
1114
});
1215

1316
worker.onmessage = function(e) {
1417
let textContent = e.data;
15-
console.log('Message reçu depuis le worker '+ textContent);
1618
textPlaceholder.innerHTML = textContent;
19+
container.classList.remove('is-loading');
20+
textPlaceholder.classList.remove('is-empty');
1721
}
1822
}
1923
})

front/scss/components/loader.scss

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.lds-ring {
2+
display: inline-block;
3+
position: relative;
4+
width: 80px;
5+
height: 80px;
6+
div {
7+
box-sizing: border-box;
8+
display: block;
9+
position: absolute;
10+
width: 64px;
11+
height: 64px;
12+
margin: 8px;
13+
border: 8px solid #000;
14+
border-radius: 50%;
15+
animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
16+
border-color: #000 transparent transparent transparent;
17+
&:nth-child(1) { animation-delay: -0.45s; }
18+
&:nth-child(2) { animation-delay: -0.3s; }
19+
&:nth-child(3) { animation-delay: -0.15s; }
20+
}
21+
}
22+
23+
@keyframes lds-ring {
24+
0% {
25+
transform: rotate(0deg);
26+
}
27+
100% {
28+
transform: rotate(360deg);
29+
}
30+
}

front/scss/pages/index.scss

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
h1 {
2+
font-family: sans-serif;
3+
}
4+
.container {
5+
position: relative;
6+
display: flex;
7+
flex-direction: column;
8+
align-items: center;
9+
#refresh {
10+
width: 30%;
11+
padding: 10px;
12+
background-color: #268fc3;
13+
color: white;
14+
font-size: 16px;
15+
border-radius: 5px;
16+
outline: none;
17+
margin-bottom: 20px;
18+
}
19+
#text-placeholder {
20+
&.is-empty { padding: 100px 20px; }
21+
background-color: lightgray;
22+
padding: 20px 20px;
23+
line-height: 20px;
24+
letter-spacing: 1px;
25+
font-family: sans-serif;
26+
border-radius: 5px;
27+
width: 96%;
28+
}
29+
.loader {
30+
position: absolute;
31+
top: 50%;
32+
left: 50%;
33+
transform: translate(-50%,-50%);
34+
}
35+
&:not(.is-loading) {
36+
.loader { display: none; }
37+
}
38+
}

front/scss/style.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@import 'pages/index';
2+
3+
@import 'components/loader'

front/style.css

Lines changed: 77 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

front/style.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)