Skip to content

Commit 32f5ac2

Browse files
committed
feat(simpsons-quotes) : change some css
1 parent a3ffebe commit 32f5ac2

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

Simpsons-Quotes/main.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11

22

3-
const loader = document.getElementById("loader");
43
function getQuote() {
54
const quoteText = document.getElementById('quoteText');
65
const characterName = document.getElementById('characterName');
76
const imageUrl = document.querySelector(".image");
7+
const loader = document.getElementById("loader");
8+
const quoteBox = document.querySelector('.quote-box');
9+
loader.style.display = "block";
10+
imageUrl.classList.remove('visible');
11+
quoteBox.style.display = 'none';
812
fetch('https://thesimpsonsquoteapi.glitch.me/quotes')
913
.then(response => response.json())
1014
.then(data => {
11-
console.log("=>(main.js:20) data", data);
15+
quoteBox.style.display = 'block';
1216
const quote = data[0].quote;
1317
const character = data[0].character;
1418
imageUrl.src = data[0].image;
@@ -19,5 +23,10 @@ function getQuote() {
1923
.catch(error => {
2024
console.error('Error fetching the quote:', error);
2125
document.getElementById('quoteText').innerText = 'Failed to fetch quote. Please try again.';
22-
});
26+
})
27+
.finally( () => {
28+
loader.style.display = "none";
29+
quoteBox.style.display = "block";
30+
});
31+
2332
}

Simpsons-Quotes/style.css

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ h1{
3131
justify-content: center;
3232
text-align: center;
3333
width: 500px;
34+
min-height: 350px;
3435
}
3536
#quoteText{
3637
font-size: larger;
@@ -76,6 +77,7 @@ img.visible {
7677
user-select: none;
7778
-webkit-user-select: none;
7879
touch-action: manipulation;
80+
margin-bottom: 10px;
7981
}
8082

8183
.btn_class:focus {
@@ -106,14 +108,14 @@ img.visible {
106108

107109
.loader {
108110
border: 8px solid #f3f3f3;
109-
border-top: 8px solid #3498db;
111+
border-top: 8px solid #ff001a;
110112
border-radius: 50%;
111113
width: 60px;
112114
height: 60px;
113115
animation: spin 1s linear infinite;
114-
position: absolute;
116+
/*position: absolute;*/
115117
top: 50%;
116-
left: 50%;
118+
margin: 60px auto 10px auto;
117119
transform: translate(-50%, -50%);
118120
display: none;
119121
}

0 commit comments

Comments
 (0)