Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Affiche les bulles une à une puis l'épreuves avec un délai (PIX-14571) #10561

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion junior/app/components/bubble.gjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
import Component from '@glimmer/component';
import {tracked} from '@glimmer/tracking';
import MarkdownToHtml from 'junior/components/markdown-to-html';
import * as markdownConverter from 'junior/utils/markdown-converter';

import OralizationButton from './oralization-button';

export default class Bubble extends Component {
@tracked display = false;

constructor() {
super(...arguments);
setTimeout(() => {
this.display = true;
}, this.args.shouldDisplayIn);
}
get getClasses() {
let className = 'bubble';
if (this.args.status) {
className += ` bubble--${this.args.status}`;
}
return className;
}
get getDelayedClass() {
if (typeof this.args.shouldDisplayIn === 'number' || this.args.withTransition) {
return 'bubble-container__delayed';
}
return '';
}

get textToRead() {
const parser = new DOMParser();
Expand All @@ -20,7 +35,7 @@ export default class Bubble extends Component {
}

<template>
<div class="bubble-container">
<div class="bubble-container {{this.getDelayedClass}} {{if this.display 'display' ''}}">
<MarkdownToHtml ...attributes @markdown={{@message}} @class={{this.getClasses}} />
{{#if @oralization}}
<OralizationButton @text={{this.textToRead}} />
Expand Down
13 changes: 13 additions & 0 deletions junior/app/components/challenge/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,21 @@ export default class Challenge extends Component {
@tracked answer = null;
@tracked answerValue = null;
@tracked displayValidationWarning = false;
@tracked displayChallenge = false;
validationWarning = null;

constructor() {
super(...arguments);
setTimeout(() => {
this.displayChallenge = true;
}, this.args.challenge.instruction.length * 1500);
}

@action
displayBubbleWithDelay(index) {
return (index || 0) * 1500;
}

get disableCheckButton() {
return this.answerValue === null || this.answerValue === '';
}
Expand Down
4 changes: 3 additions & 1 deletion junior/app/components/challenge/item/template.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<div class="challenge-item {{unless this.isMediaWithForm 'challenge-item--single-display'}}">
<div
class="challenge-item {{unless this.isMediaWithForm 'challenge-item--single-display'}} {{if @display 'display' ''}}"
>
{{#if this.hasMedia}}
<div class="challenge-item__media {{unless this.isMediaWithForm 'challenge-item__media--single-display'}}">
{{#if @challenge.illustrationUrl}}
Expand Down
19 changes: 16 additions & 3 deletions junior/app/components/challenge/template.hbs
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
{{page-title (t "pages.challenge.title")}}
<div class="container">
<RobotDialog @class={{this.robotMood}}>
{{#each @challenge.instruction as |instruction|}}
<Bubble @message={{instruction}} @oralization={{@oralization}} />
{{#each @challenge.instruction as |instruction index|}}
<Bubble
@message={{instruction}}
@oralization={{@oralization}}
@shouldDisplayIn={{this.displayBubbleWithDelay index}}
/>
{{/each}}
{{#if (eq this.answer.result "ok")}}
<Bubble
@message={{t "pages.challenge.messages.correct-answer"}}
@status="success"
@oralization={{@oralization}}
aria-live="polite"
@withTransition={{true}}
/>
{{/if}}
{{#if (eq this.answer.result "ko")}}
Expand All @@ -18,13 +23,21 @@
@oralization={{@oralization}}
@status="error"
aria-live="polite"
@withTransition={{true}}
/>
{{/if}}
{{#if this.displayValidationWarning}}
<Bubble @message={{this.validationWarning}} @status="warning" aria-live="polite" @oralization={{@oralization}} />
<Bubble
@message={{this.validationWarning}}
@status="warning"
aria-live="polite"
@oralization={{@oralization}}
@withTransition={{true}}
/>
{{/if}}
</RobotDialog>
<Challenge::Item
@display={{this.displayChallenge}}
@setAnswerValue={{this.setAnswerValue}}
@setValidationWarning={{this.setValidationWarning}}
@validateAnswer={{this.validateAnswer}}
Expand Down
9 changes: 9 additions & 0 deletions junior/app/styles/components/bubble.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
.bubble-container {
display: flex;
align-items: center;
opacity: 0;

&.display {
opacity: 1;
}

&__delayed {
transition: all 2s;
}
}

.bubble {
Expand Down
6 changes: 6 additions & 0 deletions junior/app/styles/components/challenge/challenge-item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
display: flex;
align-content: center;
margin: 0 140px;
opacity: 0;
transition: all 1s;

&.display {
opacity:1;
}

@include device-is('tablet') {
margin: 0 120px;
Expand Down