-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Ajoute une page de loader avant les résultats de fin de par…
- Loading branch information
Showing
30 changed files
with
442 additions
and
27 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
100 changes: 100 additions & 0 deletions
100
mon-pix/app/components/pages/campaigns/results-loader.gjs
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,100 @@ | ||
import PixButton from '@1024pix/pix-ui/components/pix-button'; | ||
import PixIcon from '@1024pix/pix-ui/components/pix-icon'; | ||
import { action } from '@ember/object'; | ||
import { service } from '@ember/service'; | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { t } from 'ember-intl'; | ||
import { modifier } from 'ember-modifier'; | ||
import { gt } from 'ember-truth-helpers'; | ||
|
||
const callOnTrue = modifier((element, [action, value]) => { | ||
if (value) { | ||
action(); | ||
} | ||
}); | ||
|
||
export default class ResultsLoader extends Component { | ||
@service router; | ||
@tracked steps = 1; | ||
@tracked isButtonDisabled = true; | ||
|
||
get lineAppearanceInterval() { | ||
return this.args.lineAppearanceInterval ?? 1200; | ||
} | ||
|
||
get lineTransitionDuration() { | ||
return this.args.lineTransitionDuration ?? 300; | ||
} | ||
|
||
get iconTransitionDuration() { | ||
return this.args.iconTransitionDuration ?? 300; | ||
} | ||
|
||
constructor(...args) { | ||
super(...args); | ||
const interval = setInterval(() => { | ||
this.steps++; | ||
if (this.steps === 3) { | ||
clearInterval(interval); | ||
setTimeout(() => { | ||
this.isButtonDisabled = false; | ||
}, this.lineTransitionDuration + this.iconTransitionDuration); | ||
} | ||
}, this.lineAppearanceInterval); | ||
} | ||
|
||
@action | ||
onClick() { | ||
this.router.transitionTo('campaigns.assessment.skill-review', this.args.code); | ||
} | ||
|
||
<template> | ||
<main role="main" class="results-loader"> | ||
<div class="results-loader__content"> | ||
<img class="results-loader__illustration" alt="" src="/images/illustrations/score-computation.svg" /> | ||
<h1 class="results-loader__title">{{t "components.campaigns.results-loader.title"}}</h1> | ||
<p class="results-loader__subtitle">{{t "components.campaigns.results-loader.subtitle"}}</p> | ||
<ul class="results-loader__steps"> | ||
<Line @visible={{true}} @iconTransitionDuration={{this.iconTransitionDuration}}> | ||
{{t "components.campaigns.results-loader.steps.competences"}} | ||
</Line> | ||
<Line @visible={{gt this.steps 1}} @iconTransitionDuration={{this.iconTransitionDuration}}> | ||
{{t "components.campaigns.results-loader.steps.trainings"}} | ||
</Line> | ||
<Line @visible={{gt this.steps 2}} @iconTransitionDuration={{this.iconTransitionDuration}}> | ||
{{t "components.campaigns.results-loader.steps.rewards"}} | ||
</Line> | ||
</ul> | ||
|
||
<PixButton | ||
class="results-loader__button" | ||
@isDisabled={{this.isButtonDisabled}} | ||
@triggerAction={{this.onClick}} | ||
>{{t "common.actions.continue"}}</PixButton> | ||
</div> | ||
</main> | ||
</template> | ||
} | ||
|
||
class Line extends Component { | ||
@tracked isIconDisplayed = false; | ||
|
||
@action | ||
displayIcon() { | ||
setTimeout(() => { | ||
this.isIconDisplayed = true; | ||
}, this.args.iconTransitionDuration); | ||
} | ||
|
||
<template> | ||
<li class="line {{if @visible 'line--visible'}}" {{callOnTrue this.displayIcon @visible}}> | ||
<PixIcon | ||
class="line__icon {{if this.isIconDisplayed 'line__icon--visible'}}" | ||
@name="checkCircle" | ||
@plainIcon={{true}} | ||
/> | ||
{{yield}} | ||
</li> | ||
</template> | ||
} |
81 changes: 81 additions & 0 deletions
81
mon-pix/app/components/pages/campaigns/results-loader.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,81 @@ | ||
.results-loader { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
width: 100vw; | ||
height: 100vh; | ||
padding: var(--pix-spacing-8x) var(--pix-spacing-2x); | ||
|
||
&__illustration { | ||
align-self: center; | ||
min-width: 210px; | ||
max-width: 320px; | ||
} | ||
|
||
@media (min-width: 767px) { | ||
&__illustration { | ||
min-width: 320px; | ||
} | ||
} | ||
|
||
&__content { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
} | ||
|
||
&__button, | ||
&__steps { | ||
width: fit-content; | ||
margin: auto; | ||
margin-top: var(--pix-spacing-6x); | ||
} | ||
|
||
&__title { | ||
@extend %pix-title-m; | ||
|
||
margin-top: var(--pix-spacing-8x); | ||
color: var(--pix-neutral-900); | ||
text-align: center; | ||
} | ||
|
||
&__subtitle { | ||
@extend %pix-title-xs; | ||
|
||
margin-top: var(--pix-spacing-2x); | ||
color: var(--pix-neutral-500); | ||
text-align: center; | ||
} | ||
|
||
&__button { | ||
transition: opacity 300ms ease-in; | ||
} | ||
|
||
.line { | ||
display: flex; | ||
gap: var(--pix-spacing-2x); | ||
margin-top: var(--pix-spacing-3x); | ||
opacity: 0; | ||
transition: opacity 150ms ease-in; | ||
|
||
&--visible { | ||
opacity: 1; | ||
} | ||
|
||
&__icon { | ||
width: var(--pix-spacing-6x); | ||
height: var(--pix-spacing-6x); | ||
opacity: 0; | ||
transition: opacity 300ms ease-in; | ||
fill: var(--pix-success-500); | ||
|
||
&--visible { | ||
opacity: 1; | ||
} | ||
} | ||
|
||
&:first-child { | ||
margin-top: 0; | ||
} | ||
} | ||
} |
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
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
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
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,36 @@ | ||
import Route from '@ember/routing/route'; | ||
import { service } from '@ember/service'; | ||
|
||
export default class ResultsLoaderRoute extends Route { | ||
@service currentUser; | ||
@service session; | ||
@service router; | ||
@service store; | ||
|
||
beforeModel(transition) { | ||
this.session.requireAuthenticationAndApprovedTermsOfService(transition); | ||
} | ||
|
||
async model() { | ||
const campaign = this.modelFor('campaigns'); | ||
const campaignParticipation = await this.store.queryRecord('campaign-participation', { | ||
campaignId: campaign.id, | ||
userId: this.currentUser.user.id, | ||
}); | ||
return { | ||
campaign, | ||
campaignParticipation, | ||
}; | ||
} | ||
|
||
async afterModel({ campaign, campaignParticipation }) { | ||
const assessment = await campaignParticipation?.assessment; | ||
|
||
if (!campaignParticipation) { | ||
this.router.replaceWith('campaigns.campaign-landing-page', campaign.code); | ||
} else if (campaignParticipation.isShared) { | ||
this.router.replaceWith('campaigns.assessment.skill-review', campaign.code); | ||
} else if (campaignParticipation && !assessment.isCompleted) | ||
this.router.replaceWith('campaigns.assessment.start-or-resume', campaign.code); | ||
} | ||
} |
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 @@ | ||
<Pages::Campaigns::ResultsLoader @code={{@model.campaign.code}} /> |
Oops, something went wrong.