Skip to content

Commit 8c6db8f

Browse files
authored
VA-523 Implement changes after design review (#78)
* VA-453 Align icons of audio and video play buttons * VA-523 Scroll video modal into view when opened * VA-523 Make video modal more compact when space is limited * VA-523 Prevent warped button caused audio option `fitToWrapper` * VA-523 Add a little bit of padding to compact modals' content
1 parent 0ae7d0b commit 8c6db8f

4 files changed

+44
-8
lines changed

src/scripts/h5p-multi-media-choice-option.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export class MultiMediaChoiceOption {
123123

124124
modal.setAttribute('tabindex', '0');
125125
modal.focus();
126+
modal.scrollIntoView({ behavior: 'smooth', block: 'center' });
126127
event.stopPropagation();
127128
});
128129

@@ -209,8 +210,8 @@ export class MultiMediaChoiceOption {
209210
*/
210211
createVideoPlayer(lastFocus) {
211212
const modal = createElement({type: 'div', classList: ['h5p-multi-media-modal'], attributes: {'aria-modal': 'true'}});
212-
const modalContainer = createElement({type: 'div', classList: ['modal-container']});
213-
const modalContent = createElement({type: 'div', classList: ['modal-content']});
213+
const modalContainer = createElement({type: 'div', classList: ['h5p-multi-media-choice-modal-container']});
214+
const modalContent = createElement({type: 'div', classList: ['h5p-multi-media-choice-modal-content']});
214215
const closeButton = createElement({type: 'button', classList: ['modal-close-button'], attributes: {'aria-label': this.closeModalText}});
215216
const cross = createElement({type: 'div', classList: ['icon-cross']});
216217

src/scripts/h5p-multi-media-choice.js

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ export default class MultiMediaChoice extends H5P.Question {
2323
// Default values are extended
2424
this.params = Util.extendParams(params);
2525

26+
// Override subcontent params
27+
for (const option of this.params.options) {
28+
if (option.media?.library?.includes('H5P.Audio')) {
29+
option.media.params.fitToWrapper = false; // VA-523: prevent warped button
30+
}
31+
}
32+
2633
this.content = new MultiMediaChoiceContent(
2734
this.params,
2835
contentId,

src/styles/_sizes.scss

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ $option-icon: 2.8em;
99
$minimum-auto-scaling-size: 901px;
1010
$scaling-interval: 300px;
1111
$button-size: 4rem;
12+
$button-size-small: 2.5rem;

src/styles/h5p-multi-media-choice.scss

+33-6
Original file line numberDiff line numberDiff line change
@@ -208,16 +208,18 @@
208208
align-items: center;
209209
justify-content: center;
210210

211-
.modal-container {
211+
.h5p-multi-media-choice-modal-container {
212212
position: relative;
213213
width: 100%;
214214
display: flex;
215215
justify-content: center;
216216
align-items: center;
217217
max-width: 100%;
218218
max-height: 100%;
219+
container-name: h5p-mmc-modal-container;
220+
container-type: inline-size;
219221

220-
.modal-content {
222+
.h5p-multi-media-choice-modal-content {
221223
position: relative;
222224
background-color: white;
223225
padding: 1.2rem;
@@ -229,6 +231,12 @@
229231
box-shadow: none;
230232
max-height: 100%;
231233

234+
@container h5p-mmc-modal-container (width < 480px) {
235+
padding: 3px;
236+
width: 100%;
237+
max-width: 100%;
238+
}
239+
232240
.modal-close-button {
233241
background-color: #ffffff;
234242
position: absolute;
@@ -245,13 +253,25 @@
245253
justify-content: center;
246254
align-items: center;
247255

256+
@container h5p-mmc-modal-container (width < 480px) {
257+
right: 0;
258+
height: $button-size-small;
259+
width: $button-size-small;
260+
}
261+
248262
.icon-cross {
249-
width: 4rem;
250-
height: 4rem;
263+
width: $button-size;
264+
height: $button-size;
251265
background-size: 3.5rem;
252266
background-image: url(../../assets/x-close.svg);
253267
background-repeat: no-repeat;
254-
background-position: -0.1rem 0.2rem;
268+
background-position: center;
269+
270+
@container h5p-mmc-modal-container (width < 480px) {
271+
height: $button-size-small;
272+
width: $button-size-small;
273+
background-size: 2rem;
274+
}
255275
}
256276
}
257277
}
@@ -282,7 +302,7 @@
282302
right: 0;
283303
margin: 0.5em;
284304
z-index: 1;
285-
305+
286306
.h5p-audio-minimal-button {
287307
width: $button-size;
288308
height: $button-size;
@@ -298,6 +318,13 @@
298318
.h5p-audio-minimal-button::before {
299319
font-size: math.div($button-size, 2);
300320
}
321+
322+
/* Make H5P.Audio's play button icon match our video play button's icon */
323+
.h5p-audio-minimal-play-paused::before {
324+
position: relative;
325+
left: 3px;
326+
font-size: 2.125rem;
327+
}
301328
}
302329

303330
.h5p-multi-media-content-media-button-centered {

0 commit comments

Comments
 (0)