🎉 first commit

This commit is contained in:
2023-09-10 17:31:20 +02:00
parent e9a19071c2
commit a6bc695506
28 changed files with 1336 additions and 97 deletions

View File

@@ -1 +1 @@
<div class="logo">help<span class="contra">Contra</span></div>
<div class="logo"><span class="contra">Gyn</span>ette</div>

View File

@@ -10,7 +10,6 @@
background-color: $color-E;
color: #FFF;
border-radius: 8px;
text-transform: uppercase;
padding: 4px 8px;
margin-left: 4px;
}

View File

@@ -24,7 +24,7 @@
</div>
<div class="buttons">
<button *ngIf="!isFirstQuestion" class="btn secondary">Question précédente</button>
<button *ngIf="!isFirstQuestion" class="btn secondary" (click)="previous()">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>

View File

@@ -2,18 +2,20 @@
<div class="container">
<app-logo></app-logo>
<h2>Résultats</h2>
<div class="explanation">
<p>Les résultats sont classés du plus recommandé au moins recommandé.</p>
<p>Les résultats sont classés du plus conseillé au moins conseillé.</p>
<p>Cliquez sur un traitement pour plus d'information.</p>
</div>
<h3>Recommandé</h3>
<div class="recommendation" *ngFor="let r of recommendations">
<div class="treatment">{{r.treatment.label}} ({{r.score}})</div>
</div>
<h3 class="discouragement">Non-recommandé</h3>
<div class="recommendation" *ngFor="let r of discouragements">
<div class="treatment">{{r.treatment.label}} ({{r.score}})</div>
<h3>Conseils</h3>
<div class="recommendation" *ngFor="let r of recommendations.concat(discouragements)">
<div class="treatment" [style.border-color]="computeScoreColor(r.score)" [style.color]="computeScoreColor(r.score)" (click)="openTreatmentDetails(r.treatment.code)">{{r.treatment.label}} ({{r.score}})</div>
</div>
<button class="btn" (click)="onReset.emit()">Relancer le formulaire</button>
</div>
<ng-container *ngIf="currentDetailsCode">
<app-treatment-details-modal [treatmentCode]="currentDetailsCode" (onClose)="closeTreatmentDetails()"></app-treatment-details-modal>
</ng-container>

View File

@@ -36,8 +36,18 @@
& .treatment {
font-size: 16px;
margin-bottom: 8px;
border-left: 6px solid transparent;
padding: 8px;
cursor: pointer;
&:hover{
text-decoration: underline;
}
}
}
}
.btn {
margin-top: 32px;
}

View File

@@ -12,6 +12,8 @@ export class ResultsComponent implements OnInit {
recommendations: RecommendationModel[] = [];
discouragements: RecommendationModel[] = [];
currentDetailsCode: string | null = null;
@Output() onReset: EventEmitter<void> = new EventEmitter<void>();
constructor(private engine: EngineService, private answers: AnswersService) { }
@@ -21,4 +23,36 @@ export class ResultsComponent implements OnInit {
this.recommendations = recommendations.filter((r) => r.score >= 0).sort((r1, r2) => r2.score - r1.score);
this.discouragements = recommendations.filter((r) => r.score < 0);
}
openTreatmentDetails = (code: string): void => {
this.currentDetailsCode = code;
}
closeTreatmentDetails = () => {
this.currentDetailsCode = null;
}
computeScoreColor = (score: number) => {
score += 1;
// warning, we put ourselves in a [1.5, 0] range instead of [0.5, -1]
const maxScore = 1.5;
if(score > maxScore){
score = maxScore;
}
return lerpColor("#d3274f", "#3fa58f", score / maxScore);
}
}
const lerpColor = (a: string, b: string, amount: number) => {
const ah = +a.replace('#', '0x'),
ar = ah >> 16, ag = ah >> 8 & 0xff, ab = ah & 0xff,
bh = +b.replace('#', '0x'),
br = bh >> 16, bg = bh >> 8 & 0xff, bb = bh & 0xff,
rr = ar + amount * (br - ar),
rg = ag + amount * (bg - ag),
rb = ab + amount * (bb - ab);
return '#' + ((1 << 24) + (rr << 16) + (rg << 8) + rb | 0).toString(16).slice(1);
}

View File

@@ -0,0 +1,3 @@
<p>
<span>{{treatment}}</span> {{info}}
</p>

View File

@@ -0,0 +1,6 @@
@import "../../../../styles/variables.scss";
span {
color: $color-B;
font-weight: 500;
}

View File

@@ -0,0 +1,27 @@
import {Component, Input, OnInit} from '@angular/core';
@Component({
selector: 'app-formatted-line',
templateUrl: './formatted-line.component.html',
styleUrls: ['./formatted-line.component.scss']
})
export class FormattedLineComponent implements OnInit {
@Input() line!: string;
treatment!: string;
info!: string;
constructor() { }
ngOnInit(): void {
const split = this.line.split(':');
if(split.length > 1){
this.treatment = split[0];
this.info = this.line.replace(`${this.treatment}`, '');
}else{
this.info = this.line;
}
}
}

View File

@@ -0,0 +1,25 @@
<div class="container">
<div class="modal">
<div class="header">
<h2>{{details.treatment.label}}</h2>
<button title="Fermer le traitement" (click)="onClose.emit()">X</button>
</div>
<div class="scrollable">
<div class="sections">
<div class="section" *ngFor="let section of details.sections" [ngClass]="{'free': section.type === 'free'}">
<h3>{{section.title}}</h3>
<div class="section-line" *ngFor="let line of section.rows">
<ng-container *ngIf="section.type === 'free'">
<p>{{line}}</p>
</ng-container>
<ng-container *ngIf="section.type === 'formatted'">
<app-formatted-line [line]="line"></app-formatted-line>
</ng-container>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,84 @@
@import "../../../styles/variables.scss";
.container {
position: fixed;
inset: 0;
z-index: 999;
background-color: #00000033;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.modal {
position: relative;
height: 80vh;
width: 80vw;
max-width: 80vw;
background-color: #FFFFFF;
padding: 32px;
border-radius: 32px;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 32px;
padding-bottom: 16px;
border-bottom: 2px solid $border-color;
& button {
border: none;
background-color: $color-E;
color: white;
font-size: 2em;
width: 40px;
height: 40px;
border-radius: 50%;
&:hover {
background-color: darken($color-E, 10%);
cursor: pointer;
}
}
}
.scrollable {
overflow-y: auto;
max-height: 90%;
}
h2 {
font-size: 1.5em;
font-weight: 500;
color: $color-B;
}
h3 {
font-size: 1.2em;
margin-bottom: 8px;
font-weight: 500;
color: $color-B;
}
.sections {
display: flex;
flex-direction: column;
gap: 32px;
}
.section {
border-left: 4px solid $color-B;
padding-left: 8px;
line-height: 24px;
&.free {
border-color: $color-A;
& h3 {
color: $color-A;
}
}
}

View File

@@ -0,0 +1,28 @@
import {Component, EventEmitter, Input, Output, OnInit, HostListener} from '@angular/core';
import {Section, TreatmentDetails} from "../../models";
import {TreatmentsService} from "../../services/treatments.service";
@Component({
selector: 'app-treatment-details-modal',
templateUrl: './treatment-details-modal.component.html',
styleUrls: ['./treatment-details-modal.component.scss']
})
export class TreatmentDetailsModalComponent implements OnInit {
@Input() treatmentCode!: string;
@Output() onClose: EventEmitter<void> = new EventEmitter();
details!: TreatmentDetails;
constructor(private treatmentsService: TreatmentsService) { }
ngOnInit(): void {
this.details = this.treatmentsService.getTreatmentDetails(this.treatmentCode);
this.details.sections = this.details.sections.sort((s1: Section, s2: Section) => (s1.type === "free") ? 1 : -1);
}
@HostListener('document:keydown.escape', ['$event']) onKeydownHandler(event: KeyboardEvent) {
this.onClose.emit();
}
}