Skip to content

Commit

Permalink
Improve score explainer positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
otacke committed Sep 3, 2024
1 parent 8fc7300 commit f31ec44
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
9 changes: 3 additions & 6 deletions src/scripts/h5p-dictation-solution.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ class Solution {
}

return result.words.map((word, index) =>
this.createSolutionWordDOM(index, word, result.words.length - 1 !== index));
this.createSolutionWordDOM(index, word)
);
}

/**
Expand All @@ -109,10 +110,9 @@ class Solution {
* @param {string} word.type Status about missing, typo, ...
* @param {string} word.solution Correct spelling of the word.
* @param {string} word.answer User input for this word.
* @param {boolean} [trailingGap] True if wrapper should have trailing gap.
* @returns {HTMLElement} DOM for solution words.
*/
createSolutionWordDOM(index, word, trailingGap = true) {
createSolutionWordDOM(index, word) {
if (this.params.alternateSolution === 'first' && word.type !== 'match' && word.type !== 'typo') {
word.solution = word.solution ? Util.splitWordAlternatives(word.solution)[0] : '';
}
Expand All @@ -127,9 +127,6 @@ class Solution {
wordDOM.classList.add(`h5p-wrapper-${word.type}`);
}

if (trailingGap) {
wordDOM.classList.add('h5p-spacer');
}
wordDOM.setAttribute('tabindex', '-1');
wordDOM.setAttribute('role', 'listitem');

Expand Down
19 changes: 13 additions & 6 deletions src/styles/h5p-dictation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ $border-color_1: #7fb8ff;
z-index: 3;
display: inline-flex;
flex-wrap: wrap;
gap: 0.75em;
padding-right: 1.615384615em;
padding-bottom: .5em;
padding-left: .5em;
Expand Down Expand Up @@ -294,17 +295,23 @@ $border-color_1: #7fb8ff;
}
}

.h5p-spacer {
margin-right: .25em;
.h5p-question-minus-one {
right: -1.1em;
top: -1em;
}

.h5p-question-plus-one {
right: -1.1em;
top: -1em;
}

.h5p-question-plus-one-half {
position: absolute;
width: 1.923076923em;
height: calc(1.923076923em * .638297872);
background-size: 100% 100%;
right: -1.615384615em;
top: -.846153846em;
right: -1.1em;
top: -1em;
z-index: 1;
opacity: 1;
transition: opacity 150ms linear, transform 150ms linear;
Expand All @@ -316,8 +323,8 @@ $border-color_1: #7fb8ff;
width: 1.923076923em;
height: calc(1.923076923em * .638297872);
background-size: 100% 100%;
right: -1.615384615em;
top: -.846153846em;
right: -1.1em;
top: -1em;
z-index: 1;
opacity: 1;
transition: opacity 150ms linear, transform 150ms linear;
Expand Down

0 comments on commit f31ec44

Please sign in to comment.