Skip to content

Commit 024795f

Browse files
committed
Add Restart Button
1 parent ff36584 commit 024795f

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

src/app/components/quizz/quizz.component.css

+36-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868
.quizz_results {
6969
width: 100%;
70-
height: 580px;
70+
height: 550px;
7171
border-radius: 10px;
7272
padding: 20px auto;
7373
display: flex;
@@ -78,6 +78,41 @@
7878
filter: drop-shadow(5px 5px 26px #000);
7979
}
8080

81+
.quizz_restart {
82+
padding: 1rem;
83+
text-align: center;
84+
border-radius: 10px;
85+
color: #fafaf5;
86+
cursor: pointer;
87+
border: 1px solid #644ed2;
88+
background-color: transparent;
89+
margin: 1rem 0;
90+
filter: drop-shadow(5px 5px 26px #000);
91+
}
92+
93+
.quizz_restart:hover{
94+
opacity: .8;
95+
}
96+
97+
:has(.sly) .quizz_restart {
98+
background-color: rgba(25,60,20,1);
99+
border: none;
100+
}
101+
:has(.griff) .quizz_restart {
102+
background-color: rgba(147,30,25,1);
103+
border: none;
104+
}
105+
:has(.rav) .quizz_restart {
106+
background-color: rgba(14,60,130,1);
107+
border: none;
108+
}
109+
:has(.huff) .quizz_restart {
110+
color: #050505;
111+
background-color: rgba(219,179,0,1);
112+
border: none;
113+
}
114+
115+
81116
img {
82117
margin-top: 20px;
83118
width: 250px;

src/app/components/quizz/quizz.component.html

+2
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ <h1>O seu resultado é: </h1>
1919
<p>{{ answerSelected }}</p>
2020
<img src="{{ photo }}" alt="">
2121
</div>
22+
23+
<button class="quizz_restart" (click)="restartQuizz()">Reiniciar o Quizz</button>
2224
</div>

src/app/components/quizz/quizz.component.ts

+19-1
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,29 @@ export class QuizzComponent implements OnInit {
5555
this.answerSelected = quizz_questions.results[finalAnswer as keyof typeof quizz_questions.results]
5656

5757
if(finalAnswer === "G"){
58+
5859
this.photo = 'assets/imgs/Gryffindor.webp'
5960
this.bgc = "griff"
6061
document.body.classList.toggle('griffindor')
62+
6163
}else if(finalAnswer === "S"){
64+
6265
this.photo = "assets/imgs/Slytherin.webp"
6366
this.bgc = "sly"
6467
document.body.classList.toggle('slytherin')
68+
6569
}else if(finalAnswer === "H"){
70+
6671
this.photo = "assets/imgs/Hufflepuff.webp"
6772
this.bgc = "huff"
68-
document.body.classList.toggle('hufflepuff')
73+
document.body.classList.toggle('hufflepuff')
74+
6975
}else{
76+
7077
this.photo = "assets/imgs/Ravenclaw.webp"
7178
this.bgc = "rav"
7279
document.body.classList.toggle('ravenclaw')
80+
7381
}
7482
}
7583
}
@@ -87,4 +95,14 @@ export class QuizzComponent implements OnInit {
8795
})
8896
return result
8997
}
98+
99+
restartQuizz() {
100+
this.finished = false;
101+
this.answers = [];
102+
this.questionIndex = 0;
103+
this.questionSelected = this.questions[this.questionIndex];
104+
this.photo = "";
105+
this.bgc = "";
106+
document.body.classList.remove('griffindor', 'slytherin', 'hufflepuff', 'ravenclaw');
107+
}
90108
}

0 commit comments

Comments
 (0)