✨ first working version (bugs with missing codes)
This commit is contained in:
31
src/app/compos/question/question.component.html
Normal file
31
src/app/compos/question/question.component.html
Normal file
@@ -0,0 +1,31 @@
|
||||
<app-progress [progress]="computeProgress()"></app-progress>
|
||||
|
||||
|
||||
<div class="container" *ngIf="question">
|
||||
<app-logo></app-logo>
|
||||
|
||||
<div class="hasTaken block">
|
||||
<h2>Question {{question.id}}</h2>
|
||||
<div class="question"><h3>{{question.question.split('*')[0]}}<span class="highlight">{{question.question.split('*')[1]}}</span> ?</h3></div>
|
||||
<div class="answer">
|
||||
<div class="answers">
|
||||
<span (click)="setHasTaken(true)" [ngClass]="{'active': hasTaken}">Oui</span>
|
||||
<span (click)="setHasTaken(false)" [ngClass]="{'active': hasTaken === false}">Non</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="symptoms block" *ngIf="hasTaken">
|
||||
<div class="question">
|
||||
<h3 class="question">A-t-elle présenté un ou plusieurs effet(s) indésirable(s) suivant(s) ?</h3>
|
||||
<span class="how">Plusieurs choix possibles. Sélectionnez si applicable.</span>
|
||||
</div>
|
||||
<app-radio (onAddSymptom)="addAnswer($event)" (onRemoveSymptom)="removeAnswer($event)" [choices]="question.symptoms"></app-radio>
|
||||
</div>
|
||||
|
||||
<div class="buttons">
|
||||
<button *ngIf="!isFirstQuestion" class="btn secondary">Question précédente</button>
|
||||
<button *ngIf="!isLastQuestion" [disabled]="hasTaken === undefined" class="btn" (click)="next()">Question suivante</button>
|
||||
<button *ngIf="isLastQuestion" [disabled]="hasTaken === undefined" class="btn" (click)="validate()">Valider</button>
|
||||
</div>
|
||||
</div>
|
||||
82
src/app/compos/question/question.component.scss
Normal file
82
src/app/compos/question/question.component.scss
Normal file
@@ -0,0 +1,82 @@
|
||||
@import "../../../styles/variables.scss";
|
||||
|
||||
h2 {
|
||||
font-weight: 500;
|
||||
color: #FFF;
|
||||
font-size: 64px;
|
||||
}
|
||||
|
||||
.question h3 {
|
||||
font-size: 32px;
|
||||
line-height: 48px;
|
||||
font-weight: 200;
|
||||
|
||||
& .highlight {
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
.container {
|
||||
|
||||
width: 60%;
|
||||
margin: 0 auto;
|
||||
|
||||
.block {
|
||||
display: flex;
|
||||
gap: 32px;
|
||||
flex-direction: column;
|
||||
border-radius: 32px;
|
||||
margin-top: 32px;
|
||||
}
|
||||
|
||||
& .hasTaken {
|
||||
|
||||
background: rgb(126,197,187);
|
||||
background: linear-gradient(142deg, rgba(126,197,187,1) 0%, rgb(61, 141, 141) 100%);
|
||||
position: relative;
|
||||
box-shadow: #00000022 0px 0px 10px;
|
||||
padding: 64px 32px;
|
||||
|
||||
.answers {
|
||||
background-color: #FFF;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
display: inline-block;
|
||||
|
||||
& span {
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
color: $color-A;
|
||||
transition: background-color 0.2s, color 0.2s;
|
||||
font-weight: 500;
|
||||
padding: 8px 16px;
|
||||
display: inline-block;
|
||||
|
||||
&.active {
|
||||
background-color: $color-A;
|
||||
color: #FFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
& .symptoms {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
padding-top: 0;
|
||||
border-left: 4px solid $color-A;
|
||||
border-radius: 0;
|
||||
padding-left: 16px;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.buttons {
|
||||
margin-top: 64px;
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
justify-content: flex-end;
|
||||
& .btn {
|
||||
width: 300px;
|
||||
}
|
||||
}
|
||||
69
src/app/compos/question/question.component.ts
Normal file
69
src/app/compos/question/question.component.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
||||
import {Question, QUESTIONS, Symptom} from "../../questions.constants";
|
||||
import {AnswersService} from "../../services/answers.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-question',
|
||||
templateUrl: './question.component.html',
|
||||
styleUrls: ['./question.component.scss']
|
||||
})
|
||||
export class QuestionComponent {
|
||||
|
||||
_question: Question = QUESTIONS[0];
|
||||
get question(): Question {
|
||||
return this._question;
|
||||
}
|
||||
@Input() set question(question: Question) {
|
||||
this._question = question;
|
||||
this.isFirstOrLast();
|
||||
}
|
||||
|
||||
@Output() onValidate: EventEmitter<void> = new EventEmitter<void>();
|
||||
@Output() onNext: EventEmitter<void> = new EventEmitter<void>();
|
||||
@Output() onPrevious: EventEmitter<void> = new EventEmitter<void>();
|
||||
|
||||
hasTaken: boolean | undefined = undefined;
|
||||
isFirstQuestion: boolean = false;
|
||||
isLastQuestion: boolean = false;
|
||||
|
||||
constructor(private answerService: AnswersService) { }
|
||||
|
||||
setHasTaken = (hasTaken: boolean) => {
|
||||
this.hasTaken = hasTaken;
|
||||
}
|
||||
|
||||
isFirstOrLast = () => {
|
||||
this.isFirstQuestion = this.question.id === 1;
|
||||
this.isLastQuestion = this.question.id === QUESTIONS.length;
|
||||
}
|
||||
|
||||
next = () => {
|
||||
this.onNext.emit();
|
||||
this.hasTaken = undefined;
|
||||
this.isFirstOrLast();
|
||||
}
|
||||
|
||||
previous = () => {
|
||||
this.onPrevious.emit();
|
||||
this.hasTaken = undefined;
|
||||
this.isFirstOrLast();
|
||||
}
|
||||
|
||||
computeProgress() {
|
||||
return (this.question.id - 1) * 100 / (QUESTIONS.length - 1);
|
||||
}
|
||||
|
||||
addAnswer = (symptom: Symptom) => {
|
||||
const code = `Q${this._question.id}${symptom.key}`;
|
||||
this.answerService.addAnswer(code);
|
||||
}
|
||||
|
||||
removeAnswer = (symptom: Symptom) => {
|
||||
const code = `Q${this._question.id}${symptom.key}`;
|
||||
this.answerService.removeAnswer(code);
|
||||
}
|
||||
|
||||
validate = () => {
|
||||
this.onValidate.emit();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user