-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87f6dbc
commit b2a63c3
Showing
7 changed files
with
95 additions
and
20 deletions.
There are no files selected for viewing
36 changes: 26 additions & 10 deletions
36
src/app/_shared/components/modals/quiz-answer/quiz-answer.modal.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,28 @@ | ||
<div class="modal-header"> | ||
<h4 class="modal-title">Correct!</h4> | ||
<button type="button" class="btn-close" aria-label="Close" (click)="activeModal.dismiss('Cross click')"></button> | ||
</div> | ||
<div class="modal-body"> | ||
<div class=""> | ||
<img alt="album cover" src="{{track.album.images[0].url}}"> | ||
<div class="result-modal"> | ||
<div class="modal-header" [ngClass]="(result.isCorrect ? 'result-modal--correct' : 'result-modal--incorrect')"> | ||
<h4 class="modal-title">{{result.isCorrect ? 'Correct!' : 'Incorrect!'}}</h4> | ||
<button type="button" class="btn-close" aria-label="Close" (click)="activeModal.dismiss('Cross click')"></button> | ||
</div> | ||
<div class="modal-body d-flex flex-column"> | ||
<div class="pt-0 p-1 mx-auto"> | ||
{{resultMessage}} | ||
</div> | ||
<div class="d-flex flex-row "> | ||
<img class="result-modal__album-cover" alt="album cover" src="{{result.track.album.images[0].url}}"> | ||
<div class="d-flex flex-column justify-content-around p-3"> | ||
<div> | ||
{{result.track.name}} | ||
</div> | ||
<div> | ||
{{result.track.artists[0].name}} | ||
</div> | ||
<div> | ||
{{result.track.album.name}} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="modal-footer" [ngClass]="(result.isCorrect ? 'result-modal--correct' : 'result-modal--incorrect')"> | ||
<button type="button" class="btn btn-outline-dark" (click)="close()">{{closeButtonText}}</button> | ||
</div> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-outline-dark" (click)="activeModal.close('Close click')">Close</button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@use '../../../../../assets/sass/base/variables' as *; | ||
|
||
.result-modal { | ||
color: $taeyeon-black; | ||
font-weight: bold; | ||
|
||
&--correct { | ||
background: $green; | ||
} | ||
|
||
&--incorrect { | ||
background: $red; | ||
} | ||
|
||
&__album-cover { | ||
height: 175px; //10rem | ||
width: 175px; | ||
border-radius: 20px; | ||
} | ||
} |
34 changes: 29 additions & 5 deletions
34
src/app/_shared/components/modals/quiz-answer/quiz-answer.modal.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,41 @@ | ||
import { Component, Input } from "@angular/core"; | ||
import { Component, Input, OnInit } from "@angular/core"; | ||
import { NgbActiveModal } from "@ng-bootstrap/ng-bootstrap"; | ||
import { Track } from "../../../models/user-top-items-response.model"; | ||
import { QuizResult } from "../../../models/result-modal.model"; | ||
import { CommonModule } from "@angular/common"; | ||
import { Router } from "@angular/router"; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: 'app-quiz-answer-modal', | ||
templateUrl: './quiz-answer.modal.html', | ||
styleUrls: ['./quiz-answer.modal.scss'], | ||
imports: [CommonModule] | ||
}) | ||
export class QuizAnswerModal { | ||
@Input() track!: Track; | ||
export class QuizAnswerModal implements OnInit { | ||
@Input() result!: QuizResult; | ||
|
||
activeModal: NgbActiveModal = this.activeModalRef; | ||
closeButtonText: string = "Close"; | ||
resultMessage: string = ""; | ||
|
||
constructor(private activeModalRef: NgbActiveModal) { } | ||
constructor( | ||
private activeModalRef: NgbActiveModal, | ||
private router: Router) { } | ||
|
||
ngOnInit(): void { | ||
if (this.result.isCorrect) | ||
this.resultMessage = "You got it right!"; | ||
else | ||
this.resultMessage = "The right answer is..." | ||
|
||
if (this.result.isLastQuestion) | ||
this.closeButtonText = "Home"; | ||
} | ||
|
||
close(): void { | ||
if (this.result.isLastQuestion) | ||
this.router.navigate(['./home']); | ||
else | ||
this.activeModal.close('Close click') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Track } from "./user-top-items-response.model"; | ||
|
||
export interface QuizResult { | ||
isCorrect: boolean; | ||
isLastQuestion: boolean; | ||
|
||
track: Track; | ||
score: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters