Skip to content

Commit

Permalink
[FEATURE] Afficher la légende et la licence d'une image dans un module (
Browse files Browse the repository at this point in the history
  • Loading branch information
pix-service-auto-merge authored Jan 15, 2025
2 parents 9275d61 + 320bc48 commit 6e2c472
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
16 changes: 15 additions & 1 deletion mon-pix/app/components/module/element/_image.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.element-image {
&__container {
margin: 0 auto var(--pix-spacing-3x) auto;
margin: 0 auto;
}
}

Expand All @@ -11,4 +11,18 @@
object-fit: contain;
border-radius: var(--modulix-radius-s);
}

&__caption {
@extend %pix-body-s;

margin-top: var(--pix-spacing-1x);
color: rgb(var(--pix-neutral-800-inline), 0.9);
}

&__licence {
@extend %pix-body-xs;

margin-left: var(--pix-spacing-1x);
color: var(--pix-neutral-500);
}
}
9 changes: 6 additions & 3 deletions mon-pix/app/components/module/element/image.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ export default class ModulixImageElement extends Component {

<template>
<div class="element-image">
<div class="element-image__container">
<figure class="element-image__container">
<img class="element-image-container__image" alt={{@image.alt}} src={{@image.url}} />
</div>
<figcaption class="element-image-container__caption">{{@image.legend}}<span
class="element-image-container__licence"
>{{@image.licence}}</span></figcaption>
</figure>
{{#if this.hasAlternativeText}}
<PixButton @variant="tertiary" @triggerAction={{this.showModal}}>
<PixButton class="element-image__button" @variant="tertiary" @triggerAction={{this.showModal}}>
{{t "pages.modulix.buttons.element.alternativeText"}}
</PixButton>
<PixModal
Expand Down
4 changes: 4 additions & 0 deletions mon-pix/tests/integration/components/module/image_test.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ module('Integration | Component | Module | Image', function (hooks) {
url,
alt: 'alt text',
alternativeText: 'alternative instruction',
legend: 'je suis une légende',
licence: 'Je suis une licence',
};

// when
Expand All @@ -28,6 +30,8 @@ module('Integration | Component | Module | Image', function (hooks) {
assert.strictEqual(findAll('.element-image').length, 1);
assert.ok(screen.getByRole('img', { name: 'alt text' }).hasAttribute('src', url));
assert.ok(screen.getByRole('button', { name: "Afficher l'alternative textuelle" }));
assert.dom(screen.getByText(imageElement.legend)).exists();
assert.dom(screen.getByText(imageElement.licence)).exists();
});

test('should be able to use the modal for alternative instruction', async function (assert) {
Expand Down

0 comments on commit 6e2c472

Please sign in to comment.