@micromag/screen-quiz 0.3.637 → 0.3.643
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/css/styles.css +1 -1
- package/es/index.js +134 -52
- package/package.json +2 -2
package/assets/css/styles.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
.micromag-screen-quiz-answers-emptyAnswer{border:2px dashed #343434;color:#343434;margin:5px auto}.micromag-screen-quiz-answers-button:focus-visible{outline:3px solid #a13dff;outline-offset:4px}.micromag-screen-quiz-answers-container,.micromag-screen-quiz-answers-items{position:relative}.micromag-screen-quiz-answers-emptyAnswer{font-size:.75em;height:40px;margin:0 auto;width:100%}.micromag-screen-quiz-answers-item{margin:0;padding:0;position:relative;-webkit-transition:opacity .6s ease-out;transition:opacity .6s ease-out}.micromag-screen-quiz-answers-isPlaceholder .micromag-screen-quiz-answers-item{padding:1px 0}.micromag-screen-quiz-answers-item.micromag-screen-quiz-answers-userAnswer{opacity:1!important}.micromag-screen-quiz-answers-item.micromag-screen-quiz-answers-otherAnswer{opacity:.6!important}.micromag-screen-quiz-answers-item.micromag-screen-quiz-answers-withoutOpacity{opacity:1!important}.micromag-screen-quiz-answers-button{color:#fff;padding:10px;position:relative;width:100%}.micromag-screen-quiz-answers-button:disabled{opacity:1;pointer-events:none}.micromag-screen-quiz-answers-withIcon .micromag-screen-quiz-answers-button{padding-left:42px;padding-right:42px}.micromag-screen-quiz-answers-resultIcon{display:-ms-flexbox;display:flex;left:5px;position:absolute;top:50%;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;background-color:#ff2945;border:2px solid #1c1c1c;border-radius:50%;height:32px;justify-content:center;margin-top:-16px;opacity:0;padding:5px;-webkit-transition:opacity .15s ease;transition:opacity .15s ease;width:32px}.micromag-screen-quiz-answers-answered .micromag-screen-quiz-answers-resultIcon{opacity:1}.micromag-screen-quiz-answers-rightAnswer .micromag-screen-quiz-answers-resultIcon{background-color:#0ed88f}.micromag-screen-quiz-answers-resultIcon .micromag-screen-quiz-answers-faIcon{display:block}.micromag-screen-quiz-answers-itemContent{padding:5px 0}
|
|
2
2
|
.micromag-screen-quiz-question-container .micromag-screen-quiz-question-emptyQuestion,.micromag-screen-quiz-question-container .micromag-screen-quiz-question-emptyResult{border:2px dashed #343434;color:#343434;margin:5px auto}.micromag-screen-quiz-question-container .micromag-screen-quiz-question-question{margin-bottom:10px}.micromag-screen-quiz-question-container .micromag-screen-quiz-question-index{display:block;margin-bottom:1em;text-align:center;width:100%}.micromag-screen-quiz-question-container .micromag-screen-quiz-question-result{opacity:0;pointer-events:none;position:absolute;-webkit-transition:opacity .5s ease;transition:opacity .5s ease;-webkit-transition-delay:.3s;transition-delay:.3s}.micromag-screen-quiz-question-container .micromag-screen-quiz-question-resultContent{padding:20px 0}.micromag-screen-quiz-question-container .micromag-screen-quiz-question-emptyQuestion,.micromag-screen-quiz-question-container .micromag-screen-quiz-question-emptyResult{margin:0 auto;width:100%}.micromag-screen-quiz-question-container .micromag-screen-quiz-question-emptyQuestion{height:60px;margin-bottom:10px}.micromag-screen-quiz-question-container .micromag-screen-quiz-question-emptyResult{height:100px}.micromag-screen-quiz-question-container.micromag-screen-quiz-question-resultVisible .micromag-screen-quiz-question-result{opacity:1;pointer-events:all;position:relative}.micromag-screen-quiz-question-container.micromag-screen-quiz-question-isPlaceholder{padding:10px}.micromag-screen-quiz-question-container.micromag-screen-quiz-question-isPlaceholder .micromag-screen-quiz-question-index{color:hsla(0,0%,100%,.6);font-size:8px;mix-blend-mode:difference}
|
|
3
|
-
.micromag-screen-quiz-container .micromag-screen-quiz-background{height:100%;left:0;position:absolute;top:0;width:100%}.micromag-screen-quiz-container{height:100%;overflow:hidden;position:relative;width:100%}.micromag-screen-quiz-disabled.micromag-screen-quiz-container{overflow:hidden;pointer-events:none}.micromag-screen-quiz-hidden.micromag-screen-quiz-container{display:none;visibility:hidden}.micromag-screen-quiz-placeholder.micromag-screen-quiz-container .micromag-screen-quiz-content{padding:6px;position:relative}.micromag-screen-quiz-container .micromag-screen-quiz-background{z-index:0}.micromag-screen-quiz-container .micromag-screen-quiz-content{z-index:2}.micromag-screen-quiz-container.micromag-screen-quiz-disabled{pointer-events:none}.micromag-screen-quiz-reset{border:0;padding:10px;position:absolute;right:0;top:0;-webkit-transform-origin:center;-ms-transform-origin:center;transform-origin:center;-webkit-transition:opacity .15s ease-out,-webkit-transform .15s ease-out;transition:opacity .15s ease-out,-webkit-transform .15s ease-out;transition:opacity .15s ease-out,transform .15s ease-out;transition:opacity .15s ease-out,transform .15s ease-out,-webkit-transform .15s ease-out;z-index:1000}.micromag-screen-quiz-reset:hover{border:0;opacity:.8}.micromag-screen-quiz-reset:hover:active{-webkit-transform:rotate(30deg);-ms-transform:rotate(30deg);transform:rotate(30deg)}.micromag-screen-quiz-points{color:#fff;left:0;padding:10px;position:absolute;top:0;z-index:1000}.micromag-screen-quiz-layout{bottom:0;left:0;position:absolute;right:0;top:0}.micromag-screen-quiz-header{left:0;position:absolute;top:0;-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out;width:100%}.micromag-screen-quiz-header.micromag-screen-quiz-disabled{opacity:0;pointer-events:none}.micromag-screen-quiz-footer{bottom:0;left:0;position:absolute;-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out;width:100%}.micromag-screen-quiz-footer a{padding:0}.micromag-screen-quiz-footer.micromag-screen-quiz-disabled{opacity:0;pointer-events:none}.micromag-screen-quiz-transition{bottom:0;left:0;position:absolute;right:0;top:0}.micromag-screen-quiz-intro,.micromag-screen-quiz-question,.micromag-screen-quiz-results{overflow:hidden}.micromag-screen-quiz-intro.micromag-screen-quiz-enter,.micromag-screen-quiz-question.micromag-screen-quiz-enter,.micromag-screen-quiz-results.micromag-screen-quiz-enter{-webkit-transform:translateX(100%);-ms-transform:translateX(100%);transform:translateX(100%)}.micromag-screen-quiz-left .micromag-screen-quiz-intro.micromag-screen-quiz-enter,.micromag-screen-quiz-left .micromag-screen-quiz-question.micromag-screen-quiz-enter,.micromag-screen-quiz-left .micromag-screen-quiz-results.micromag-screen-quiz-enter{-webkit-transform:translateX(-100%);-ms-transform:translateX(-100%);transform:translateX(-100%)}.micromag-screen-quiz-intro.micromag-screen-quiz-enterActive,.micromag-screen-quiz-left .micromag-screen-quiz-intro.micromag-screen-quiz-enterActive,.micromag-screen-quiz-left .micromag-screen-quiz-question.micromag-screen-quiz-enterActive,.micromag-screen-quiz-left .micromag-screen-quiz-results.micromag-screen-quiz-enterActive,.micromag-screen-quiz-question.micromag-screen-quiz-enterActive,.micromag-screen-quiz-results.micromag-screen-quiz-enterActive{left:0;min-height:100%;position:absolute;top:0;-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0);-webkit-transition:-webkit-transform 1s ease;transition:-webkit-transform 1s ease;transition:transform 1s ease;transition:transform 1s ease,-webkit-transform 1s ease;width:100%}.micromag-screen-quiz-intro.micromag-screen-quiz-exit,.micromag-screen-quiz-question.micromag-screen-quiz-exit,.micromag-screen-quiz-results.micromag-screen-quiz-exit{-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0)}.micromag-screen-quiz-intro.micromag-screen-quiz-exitActive,.micromag-screen-quiz-question.micromag-screen-quiz-exitActive,.micromag-screen-quiz-results.micromag-screen-quiz-exitActive{left:0;min-height:100%;position:absolute;top:0;-webkit-transform:translateX(-100%);-ms-transform:translateX(-100%);transform:translateX(-100%);-webkit-transition:-webkit-transform 1s ease;transition:-webkit-transform 1s ease;transition:transform 1s ease;transition:transform 1s ease,-webkit-transform 1s ease;width:100%}.micromag-screen-quiz-left .micromag-screen-quiz-intro.micromag-screen-quiz-exitActive,.micromag-screen-quiz-left .micromag-screen-quiz-question.micromag-screen-quiz-exitActive,.micromag-screen-quiz-left .micromag-screen-quiz-results.micromag-screen-quiz-exitActive{-webkit-transform:translateX(100%);-ms-transform:translateX(100%);transform:translateX(100%)}.micromag-screen-quiz-background.micromag-screen-quiz-enter{opacity:0}.micromag-screen-quiz-background.micromag-screen-quiz-enterActive{opacity:1;-webkit-transition:opacity 1s ease;transition:opacity 1s ease;z-index:1}.micromag-screen-quiz-background.micromag-screen-quiz-exit{opacity:1}.micromag-screen-quiz-background.micromag-screen-quiz-exitActive{opacity:0;-webkit-transition:opacity 1s ease;transition:opacity 1s ease;z-index:0}
|
|
3
|
+
.micromag-screen-quiz-container .micromag-screen-quiz-background{height:100%;left:0;position:absolute;top:0;width:100%}.micromag-screen-quiz-container{height:100%;overflow:hidden;position:relative;width:100%}.micromag-screen-quiz-disabled.micromag-screen-quiz-container{overflow:hidden;pointer-events:none}.micromag-screen-quiz-hidden.micromag-screen-quiz-container{display:none;visibility:hidden}.micromag-screen-quiz-placeholder.micromag-screen-quiz-container .micromag-screen-quiz-content{padding:6px;position:relative}.micromag-screen-quiz-nextButton:focus-visible{outline:3px solid #a13dff;outline-offset:4px}.micromag-screen-quiz-container .micromag-screen-quiz-background{z-index:0}.micromag-screen-quiz-container .micromag-screen-quiz-content{z-index:2}.micromag-screen-quiz-container.micromag-screen-quiz-disabled{pointer-events:none}.micromag-screen-quiz-reset{background-color:transparent;border:0;padding:10px;position:absolute;right:0;top:0;-webkit-transform-origin:center;-ms-transform-origin:center;transform-origin:center;-webkit-transition:opacity .15s ease-out,-webkit-transform .15s ease-out;transition:opacity .15s ease-out,-webkit-transform .15s ease-out;transition:opacity .15s ease-out,transform .15s ease-out;transition:opacity .15s ease-out,transform .15s ease-out,-webkit-transform .15s ease-out;z-index:1000}.micromag-screen-quiz-reset:hover{border:0;opacity:.8}.micromag-screen-quiz-reset:hover:active{-webkit-transform:rotate(30deg);-ms-transform:rotate(30deg);transform:rotate(30deg)}.micromag-screen-quiz-points{color:#fff;left:0;padding:10px;position:absolute;top:0;z-index:1000}.micromag-screen-quiz-layout{bottom:0;left:0;position:absolute;right:0;top:0}.micromag-screen-quiz-header{left:0;position:absolute;top:0;-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out;width:100%}.micromag-screen-quiz-header.micromag-screen-quiz-disabled{opacity:0;pointer-events:none}.micromag-screen-quiz-footer{bottom:0;left:0;position:absolute;-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out;width:100%}.micromag-screen-quiz-footer a{padding:0}.micromag-screen-quiz-footer.micromag-screen-quiz-disabled{opacity:0;pointer-events:none}.micromag-screen-quiz-transition{bottom:0;left:0;position:absolute;right:0;top:0}.micromag-screen-quiz-intro,.micromag-screen-quiz-nextButton,.micromag-screen-quiz-question,.micromag-screen-quiz-results{overflow:hidden}.micromag-screen-quiz-intro.micromag-screen-quiz-enter,.micromag-screen-quiz-nextButton.micromag-screen-quiz-enter,.micromag-screen-quiz-question.micromag-screen-quiz-enter,.micromag-screen-quiz-results.micromag-screen-quiz-enter{-webkit-transform:translateX(100%);-ms-transform:translateX(100%);transform:translateX(100%)}.micromag-screen-quiz-left .micromag-screen-quiz-intro.micromag-screen-quiz-enter,.micromag-screen-quiz-left .micromag-screen-quiz-nextButton.micromag-screen-quiz-enter,.micromag-screen-quiz-left .micromag-screen-quiz-question.micromag-screen-quiz-enter,.micromag-screen-quiz-left .micromag-screen-quiz-results.micromag-screen-quiz-enter{-webkit-transform:translateX(-100%);-ms-transform:translateX(-100%);transform:translateX(-100%)}.micromag-screen-quiz-intro.micromag-screen-quiz-enterActive,.micromag-screen-quiz-left .micromag-screen-quiz-intro.micromag-screen-quiz-enterActive,.micromag-screen-quiz-left .micromag-screen-quiz-nextButton.micromag-screen-quiz-enterActive,.micromag-screen-quiz-left .micromag-screen-quiz-question.micromag-screen-quiz-enterActive,.micromag-screen-quiz-left .micromag-screen-quiz-results.micromag-screen-quiz-enterActive,.micromag-screen-quiz-nextButton.micromag-screen-quiz-enterActive,.micromag-screen-quiz-question.micromag-screen-quiz-enterActive,.micromag-screen-quiz-results.micromag-screen-quiz-enterActive{left:0;min-height:100%;position:absolute;top:0;-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0);-webkit-transition:-webkit-transform 1s ease;transition:-webkit-transform 1s ease;transition:transform 1s ease;transition:transform 1s ease,-webkit-transform 1s ease;width:100%}.micromag-screen-quiz-intro.micromag-screen-quiz-exit,.micromag-screen-quiz-nextButton.micromag-screen-quiz-exit,.micromag-screen-quiz-question.micromag-screen-quiz-exit,.micromag-screen-quiz-results.micromag-screen-quiz-exit{-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0)}.micromag-screen-quiz-intro.micromag-screen-quiz-exitActive,.micromag-screen-quiz-nextButton.micromag-screen-quiz-exitActive,.micromag-screen-quiz-question.micromag-screen-quiz-exitActive,.micromag-screen-quiz-results.micromag-screen-quiz-exitActive{left:0;min-height:100%;position:absolute;top:0;-webkit-transform:translateX(-100%);-ms-transform:translateX(-100%);transform:translateX(-100%);-webkit-transition:-webkit-transform 1s ease;transition:-webkit-transform 1s ease;transition:transform 1s ease;transition:transform 1s ease,-webkit-transform 1s ease;width:100%}.micromag-screen-quiz-left .micromag-screen-quiz-intro.micromag-screen-quiz-exitActive,.micromag-screen-quiz-left .micromag-screen-quiz-nextButton.micromag-screen-quiz-exitActive,.micromag-screen-quiz-left .micromag-screen-quiz-question.micromag-screen-quiz-exitActive,.micromag-screen-quiz-left .micromag-screen-quiz-results.micromag-screen-quiz-exitActive{-webkit-transform:translateX(100%);-ms-transform:translateX(100%);transform:translateX(100%)}.micromag-screen-quiz-nextButton{color:#fff;padding:10px;position:relative;width:100%}.micromag-screen-quiz-nextButton:disabled{opacity:1;pointer-events:none}.micromag-screen-quiz-withIcon .micromag-screen-quiz-nextButton{padding-left:42px;padding-right:42px}.micromag-screen-quiz-background.micromag-screen-quiz-enter{opacity:0}.micromag-screen-quiz-background.micromag-screen-quiz-enterActive{opacity:1;-webkit-transition:opacity 1s ease;transition:opacity 1s ease;z-index:1}.micromag-screen-quiz-background.micromag-screen-quiz-exit{opacity:1}.micromag-screen-quiz-background.micromag-screen-quiz-exitActive{opacity:0;-webkit-transition:opacity 1s ease;transition:opacity 1s ease;z-index:0}
|
|
4
4
|
.micromag-screen-quiz-results-container .micromag-screen-quiz-results-emptyDescription,.micromag-screen-quiz-results-container .micromag-screen-quiz-results-emptyTitle{border:2px dashed #343434;color:#343434;margin:5px auto}.micromag-screen-quiz-results-container .micromag-screen-quiz-results-title{margin-bottom:10px}.micromag-screen-quiz-results-container .micromag-screen-quiz-results-emptyDescription,.micromag-screen-quiz-results-container .micromag-screen-quiz-results-emptyTitle{margin:0 auto;width:100%}.micromag-screen-quiz-results-container .micromag-screen-quiz-results-emptyTitle{height:60px}.micromag-screen-quiz-results-container .micromag-screen-quiz-results-emptyDescription{height:100px}.micromag-screen-quiz-results-container.micromag-screen-quiz-results-isPlaceholder{padding:10px}
|
|
5
5
|
.micromag-screen-quiz-title-container .micromag-screen-quiz-title-emptyDescription,.micromag-screen-quiz-title-container .micromag-screen-quiz-title-emptyTitle{border:2px dashed #343434;color:#343434;margin:5px auto}.micromag-screen-quiz-title-container .micromag-screen-quiz-title-description,.micromag-screen-quiz-title-container .micromag-screen-quiz-title-title{margin-bottom:10px}.micromag-screen-quiz-title-container .micromag-screen-quiz-title-emptyDescription,.micromag-screen-quiz-title-container .micromag-screen-quiz-title-emptyTitle{margin:0 auto 10px;width:100%}.micromag-screen-quiz-title-container .micromag-screen-quiz-title-emptyTitle{height:60px}.micromag-screen-quiz-title-container .micromag-screen-quiz-title-emptyDescription{height:100px}.micromag-screen-quiz-title-container.micromag-screen-quiz-title-isPlaceholder{padding:10px}
|
package/es/index.js
CHANGED
|
@@ -556,7 +556,7 @@ var Question = function Question(_ref) {
|
|
|
556
556
|
Question.propTypes = propTypes$4;
|
|
557
557
|
Question.defaultProps = defaultProps$4;
|
|
558
558
|
|
|
559
|
-
var styles$2 = {"container":"micromag-screen-quiz-container","background":"micromag-screen-quiz-background","disabled":"micromag-screen-quiz-disabled","hidden":"micromag-screen-quiz-hidden","placeholder":"micromag-screen-quiz-placeholder","content":"micromag-screen-quiz-content","reset":"micromag-screen-quiz-reset","points":"micromag-screen-quiz-points","layout":"micromag-screen-quiz-layout","header":"micromag-screen-quiz-header","footer":"micromag-screen-quiz-footer","transition":"micromag-screen-quiz-transition","question":"micromag-screen-quiz-question","results":"micromag-screen-quiz-results","intro":"micromag-screen-quiz-intro","enter":"micromag-screen-quiz-enter","left":"micromag-screen-quiz-left","enterActive":"micromag-screen-quiz-enterActive","exit":"micromag-screen-quiz-exit","exitActive":"micromag-screen-quiz-exitActive"};
|
|
559
|
+
var styles$2 = {"container":"micromag-screen-quiz-container","background":"micromag-screen-quiz-background","disabled":"micromag-screen-quiz-disabled","hidden":"micromag-screen-quiz-hidden","placeholder":"micromag-screen-quiz-placeholder","content":"micromag-screen-quiz-content","nextButton":"micromag-screen-quiz-nextButton","reset":"micromag-screen-quiz-reset","points":"micromag-screen-quiz-points","layout":"micromag-screen-quiz-layout","header":"micromag-screen-quiz-header","footer":"micromag-screen-quiz-footer","transition":"micromag-screen-quiz-transition","question":"micromag-screen-quiz-question","results":"micromag-screen-quiz-results","intro":"micromag-screen-quiz-intro","enter":"micromag-screen-quiz-enter","left":"micromag-screen-quiz-left","enterActive":"micromag-screen-quiz-enterActive","exit":"micromag-screen-quiz-exit","exitActive":"micromag-screen-quiz-exitActive","withIcon":"micromag-screen-quiz-withIcon"};
|
|
560
560
|
|
|
561
561
|
var propTypes$3 = {
|
|
562
562
|
id: PropTypes.string,
|
|
@@ -1080,6 +1080,7 @@ var propTypes = {
|
|
|
1080
1080
|
background: PropTypes$1.backgroundElement,
|
|
1081
1081
|
introButton: PropTypes$1.textElement,
|
|
1082
1082
|
introBackground: PropTypes$1.backgroundElement,
|
|
1083
|
+
nextButton: PropTypes$1.textElement,
|
|
1083
1084
|
header: PropTypes$1.header,
|
|
1084
1085
|
footer: PropTypes$1.footer,
|
|
1085
1086
|
current: PropTypes.bool,
|
|
@@ -1110,6 +1111,7 @@ var defaultProps = {
|
|
|
1110
1111
|
background: null,
|
|
1111
1112
|
introButton: null,
|
|
1112
1113
|
introBackground: null,
|
|
1114
|
+
nextButton: null,
|
|
1113
1115
|
header: null,
|
|
1114
1116
|
footer: null,
|
|
1115
1117
|
current: true,
|
|
@@ -1140,6 +1142,7 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1140
1142
|
background = _ref.background,
|
|
1141
1143
|
introBackground = _ref.introBackground,
|
|
1142
1144
|
introButton = _ref.introButton,
|
|
1145
|
+
nextButton = _ref.nextButton,
|
|
1143
1146
|
header = _ref.header,
|
|
1144
1147
|
footer = _ref.footer,
|
|
1145
1148
|
current = _ref.current,
|
|
@@ -1181,9 +1184,9 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1181
1184
|
var transitionDisabled = isStatic || isCapture || isPlaceholder || isPreview || isEdit;
|
|
1182
1185
|
var backgroundPlaying = current && (isView || isEdit);
|
|
1183
1186
|
var backgroundShouldLoad = current || active;
|
|
1187
|
+
var hasButtonText = isTextFilled(nextButton);
|
|
1184
1188
|
|
|
1185
1189
|
// Call to Action
|
|
1186
|
-
|
|
1187
1190
|
var hasHeader = isHeaderFilled(header);
|
|
1188
1191
|
var hasFooter = isFooterFilled(footer);
|
|
1189
1192
|
var footerProps = getFooterProps(footer, {
|
|
@@ -1230,18 +1233,6 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1230
1233
|
answerIndex: answerIndex
|
|
1231
1234
|
});
|
|
1232
1235
|
}, [userAnswers, setUserAnswers, trackScreenEvent, questions, questionIndex]);
|
|
1233
|
-
var onAnswerTransitionEnd = useCallback(function () {
|
|
1234
|
-
if (isEdit) {
|
|
1235
|
-
return;
|
|
1236
|
-
}
|
|
1237
|
-
var nextIndex = questionIndex + 1;
|
|
1238
|
-
var questionsCount = questions.length;
|
|
1239
|
-
if (nextIndex < questionsCount) {
|
|
1240
|
-
setQuestionIndex(nextIndex);
|
|
1241
|
-
} else if (nextIndex === questionsCount) {
|
|
1242
|
-
setQuestionIndex('results');
|
|
1243
|
-
}
|
|
1244
|
-
}, [questions, questionIndex, setQuestionIndex, isEdit]);
|
|
1245
1236
|
var onClickIntroButton = useCallback(function () {
|
|
1246
1237
|
setQuestionIndex(0);
|
|
1247
1238
|
}, [setQuestionIndex]);
|
|
@@ -1252,24 +1243,49 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1252
1243
|
}, [isEdit, current, userAnswers, setUserAnswers]);
|
|
1253
1244
|
var hasQuestions = questions !== null && questions.length > 0;
|
|
1254
1245
|
var currentQuestion = hasQuestions ? questions[questionIndex] || {} : {};
|
|
1255
|
-
var
|
|
1256
|
-
text =
|
|
1257
|
-
|
|
1258
|
-
answers =
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1246
|
+
var _ref4 = currentQuestion || {},
|
|
1247
|
+
_ref4$text = _ref4.text,
|
|
1248
|
+
text = _ref4$text === undefined ? null : _ref4$text,
|
|
1249
|
+
_ref4$answers = _ref4.answers,
|
|
1250
|
+
answers = _ref4$answers === undefined ? [] : _ref4$answers,
|
|
1251
|
+
_ref4$background = _ref4.background,
|
|
1252
|
+
questionBackground = _ref4$background === undefined ? null : _ref4$background,
|
|
1253
|
+
_ref4$layout = _ref4.layout,
|
|
1254
|
+
questionLayout = _ref4$layout === undefined ? null : _ref4$layout,
|
|
1255
|
+
_ref4$result = _ref4.result,
|
|
1256
|
+
questionResult = _ref4$result === undefined ? null : _ref4$result,
|
|
1257
|
+
_ref4$resultImage = _ref4.resultImage,
|
|
1258
|
+
questionResultImage = _ref4$resultImage === undefined ? null : _ref4$resultImage;
|
|
1263
1259
|
var currentAnsweredIndex = userAnswers !== null && typeof userAnswers[questionIndex] !== 'undefined' ? userAnswers[questionIndex] : null;
|
|
1260
|
+
var answer = currentAnsweredIndex !== null && typeof answers[currentAnsweredIndex] !== 'undefined' ? answers[currentAnsweredIndex] : null;
|
|
1261
|
+
var _ref5 = answer || {},
|
|
1262
|
+
_ref5$customAnswerLab = _ref5.customAnswerLabel,
|
|
1263
|
+
customAnswerLabel = _ref5$customAnswerLab === undefined ? null : _ref5$customAnswerLab;
|
|
1264
|
+
var hasResult = questionResult !== null || questionResultImage !== null || customAnswerLabel !== null;
|
|
1265
|
+
|
|
1266
|
+
// console.log('hasResult', hasResult, questionResult, questionResultImage, customAnswerLabel);
|
|
1267
|
+
|
|
1268
|
+
var onNextSlide = useCallback(function () {
|
|
1269
|
+
if (isEdit) {
|
|
1270
|
+
return;
|
|
1271
|
+
}
|
|
1272
|
+
var nextIndex = questionIndex + 1;
|
|
1273
|
+
var questionsCount = questions.length;
|
|
1274
|
+
if (nextIndex < questionsCount) {
|
|
1275
|
+
setQuestionIndex(nextIndex);
|
|
1276
|
+
} else if (nextIndex === questionsCount) {
|
|
1277
|
+
setQuestionIndex('results');
|
|
1278
|
+
}
|
|
1279
|
+
}, [questions, questionIndex, setQuestionIndex, isEdit]);
|
|
1264
1280
|
var currentPoints = useMemo(function () {
|
|
1265
1281
|
return userAnswers !== null ? Object.keys(userAnswers).reduce(function (totalPoints, answerQuestionIndex) {
|
|
1266
|
-
var
|
|
1267
|
-
|
|
1268
|
-
questionAnswers =
|
|
1282
|
+
var _ref6 = questions !== null ? questions[answerQuestionIndex] || {} : {},
|
|
1283
|
+
_ref6$answers = _ref6.answers,
|
|
1284
|
+
questionAnswers = _ref6$answers === undefined ? [] : _ref6$answers;
|
|
1269
1285
|
var answerIndex = userAnswers[answerQuestionIndex];
|
|
1270
|
-
var
|
|
1271
|
-
|
|
1272
|
-
points =
|
|
1286
|
+
var _ref7 = questionAnswers[answerIndex] || {},
|
|
1287
|
+
_ref7$points = _ref7.points,
|
|
1288
|
+
points = _ref7$points === undefined ? 0 : _ref7$points;
|
|
1273
1289
|
return points + totalPoints;
|
|
1274
1290
|
}, 0) : 0;
|
|
1275
1291
|
}, [userAnswers, questions]);
|
|
@@ -1283,30 +1299,30 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1283
1299
|
if (stateId === 'results') {
|
|
1284
1300
|
return (results || [])[parseInt(stateIndex, 10)] || null;
|
|
1285
1301
|
}
|
|
1286
|
-
return (results || []).sort(function (
|
|
1287
|
-
var
|
|
1288
|
-
pointsA =
|
|
1289
|
-
var
|
|
1290
|
-
pointsB =
|
|
1302
|
+
return (results || []).sort(function (_ref8, _ref9) {
|
|
1303
|
+
var _ref8$points = _ref8.points,
|
|
1304
|
+
pointsA = _ref8$points === undefined ? 0 : _ref8$points;
|
|
1305
|
+
var _ref9$points = _ref9.points,
|
|
1306
|
+
pointsB = _ref9$points === undefined ? 0 : _ref9$points;
|
|
1291
1307
|
if (pointsA === pointsB) {
|
|
1292
1308
|
return 0;
|
|
1293
1309
|
}
|
|
1294
1310
|
return pointsA > pointsB ? 1 : -1;
|
|
1295
1311
|
}).reduce(function (lastResult, result) {
|
|
1296
|
-
var
|
|
1297
|
-
|
|
1298
|
-
lastPoints =
|
|
1299
|
-
var
|
|
1300
|
-
|
|
1301
|
-
points =
|
|
1312
|
+
var _ref10 = lastResult || {},
|
|
1313
|
+
_ref10$points = _ref10.points,
|
|
1314
|
+
lastPoints = _ref10$points === undefined ? 0 : _ref10$points;
|
|
1315
|
+
var _ref11 = result || {},
|
|
1316
|
+
_ref11$points = _ref11.points,
|
|
1317
|
+
points = _ref11$points === undefined ? 0 : _ref11$points;
|
|
1302
1318
|
return currentPoints >= (lastPoints || 0) && currentPoints >= points ? result : lastResult;
|
|
1303
1319
|
}, null);
|
|
1304
1320
|
}, [isResults, results, currentPoints, stateId, stateIndex]);
|
|
1305
|
-
var
|
|
1306
|
-
|
|
1307
|
-
resultBackground =
|
|
1308
|
-
|
|
1309
|
-
resultLayout =
|
|
1321
|
+
var _ref12 = currentResult || {},
|
|
1322
|
+
_ref12$background = _ref12.background,
|
|
1323
|
+
resultBackground = _ref12$background === undefined ? null : _ref12$background,
|
|
1324
|
+
_ref12$layout = _ref12.layout,
|
|
1325
|
+
resultLayout = _ref12$layout === undefined ? null : _ref12$layout;
|
|
1310
1326
|
var _useQuizCreate = useQuizCreate({
|
|
1311
1327
|
screenId: screenId
|
|
1312
1328
|
}),
|
|
@@ -1366,8 +1382,8 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1366
1382
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
1367
1383
|
scrolledBottom = _useState6[0],
|
|
1368
1384
|
setScrolledBottom = _useState6[1];
|
|
1369
|
-
var onScrolledBottom = useCallback(function (
|
|
1370
|
-
var initial =
|
|
1385
|
+
var onScrolledBottom = useCallback(function (_ref13) {
|
|
1386
|
+
var initial = _ref13.initial;
|
|
1371
1387
|
if (initial) {
|
|
1372
1388
|
trackScreenEvent('scroll', 'Screen');
|
|
1373
1389
|
}
|
|
@@ -1380,9 +1396,9 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1380
1396
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
1381
1397
|
hasScroll = _useState8[0],
|
|
1382
1398
|
setHasScroll = _useState8[1];
|
|
1383
|
-
var onScrollHeightChange = useCallback(function (
|
|
1384
|
-
var
|
|
1385
|
-
canScroll =
|
|
1399
|
+
var onScrollHeightChange = useCallback(function (_ref14) {
|
|
1400
|
+
var _ref14$canScroll = _ref14.canScroll,
|
|
1401
|
+
canScroll = _ref14$canScroll === undefined ? false : _ref14$canScroll;
|
|
1386
1402
|
setHasScroll(canScroll);
|
|
1387
1403
|
}, [setHasScroll]);
|
|
1388
1404
|
var onQuizReset = useCallback(function () {
|
|
@@ -1413,7 +1429,7 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1413
1429
|
"type": 0,
|
|
1414
1430
|
"value": "points gained"
|
|
1415
1431
|
}]
|
|
1416
|
-
})) : null, showReset ? /*#__PURE__*/React.createElement(Button
|
|
1432
|
+
})) : null, showReset ? /*#__PURE__*/React.createElement(Button, {
|
|
1417
1433
|
className: styles$2.reset,
|
|
1418
1434
|
icon: /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
1419
1435
|
icon: faRedo,
|
|
@@ -1480,6 +1496,9 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1480
1496
|
focusable: current && isView,
|
|
1481
1497
|
showInstantAnswer: showInstantAnswer,
|
|
1482
1498
|
layout: questionLayout || layout,
|
|
1499
|
+
result: questionResult,
|
|
1500
|
+
resultImage: questionResultImage,
|
|
1501
|
+
withResult: hasResult,
|
|
1483
1502
|
withoutGoodAnswer: true,
|
|
1484
1503
|
withoutTrueFalse: true,
|
|
1485
1504
|
transitions: transitions,
|
|
@@ -1487,14 +1506,41 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1487
1506
|
transitionStagger: transitionStagger,
|
|
1488
1507
|
transitionDisabled: transitionDisabled,
|
|
1489
1508
|
onAnswerClick: onAnswerClick,
|
|
1490
|
-
onAnswerTransitionEnd:
|
|
1509
|
+
onAnswerTransitionEnd: hasResult ? null : onNextSlide,
|
|
1491
1510
|
className: styles$2.question,
|
|
1492
1511
|
style: !isPlaceholder ? {
|
|
1493
1512
|
padding: spacing,
|
|
1494
1513
|
paddingTop: (current && !isPreview ? viewerTopHeight : 0) + (headerHeight || spacing),
|
|
1495
1514
|
paddingBottom: (current && !isPreview ? viewerBottomHeight : 0) + (callToActionHeight || spacing)
|
|
1496
1515
|
} : null
|
|
1497
|
-
})) : null,
|
|
1516
|
+
})) : null, hasResult && currentAnsweredIndex !== null ? /*#__PURE__*/React.createElement(CSSTransition, {
|
|
1517
|
+
key: "next",
|
|
1518
|
+
classNames: styles$2,
|
|
1519
|
+
timeout: 0
|
|
1520
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1521
|
+
className: styles$2.next,
|
|
1522
|
+
style: !isPlaceholder ? {
|
|
1523
|
+
padding: spacing,
|
|
1524
|
+
paddingTop: (current && !isPreview ? viewerTopHeight : 0) + (headerHeight || spacing),
|
|
1525
|
+
paddingBottom: (current && !isPreview ? viewerBottomHeight : 0) + (callToActionHeight || spacing)
|
|
1526
|
+
} : null
|
|
1527
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
1528
|
+
disabled: currentAnsweredIndex === null,
|
|
1529
|
+
focusable: true,
|
|
1530
|
+
buttonStyle: nextButton !== null ? nextButton.buttonStyle : null,
|
|
1531
|
+
className: styles$2.nextButton,
|
|
1532
|
+
onClick: onNextSlide
|
|
1533
|
+
}, hasButtonText ? /*#__PURE__*/React.createElement(Text, Object.assign({}, nextButton, {
|
|
1534
|
+
className: styles$2.label
|
|
1535
|
+
})) : /*#__PURE__*/React.createElement("span", {
|
|
1536
|
+
className: styles$2.label
|
|
1537
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1538
|
+
id: "SVLGTA",
|
|
1539
|
+
defaultMessage: [{
|
|
1540
|
+
"type": 0,
|
|
1541
|
+
"value": "Next"
|
|
1542
|
+
}]
|
|
1543
|
+
}))))) : null, isResults ? /*#__PURE__*/React.createElement(CSSTransition, {
|
|
1498
1544
|
key: "results",
|
|
1499
1545
|
classNames: styles$2,
|
|
1500
1546
|
timeout: 2000
|
|
@@ -1896,6 +1942,29 @@ var definition = [{
|
|
|
1896
1942
|
"value": "Answers"
|
|
1897
1943
|
}]
|
|
1898
1944
|
})
|
|
1945
|
+
}, {
|
|
1946
|
+
name: 'result',
|
|
1947
|
+
type: 'text-element',
|
|
1948
|
+
theme: {
|
|
1949
|
+
textStyle: 'text'
|
|
1950
|
+
},
|
|
1951
|
+
label: defineMessage({
|
|
1952
|
+
id: "iQ5Uf7",
|
|
1953
|
+
defaultMessage: [{
|
|
1954
|
+
"type": 0,
|
|
1955
|
+
"value": "Default feedback"
|
|
1956
|
+
}]
|
|
1957
|
+
})
|
|
1958
|
+
}, {
|
|
1959
|
+
name: 'resultImage',
|
|
1960
|
+
type: 'visual',
|
|
1961
|
+
label: defineMessage({
|
|
1962
|
+
id: "yA4B6h",
|
|
1963
|
+
defaultMessage: [{
|
|
1964
|
+
"type": 0,
|
|
1965
|
+
"value": "Result feedback image"
|
|
1966
|
+
}]
|
|
1967
|
+
})
|
|
1899
1968
|
}, {
|
|
1900
1969
|
name: 'background',
|
|
1901
1970
|
type: 'background',
|
|
@@ -2077,6 +2146,19 @@ var definition = [{
|
|
|
2077
2146
|
}]
|
|
2078
2147
|
})
|
|
2079
2148
|
}]
|
|
2149
|
+
}, {
|
|
2150
|
+
name: 'nextButton',
|
|
2151
|
+
type: 'button-element',
|
|
2152
|
+
theme: {
|
|
2153
|
+
textStyle: 'button'
|
|
2154
|
+
},
|
|
2155
|
+
label: defineMessage({
|
|
2156
|
+
id: "Yu/PB5",
|
|
2157
|
+
defaultMessage: [{
|
|
2158
|
+
"type": 0,
|
|
2159
|
+
"value": "Next button"
|
|
2160
|
+
}]
|
|
2161
|
+
})
|
|
2080
2162
|
}, {
|
|
2081
2163
|
name: 'background',
|
|
2082
2164
|
type: 'background',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/screen-quiz",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.643",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"access": "public",
|
|
90
90
|
"registry": "https://registry.npmjs.org/"
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "8370388b4087d27421b13ad0b8d2b8ad87163036"
|
|
93
93
|
}
|