I have a page that shows the result of a quiz and depends on the number of right answer, the user get some rewards. So, if the user get just one right answer, he will get one reward, the others will be blurred. If the user get two right answers, he will get two rewards, the others will be blurred, and so on. The total of questions is 5 and the total of rewards is 5 too.
HTML
<div id="container"><span>Você acertou </span><span style="color: black; text-align: center;">{{quizResult}}</span> <span id="spotlight"> pergunta(s). Agora é só aproveitar a(s) recompensa(s)!</span> </div> <span class="image"><img src="./assets/images/ticket1.png" alt="Muito abracos" id="recompensa1" [class.blur]="isBlur[0]" /></span> <span class="image"><img src="./assets/images/ticket2.png" alt="Beijo Calhiente" id="recompensa2" [class.blur]="isBlur[1]" /></span> <span class="image"><img src="./assets/images/ticket3.png" alt="Massagem" id="recompensa3" [class.blur]="isBlur[2]" /></span> <span class="image"><img src="./assets/images/ticket4.png" alt="Cafe na cama" id="recompensa4" [class.blur]="isBlur[3]" /></span> <span class="image"><img src="./assets/images/ticket5.png" alt="Jantar Romantico" id="recompensa5" [class.blur]="isBlur[4]" /></span>
TYPESCRIPT
import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-result', templateUrl: './result.component.html', styleUrls: ['./result.component.css'] }) export class ResultComponent implements OnInit { quizResult: number; isBlur: boolean[]; constructor() { this.quizResult = 0; this.isBlur = [] } ngOnInit(): void { this.quizResult = parseInt(localStorage.getItem("numCorrect") ?? "0", this.quizResult); const numberOfImages = document.querySelectorAll('app-result > .image').length; for (let i = 0; i < numberOfImages; i++) { this.isBlur[i] = this.quizResult < i + 1; } } }
CSS
.blur{ filter: blur(5px); -webkit-filter: blur(5px); }