Skip to content

Commit

Permalink
refactor(junior): purge some mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
rouxxi committed Jan 15, 2025
1 parent d4fc3c3 commit 9335a91
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 45 deletions.
5 changes: 5 additions & 0 deletions junior/app/components/card-wrapper.gjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div class="card-wrapper">
{{yield}}
</div>
</template>
27 changes: 16 additions & 11 deletions junior/app/components/challenge/challenge-content.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { or } from 'ember-truth-helpers';

import CardWrapper from '../card-wrapper';
import AutoReply from './content/auto-reply';
import ChallengeActions from './content/challenge-actions';
import ChallengeMedia from './content/challenge-media';
Expand Down Expand Up @@ -54,17 +55,21 @@ export default class ChallengeContent extends Component {
<template>
<div class="challenge-content {{this.challengeContentClassname}}">
{{#if @challenge.illustrationUrl}}
<ChallengeMedia @src={{@challenge.illustrationUrl}} @alt={{@challenge.illustrationAlt}} />
<CardWrapper>
<ChallengeMedia @src={{@challenge.illustrationUrl}} @alt={{@challenge.illustrationAlt}} />
</CardWrapper>
{{/if}}
{{#if @challenge.hasEmbed}}
<EmbeddedSimulator
@url={{@challenge.embedUrl}}
@title={{@challenge.embedTitle}}
@height={{@challenge.embedHeight}}
@hideSimulator={{@isDisabled}}
@isMediaWithForm={{this.isMediaWithForm}}
@shouldDisplayRebootButton={{this.shouldDisplayRebootButton}}
/>
<CardWrapper>
<EmbeddedSimulator
@url={{@challenge.embedUrl}}
@title={{@challenge.embedTitle}}
@height={{@challenge.embedHeight}}
@hideSimulator={{@isDisabled}}
@isMediaWithForm={{this.isMediaWithForm}}
@shouldDisplayRebootButton={{this.shouldDisplayRebootButton}}
/>
</CardWrapper>
{{/if}}
{{#if @challenge.hasWebComponent}}
<EmbeddedWebComponent
Expand All @@ -74,7 +79,7 @@ export default class ChallengeContent extends Component {
/>
{{/if}}
{{#if @challenge.hasForm}}
<div class="challenge-content__questionnaire">
<div class="challenge-content__form">
{{#if (or @challenge.isQROC @challenge.isQROCM)}}
<Qrocm @challenge={{@challenge}} @setAnswerValue={{@setAnswerValue}} @isDisabled={{@isDisabled}} />
{{else if @challenge.isQCU}}
Expand Down Expand Up @@ -105,7 +110,7 @@ export default class ChallengeContent extends Component {
@skipChallenge={{@skipChallenge}}
@level={{@activity.level}}
@nextAction={{@resume}}
@isLesson={{@challenge.focused}}
@isLesson={{@challenge.isLesson}}
@disableCheckButton={{@disableCheckButton}}
@disableLessonButton={{@disableLessonButton}}
@answerHasBeenValidated={{@answerHasBeenValidated}}
Expand Down
12 changes: 5 additions & 7 deletions junior/app/models/challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,17 @@ export default class Challenge extends Model {
@computed('embedHeight', 'embedTitle', 'embedUrl', 'hasWebComponent')
get hasEmbed() {
const embedUrl = this.embedUrl;
return (
!!embedUrl &&
!!this.embedTitle &&
!!this.embedHeight &&
!this.hasWebComponent &&
embedUrl.toLowerCase().indexOf('https://') === 0
); // fixes bug on IE: startsWith in not supported (PR #242)
return !!embedUrl && !!this.embedTitle && !this.hasWebComponent && embedUrl.toLowerCase().indexOf('https://') === 0; // fixes bug on IE: startsWith in not supported (PR #242)
}

get hasWebComponent() {
return !!this.webComponentProps && !!this.webComponentTagName;
}

get isLesson() {
return !!this.focused;
}

get isQROC() {
return this.autoReply === false && this.type === 'QROC';
}
Expand Down
1 change: 1 addition & 0 deletions junior/app/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
@import 'components/delayed-element';
@import 'components/mission-card/card';
@import 'components/bubble';
@import 'components/card-wrapper';
@import 'components/footer';
@import 'components/issue';
@import 'components/oralization-button';
Expand Down
7 changes: 7 additions & 0 deletions junior/app/styles/components/card-wrapper.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.card-wrapper {
height: fit-content;
padding: var(--pix-spacing-4x);
background-color: var(--pix-neutral-0);
border-radius: 24px;
box-shadow: 0 0 1px 0 var(--pix-primary-500), 8px 8px 32px -8px rgb(63 125 216 / 35%)
}
16 changes: 1 addition & 15 deletions junior/app/styles/components/challenge/challenge-content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,6 @@
margin: 16px 140px 0;
transition: all 0.4s;

iframe {
min-height: 100%;
}

.challenge-embed-simulator,
.challenge-media__loaded-image,
.challenge-media__placeholder{
padding: var(--pix-spacing-4x);
background-color: var(--pix-neutral-0);
border-radius: 24px;
box-shadow: 0 0 1px 0 var(--pix-primary-500), 8px 8px 32px -8px rgb(63 125 216 / 35%)
}


&__grid-multiple-element {
grid-template-areas:
"illu form"
Expand Down Expand Up @@ -47,7 +33,7 @@
margin: 16px 120px 0;
}

&__questionnaire {
&__form {
display: flex;
justify-content: center;
width: 100%;
Expand Down
11 changes: 0 additions & 11 deletions junior/tests/unit/models/challenge-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,25 @@ module('Unit | Model | Challenge', function (hooks) {
const challenge = store.createRecord('challenge', {
embedUrl: 'https://pix.fr',
embedTitle: 'Amazing Pix Embed',
embedHeight: 800,
});
assert.true(challenge.hasEmbed);
});
test('should be false when embedUrl does not start with "https://"', function (assert) {
const challenge = store.createRecord('challenge', {
embedUrl: 'http://pix.fr',
embedTitle: 'Amazing Pix Embed',
embedHeight: 800,
});
assert.false(challenge.hasEmbed);
});
test('should be false when embedUrl is not provided', function (assert) {
const challenge = store.createRecord('challenge', {
embedTitle: 'Amazing Pix Embed',
embedHeight: 800,
});
assert.false(challenge.hasEmbed);
});
test('should be false when embedTitle is not provided', function (assert) {
const challenge = store.createRecord('challenge', {
embedUrl: 'https://pix.fr',
embedHeight: 800,
});
assert.false(challenge.hasEmbed);
});
test('should be false when embedHeight is not provided', function (assert) {
const challenge = store.createRecord('challenge', {
embedUrl: 'https://pix.fr',
embedTitle: 'Amazing Pix Embed',
});
assert.false(challenge.hasEmbed);
});
Expand Down
2 changes: 1 addition & 1 deletion mon-pix/tests/unit/models/challenge-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ module('Unit | Model | Challenge', function (hooks) {
});
});

module('Computed property #hasEmbedDocument', function (hooks) {
module('Computed property #hasEmbed', function (hooks) {
let embedOptions;

hooks.beforeEach(function () {
Expand Down

0 comments on commit 9335a91

Please sign in to comment.