-
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.
Merge pull request #19 from hurry-harry/hf-quiz-answer-modal
Implement quiz answer result modal
- Loading branch information
Showing
24 changed files
with
7,742 additions
and
82 deletions.
There are no files selected for viewing
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
28 changes: 28 additions & 0 deletions
28
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<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> |
20 changes: 20 additions & 0 deletions
20
src/app/_shared/components/modals/quiz-answer/quiz-answer.modal.scss
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; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Component, Input, OnInit } from "@angular/core"; | ||
import { NgbActiveModal } from "@ng-bootstrap/ng-bootstrap"; | ||
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 implements OnInit { | ||
@Input() result!: QuizResult; | ||
|
||
activeModal: NgbActiveModal = this.activeModalRef; | ||
closeButtonText: string = "Close"; | ||
resultMessage: string = ""; | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { NgModule } from "@angular/core"; | ||
import { NgbModal } from "@ng-bootstrap/ng-bootstrap"; | ||
|
||
export const thirdPartyModules: any[] = [ | ||
NgbModal | ||
] | ||
|
||
@NgModule({ | ||
imports: [ | ||
...thirdPartyModules | ||
], | ||
exports: [ | ||
...thirdPartyModules | ||
] | ||
}) | ||
export class SharedModule { } |
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,5 +1,5 @@ | ||
<div class="card" (click)="navigateTo()" (keypress)="navigateTo()" tabindex="0"> | ||
<img alt="card icon" class="image card__item" src="{{ card.imageSource }}"> | ||
<h2 class="card__item">{{ card.title }}</h2> | ||
<p class="card__description">{{ card.description }}</p> | ||
<div class="home-card" (click)="navigateTo()" (keypress)="navigateTo()" tabindex="0"> | ||
<img alt="card icon" class="home-card__icon home-card__item" src="{{ card.imageSource }}"> | ||
<h2 class="mt-3">{{ card.title }}</h2> | ||
<p class="px-2 pb-2 home-card__description">{{ card.description }}</p> | ||
</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 |
---|---|---|
@@ -1,24 +1,23 @@ | ||
.card { | ||
@use "../../../assets/sass/base/variables" as *; | ||
|
||
.home-card { | ||
background-color: #62587c; | ||
width: 250px; | ||
width: 275px; | ||
height: 200px; | ||
border-radius: 25px; | ||
padding: 0.5rem; | ||
margin: 1rem; | ||
display: flex; | ||
flex-wrap: wrap; | ||
|
||
&__item { | ||
padding: 1.75rem 0.5rem 0rem 0.5rem; | ||
} | ||
color: $taeyeon-white; | ||
cursor: pointer; | ||
|
||
&__description { | ||
margin: -2rem 0.75rem 0rem 0.75rem; | ||
font-weight: 600; | ||
} | ||
} | ||
|
||
.image { | ||
height: 64px; | ||
width: 64px; | ||
&__icon { | ||
width: 64px; | ||
height: 64px; | ||
} | ||
} |
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,3 +1,8 @@ | ||
<a href="http://localhost:8888/login"> | ||
<button>login with spotify</button> | ||
</a> | ||
<div class="vh-100 h-100 d-flex align-items-center justify-content-center "> | ||
<div class="d-flex flex-column align-items-center justify-content-center container__login"> | ||
<p class="w-75 py-4 container__login__header">View your most played on Spotify, play Heardle with your favourite songs, or a daily Taeyeon Heardle!</p> | ||
<a href="http://localhost:8888/login"> | ||
<button class="w-100 btn btn-success">Login with Spotify</button> | ||
</a> | ||
</div> | ||
</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,11 @@ | ||
.container { | ||
|
||
&__login { | ||
margin-bottom: 200px; | ||
|
||
&__header { | ||
font-weight: bold; | ||
} | ||
|
||
} | ||
} |
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
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
Oops, something went wrong.