Skip to content

Commit

Permalink
🎨 feat(junior) show specific mission logo
Browse files Browse the repository at this point in the history
Co-authored-by: rouxxi <[email protected]>
Co-authored-by: Aurelie Crouillebois <[email protected]>
  • Loading branch information
3 people committed Oct 8, 2024
1 parent 8fad487 commit dd6ebfd
Show file tree
Hide file tree
Showing 15 changed files with 138 additions and 116 deletions.
2 changes: 2 additions & 0 deletions api/src/school/domain/models/Mission.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Mission {
constructor({
id,
name,
cardImageUrl,
competenceId,
competenceName,
thematicId,
Expand All @@ -19,6 +20,7 @@ class Mission {
} = {}) {
this.id = id;
this.name = name;
this.cardImageUrl = cardImageUrl;
this.competenceId = competenceId;
this.competenceName = competenceName;
this.thematicId = thematicId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function _toDomain(data, locale) {
return new Mission({
id: data.id,
name: translatedName,
cardImageUrl: data.cardImageUrl,
competenceId: data.competenceId,
thematicId: data.thematicId,
learningObjectives: translatedLearningObjectives,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const serialize = function (missions) {
return new Serializer('missions', {
attributes: [
'name',
'cardImageUrl',
'areaCode',
'validatedObjectives',
'learningObjectives',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,85 @@ describe('Integration | Repository | mission-repository', function () {
});
});
});

describe('#findAllActiveMissions', function () {
context('when there are active missions', function () {
it('should return all active mission', async function () {
// given
const expectedMission = new Mission({
id: 1,
name: 'nameThemaFR1',
competenceId: 'competenceId',
thematicId: 'thematicId',
cardImageUrl: 'super-url',
learningObjectives: 'learningObjectivesi18n',
validatedObjectives: 'validatedObjectivesi18n',
introductionMediaUrl: 'http://monimage.pix.fr',
introductionMediaType: 'image',
introductionMediaAlt: "Alt à l'image",
documentationUrl: 'http://madoc.pix.fr',
content: {
steps: [
{
name: 'step_name_1',
},
],
},
});

mockLearningContent({
missions: [
{
id: 1,
status: 'VALIDATED',
name_i18n: { fr: 'nameThemaFR1' },
competenceId: 'competenceId',
thematicId: 'thematicId',
cardImageUrl: 'super-url',
learningObjectives_i18n: { fr: 'learningObjectivesi18n' },
validatedObjectives_i18n: { fr: 'validatedObjectivesi18n' },
introductionMediaUrl: 'http://monimage.pix.fr',
introductionMediaType: 'image',
introductionMediaAlt: "Alt à l'image",
documentationUrl: 'http://madoc.pix.fr',
content: {
steps: [
{
name_i18n: { fr: 'step_name_1' },
},
],
},
},
{
id: 2,
status: 'INACTIVE',
name_i18n: { fr: 'nameThemaFR1' },
competenceId: 'competenceId',
thematicId: 'thematicId',
cardImageUrl: 'super-url',
learningObjectives_i18n: { fr: 'learningObjectivesi18n' },
validatedObjectives_i18n: { fr: 'validatedObjectivesi18n' },
introductionMediaUrl: 'http://monimage.pix.fr',
introductionMediaType: 'image',
introductionMediaAlt: "Alt à l'image",
documentationUrl: 'http://madoc.pix.fr',
content: {
steps: [
{
name_i18n: { fr: 'step_name_1' },
},
],
},
},
],
});

// when
const missions = await missionRepository.findAllActiveMissions();

// then
expect(missions).to.deep.equal([expectedMission]);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Background from './mission-card-completed-background';
{{/if}}

<div class="mission-icon--completed">
<img src="/images/mission/icon/finished-icon.svg" alt="" />
<img src="/images/mission/icon/pix-junior-logo-white.svg" alt="" aria-hidden="true"/>
</div>
<Background @areaCode={{@areaCode}} />
<div class="completed-mission-card-bottom">
Expand Down
64 changes: 39 additions & 25 deletions junior/app/components/mission-card/mission-card.gjs
Original file line number Diff line number Diff line change
@@ -1,33 +1,47 @@
import Component from '@glimmer/component';

import MissionCardBackGround from './mission-card-background';
<template>
<div class="mission-card__container">
{{#if @missionLabelStatus}}
<div class="status">
<p>{{@missionLabelStatus}}</p>
</div>
{{/if}}
{{#if @displayStartedIcon}}
<div class="started-icon">
<img src="/images/mission/icon/started-icon.svg" alt="" />
</div>
{{/if}}

<div class="mission-icon">
<img src="/images/mission/icon/area-code-{{@areaCode}}.svg" alt="" />
</div>
export default class MissionCard extends Component {
get imageUrl() {
console.log(this.args.cardImageUrl);
return this.args.cardImageUrl ? this.args.cardImageUrl : '/images/mission/icon/pix-junior-logo-white.svg';
}

<MissionCardBackGround @class="area-code-{{@areaCode}}" @areaCode={{@areaCode}} />
get classIcon() {
console.log(this.args.cardImageUrl);
return this.args.cardImageUrl ? 'mission-icon' : 'mission-icon-default';
}
<template>
<div class="mission-card__container">
{{#if @missionLabelStatus}}
<div class="status">
<p>{{@missionLabelStatus}}</p>
</div>
{{/if}}
{{#if @displayStartedIcon}}
<div class="started-icon">
<img src="/images/mission/icon/started-icon.svg" alt="" aria-hidden="true" />
</div>
{{/if}}

<div class="area-code-{{@areaCode}} mission-card-bottom">
<div class="mission-name area-code-{{@areaCode}}">
<p> {{@title}}</p>
<div class={{this.classIcon}}>
<img src={{this.imageUrl}} aria-hidden="true" />
</div>

{{#if @missionButtonLabel}}
<div class="fake-button">
<p>{{@missionButtonLabel}}</p>
<MissionCardBackGround @class="area-code-{{@areaCode}}" @areaCode={{@areaCode}} />

<div class="area-code-{{@areaCode}} mission-card-bottom">
<div class="mission-name area-code-{{@areaCode}}">
<p> {{@title}}</p>
</div>
{{/if}}

{{#if @missionButtonLabel}}
<div class="fake-button">
<p>{{@missionButtonLabel}}</p>
</div>
{{/if}}
</div>
</div>
</div>
</template>
</template>
}
1 change: 1 addition & 0 deletions junior/app/models/mission.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export default class Mission extends Model {
@attr('string') introductionMediaUrl;
@attr('string') introductionMediaType;
@attr('string') introductionMediaAlt;
@attr('string') cardImageUrl;
}
6 changes: 6 additions & 0 deletions junior/app/styles/components/mission-card/card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@
right: 18%;
}

.mission-icon-default {
position: absolute;
top: 100px;
right: 27%;
}

.mission-icon--completed {
position: absolute;
top: 130px;
Expand Down
1 change: 1 addition & 0 deletions junior/app/templates/identified/missions/list.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
@missionButtonLabel={{this.getMissionButtonLabel mission.id}}
@title={{mission.name}}
@areaCode={{mission.areaCode}}
@cardImageUrl={{mission.cardImageUrl}}
@displayStartedIcon={{this.isMissionStarted mission.id}}
/>
{{/if}}
Expand Down
6 changes: 5 additions & 1 deletion junior/app/templates/identified/missions/mission/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
</RobotDialog>
<div class="mission-page__body">

<MissionCard::MissionCard @title={{@model.name}} @areaCode={{@model.areaCode}} />
<MissionCard::MissionCard
@title={{@model.name}}
@cardImageUrl={{@model.cardImageUrl}}
@areaCode={{@model.areaCode}}
/>

<div class="mission-page__details">
<LinkTo @route="identified.missions" class="details-go-back">{{t
Expand Down
27 changes: 0 additions & 27 deletions junior/public/images/mission/icon/area-code-1.svg

This file was deleted.

17 changes: 0 additions & 17 deletions junior/public/images/mission/icon/area-code-2.svg

This file was deleted.

22 changes: 0 additions & 22 deletions junior/public/images/mission/icon/area-code-3.svg

This file was deleted.

Loading

0 comments on commit dd6ebfd

Please sign in to comment.