@micromag/screen-quiz 0.3.4 → 0.3.5
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/es/index.js +15 -4
- package/lib/index.js +15 -4
- package/package.json +12 -12
package/es/index.js
CHANGED
|
@@ -371,13 +371,13 @@ var Question = function Question(_ref) {
|
|
|
371
371
|
placeholder: /*#__PURE__*/React.createElement("div", {
|
|
372
372
|
className: styles$3.index
|
|
373
373
|
}, "1 / 10")
|
|
374
|
-
}, /*#__PURE__*/React.createElement(Transitions, {
|
|
374
|
+
}, totalCount > 1 ? /*#__PURE__*/React.createElement(Transitions, {
|
|
375
375
|
transitions: transitions,
|
|
376
376
|
playing: transitionPlaying,
|
|
377
377
|
disabled: transitionDisabled
|
|
378
378
|
}, /*#__PURE__*/React.createElement("div", {
|
|
379
379
|
className: styles$3.index
|
|
380
|
-
}, index + 1, " / ", totalCount))) : null, /*#__PURE__*/React.createElement(ScreenElement, {
|
|
380
|
+
}, index + 1, " / ", totalCount)) : null) : null, /*#__PURE__*/React.createElement(ScreenElement, {
|
|
381
381
|
key: "question",
|
|
382
382
|
placeholder: "title",
|
|
383
383
|
emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
@@ -941,13 +941,24 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
941
941
|
userAnswers = _useState2[0],
|
|
942
942
|
setUserAnswers = _useState2[1];
|
|
943
943
|
|
|
944
|
-
var initialQuestionIndex =
|
|
944
|
+
var initialQuestionIndex = 'intro';
|
|
945
945
|
|
|
946
|
-
|
|
946
|
+
if (stateId !== null) {
|
|
947
|
+
initialQuestionIndex = stateId === 'questions' ? parseInt(stateIndex, 10) : stateId;
|
|
948
|
+
} else if (isPlaceholder || !hasIntro) {
|
|
949
|
+
initialQuestionIndex = 0;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
var _useState3 = useState(initialQuestionIndex),
|
|
947
953
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
948
954
|
questionIndex = _useState4[0],
|
|
949
955
|
setQuestionIndex = _useState4[1];
|
|
950
956
|
|
|
957
|
+
useEffect(function () {
|
|
958
|
+
if (isPreview && hasIntro && questionIndex !== 'intro') {
|
|
959
|
+
setQuestionIndex('intro');
|
|
960
|
+
}
|
|
961
|
+
}, [isPreview, hasIntro, questionIndex, setQuestionIndex]);
|
|
951
962
|
var onAnswerClick = useCallback(function (answer, answerIndex) {
|
|
952
963
|
setUserAnswers(_objectSpread(_objectSpread({}, userAnswers), {}, _defineProperty({}, questionIndex, answerIndex)));
|
|
953
964
|
trackScreenEvent('click_answer', "Question #".concat(questionIndex + 1, " ").concat(answerIndex + 1, ": ").concat(answer.label.body), {
|
package/lib/index.js
CHANGED
|
@@ -392,13 +392,13 @@ var Question = function Question(_ref) {
|
|
|
392
392
|
placeholder: /*#__PURE__*/React__default["default"].createElement("div", {
|
|
393
393
|
className: styles$3.index
|
|
394
394
|
}, "1 / 10")
|
|
395
|
-
}, /*#__PURE__*/React__default["default"].createElement(components.Transitions, {
|
|
395
|
+
}, totalCount > 1 ? /*#__PURE__*/React__default["default"].createElement(components.Transitions, {
|
|
396
396
|
transitions: transitions,
|
|
397
397
|
playing: transitionPlaying,
|
|
398
398
|
disabled: transitionDisabled
|
|
399
399
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
400
400
|
className: styles$3.index
|
|
401
|
-
}, index + 1, " / ", totalCount))) : null, /*#__PURE__*/React__default["default"].createElement(components.ScreenElement, {
|
|
401
|
+
}, index + 1, " / ", totalCount)) : null) : null, /*#__PURE__*/React__default["default"].createElement(components.ScreenElement, {
|
|
402
402
|
key: "question",
|
|
403
403
|
placeholder: "title",
|
|
404
404
|
emptyLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
|
|
@@ -962,13 +962,24 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
962
962
|
userAnswers = _useState2[0],
|
|
963
963
|
setUserAnswers = _useState2[1];
|
|
964
964
|
|
|
965
|
-
var initialQuestionIndex =
|
|
965
|
+
var initialQuestionIndex = 'intro';
|
|
966
966
|
|
|
967
|
-
|
|
967
|
+
if (stateId !== null) {
|
|
968
|
+
initialQuestionIndex = stateId === 'questions' ? parseInt(stateIndex, 10) : stateId;
|
|
969
|
+
} else if (isPlaceholder || !hasIntro) {
|
|
970
|
+
initialQuestionIndex = 0;
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
var _useState3 = React.useState(initialQuestionIndex),
|
|
968
974
|
_useState4 = _slicedToArray__default["default"](_useState3, 2),
|
|
969
975
|
questionIndex = _useState4[0],
|
|
970
976
|
setQuestionIndex = _useState4[1];
|
|
971
977
|
|
|
978
|
+
React.useEffect(function () {
|
|
979
|
+
if (isPreview && hasIntro && questionIndex !== 'intro') {
|
|
980
|
+
setQuestionIndex('intro');
|
|
981
|
+
}
|
|
982
|
+
}, [isPreview, hasIntro, questionIndex, setQuestionIndex]);
|
|
972
983
|
var onAnswerClick = React.useCallback(function (answer, answerIndex) {
|
|
973
984
|
setUserAnswers(_objectSpread__default["default"](_objectSpread__default["default"]({}, userAnswers), {}, _defineProperty__default["default"]({}, questionIndex, answerIndex)));
|
|
974
985
|
trackScreenEvent('click_answer', "Question #".concat(questionIndex + 1, " ").concat(answerIndex + 1, ": ").concat(answer.label.body), {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/screen-quiz",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -52,16 +52,16 @@
|
|
|
52
52
|
"@fortawesome/fontawesome-svg-core": "^1.2.32",
|
|
53
53
|
"@fortawesome/free-solid-svg-icons": "^5.15.1",
|
|
54
54
|
"@fortawesome/react-fontawesome": "^0.1.13",
|
|
55
|
-
"@micromag/core": "^0.3.
|
|
56
|
-
"@micromag/data": "^0.3.
|
|
57
|
-
"@micromag/element-background": "^0.3.
|
|
58
|
-
"@micromag/element-button": "^0.3.
|
|
59
|
-
"@micromag/element-call-to-action": "^0.3.
|
|
60
|
-
"@micromag/element-container": "^0.3.
|
|
61
|
-
"@micromag/element-heading": "^0.3.
|
|
62
|
-
"@micromag/element-layout": "^0.3.
|
|
63
|
-
"@micromag/element-text": "^0.3.
|
|
64
|
-
"@micromag/transforms": "^0.3.
|
|
55
|
+
"@micromag/core": "^0.3.5",
|
|
56
|
+
"@micromag/data": "^0.3.5",
|
|
57
|
+
"@micromag/element-background": "^0.3.5",
|
|
58
|
+
"@micromag/element-button": "^0.3.5",
|
|
59
|
+
"@micromag/element-call-to-action": "^0.3.5",
|
|
60
|
+
"@micromag/element-container": "^0.3.5",
|
|
61
|
+
"@micromag/element-heading": "^0.3.5",
|
|
62
|
+
"@micromag/element-layout": "^0.3.5",
|
|
63
|
+
"@micromag/element-text": "^0.3.5",
|
|
64
|
+
"@micromag/transforms": "^0.3.5",
|
|
65
65
|
"classnames": "^2.2.6",
|
|
66
66
|
"lodash": "^4.17.21",
|
|
67
67
|
"prop-types": "^15.7.2",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"publishConfig": {
|
|
73
73
|
"access": "public"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "3a617eef4e655aabe14d4eb9da5460e8f3e93d7e"
|
|
76
76
|
}
|