@micromag/screen-quiz 0.3.408 → 0.3.412
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 +35 -8
- package/lib/index.js +35 -7
- package/package.json +15 -14
package/es/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { PropTypes } from '@micromag/core';
|
|
|
10
10
|
import { ScreenElement, Transitions, Button as Button$1 } from '@micromag/core/components';
|
|
11
11
|
import { useScreenRenderContext, useScreenSize, useViewerContext, useViewerWebView, usePlaybackContext, usePlaybackMediaRef, useScreenState } from '@micromag/core/contexts';
|
|
12
12
|
import { useTrackScreenEvent, useDimensionObserver } from '@micromag/core/hooks';
|
|
13
|
-
import { isTextFilled, getStyleFromColor, isHeaderFilled, isFooterFilled, getFooterProps } from '@micromag/core/utils';
|
|
13
|
+
import { isTextFilled, getStyleFromColor, isImageFilled, isHeaderFilled, isFooterFilled, getFooterProps } from '@micromag/core/utils';
|
|
14
14
|
import { useQuizCreate } from '@micromag/data';
|
|
15
15
|
import Background from '@micromag/element-background';
|
|
16
16
|
import Container from '@micromag/element-container';
|
|
@@ -21,6 +21,7 @@ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
|
21
21
|
import Heading from '@micromag/element-heading';
|
|
22
22
|
import Layout, { Spacer } from '@micromag/element-layout';
|
|
23
23
|
import Text from '@micromag/element-text';
|
|
24
|
+
import Visual from '@micromag/element-visual';
|
|
24
25
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
25
26
|
import { faCheck } from '@fortawesome/free-solid-svg-icons/faCheck';
|
|
26
27
|
import { faTimes } from '@fortawesome/free-solid-svg-icons/faTimes';
|
|
@@ -314,6 +315,7 @@ var propTypes$4 = {
|
|
|
314
315
|
image: PropTypes.imageElement,
|
|
315
316
|
text: PropTypes.textElement
|
|
316
317
|
}),
|
|
318
|
+
resultImage: PropTypes.visualElement,
|
|
317
319
|
index: PropTypes$1.number,
|
|
318
320
|
totalCount: PropTypes$1.number,
|
|
319
321
|
answeredIndex: PropTypes$1.number,
|
|
@@ -343,6 +345,7 @@ var defaultProps$4 = {
|
|
|
343
345
|
question: null,
|
|
344
346
|
answers: null,
|
|
345
347
|
result: null,
|
|
348
|
+
resultImage: null,
|
|
346
349
|
index: null,
|
|
347
350
|
totalCount: null,
|
|
348
351
|
answeredIndex: null,
|
|
@@ -373,6 +376,7 @@ var Question = function Question(_ref) {
|
|
|
373
376
|
var question = _ref.question,
|
|
374
377
|
answers = _ref.answers,
|
|
375
378
|
result = _ref.result,
|
|
379
|
+
resultImage = _ref.resultImage,
|
|
376
380
|
index = _ref.index,
|
|
377
381
|
totalCount = _ref.totalCount,
|
|
378
382
|
answeredIndex = _ref.answeredIndex,
|
|
@@ -413,8 +417,11 @@ var Question = function Question(_ref) {
|
|
|
413
417
|
var answer = answeredIndex !== null && answers[answeredIndex] ? answers[answeredIndex] : null;
|
|
414
418
|
var _ref3 = answer || {},
|
|
415
419
|
_ref3$customAnswerLab = _ref3.customAnswerLabel,
|
|
416
|
-
customAnswerLabel = _ref3$customAnswerLab === void 0 ? null : _ref3$customAnswerLab
|
|
420
|
+
customAnswerLabel = _ref3$customAnswerLab === void 0 ? null : _ref3$customAnswerLab,
|
|
421
|
+
_ref3$answerImage = _ref3.answerImage,
|
|
422
|
+
answerImage = _ref3$answerImage === void 0 ? null : _ref3$answerImage;
|
|
417
423
|
var hasResult = isTextFilled(customAnswerLabel) || isTextFilled(result);
|
|
424
|
+
var hasResultVisual = isImageFilled(answerImage) || isImageFilled(resultImage);
|
|
418
425
|
var defaultResult = isTextFilled(result) ? result : null;
|
|
419
426
|
var customResult = isTextFilled(customAnswerLabel) ? customAnswerLabel : null;
|
|
420
427
|
var onAnswersCollapse = useCallback(function () {
|
|
@@ -492,14 +499,18 @@ var Question = function Question(_ref) {
|
|
|
492
499
|
}) : null,
|
|
493
500
|
isEmpty: answered && !hasResult,
|
|
494
501
|
emptyClassName: styles$3.emptyResult
|
|
495
|
-
}, hasResult && answers !== null ? /*#__PURE__*/React.createElement(Transitions, {
|
|
502
|
+
}, (hasResult || hasResultVisual) && answers !== null ? /*#__PURE__*/React.createElement(Transitions, {
|
|
496
503
|
transitions: transitions,
|
|
497
504
|
playing: transitionPlaying,
|
|
498
505
|
delay: (1 + answers.length) * transitionStagger,
|
|
499
506
|
disabled: transitionDisabled
|
|
500
|
-
}, /*#__PURE__*/React.createElement(Text, Object.assign({}, customResult || defaultResult, {
|
|
507
|
+
}, hasResult ? /*#__PURE__*/React.createElement(Text, Object.assign({}, customResult || defaultResult, {
|
|
501
508
|
className: styles$3.resultText
|
|
502
|
-
}))
|
|
509
|
+
})) : null, hasResultVisual ? /*#__PURE__*/React.createElement(Visual, {
|
|
510
|
+
media: answerImage || resultImage,
|
|
511
|
+
width: "100%",
|
|
512
|
+
height: "auto"
|
|
513
|
+
}) : null) : null))) : null]);
|
|
503
514
|
};
|
|
504
515
|
Question.propTypes = propTypes$4;
|
|
505
516
|
Question.defaultProps = defaultProps$4;
|
|
@@ -515,6 +526,7 @@ var propTypes$3 = {
|
|
|
515
526
|
image: PropTypes.imageElement,
|
|
516
527
|
text: PropTypes.textElement
|
|
517
528
|
}),
|
|
529
|
+
resultImage: PropTypes.visualElement,
|
|
518
530
|
buttonsStyle: PropTypes.boxStyle,
|
|
519
531
|
buttonsTextStyle: PropTypes.textStyle,
|
|
520
532
|
goodAnswerColor: PropTypes.color,
|
|
@@ -538,6 +550,7 @@ var defaultProps$3 = {
|
|
|
538
550
|
question: null,
|
|
539
551
|
answers: null,
|
|
540
552
|
result: null,
|
|
553
|
+
resultImage: null,
|
|
541
554
|
buttonsStyle: null,
|
|
542
555
|
buttonsTextStyle: null,
|
|
543
556
|
goodAnswerColor: null,
|
|
@@ -562,6 +575,7 @@ var QuizScreen = function QuizScreen(_ref) {
|
|
|
562
575
|
question = _ref.question,
|
|
563
576
|
answers = _ref.answers,
|
|
564
577
|
result = _ref.result,
|
|
578
|
+
resultImage = _ref.resultImage,
|
|
565
579
|
buttonsStyle = _ref.buttonsStyle,
|
|
566
580
|
buttonsTextStyle = _ref.buttonsTextStyle,
|
|
567
581
|
goodAnswerColor = _ref.goodAnswerColor,
|
|
@@ -714,13 +728,15 @@ var QuizScreen = function QuizScreen(_ref) {
|
|
|
714
728
|
}),
|
|
715
729
|
onClick: onQuizReset
|
|
716
730
|
}) : null, /*#__PURE__*/React.createElement(Scroll, {
|
|
717
|
-
verticalAlign: verticalAlign
|
|
718
|
-
disabled
|
|
731
|
+
verticalAlign: verticalAlign
|
|
732
|
+
// disabled={scrollingDisabled || userAnswerIndex !== null}
|
|
733
|
+
,
|
|
734
|
+
disabled: scrollingDisabled,
|
|
719
735
|
onScrolledBottom: onScrolledBottom,
|
|
720
736
|
onScrolledNotBottom: onScrolledNotBottom,
|
|
721
737
|
onScrollHeightChange: onScrollHeightChange
|
|
722
738
|
}, !isPlaceholder && hasHeader ? /*#__PURE__*/React.createElement("div", {
|
|
723
|
-
className: classNames([styles$2.header, _defineProperty({}, styles$2.disabled, scrolledBottom && !scrollingDisabled && hasScroll)]),
|
|
739
|
+
className: classNames([styles$2.header, _defineProperty({}, styles$2.disabled, userAnswerIndex !== null || scrolledBottom && !scrollingDisabled && hasScroll)]),
|
|
724
740
|
ref: headerRef,
|
|
725
741
|
style: {
|
|
726
742
|
paddingTop: spacing / 2,
|
|
@@ -733,6 +749,7 @@ var QuizScreen = function QuizScreen(_ref) {
|
|
|
733
749
|
question: question,
|
|
734
750
|
answers: answers,
|
|
735
751
|
result: result,
|
|
752
|
+
resultImage: resultImage,
|
|
736
753
|
answeredIndex: userAnswerIndex,
|
|
737
754
|
buttonsStyle: buttonsStyle,
|
|
738
755
|
buttonsTextStyle: buttonsTextStyle,
|
|
@@ -1573,6 +1590,16 @@ var definition = [{
|
|
|
1573
1590
|
"value": "Default feedback"
|
|
1574
1591
|
}]
|
|
1575
1592
|
})
|
|
1593
|
+
}, {
|
|
1594
|
+
name: 'resultImage',
|
|
1595
|
+
type: 'visual',
|
|
1596
|
+
label: defineMessage({
|
|
1597
|
+
id: "yA4B6h",
|
|
1598
|
+
defaultMessage: [{
|
|
1599
|
+
"type": 0,
|
|
1600
|
+
"value": "Result feedback image"
|
|
1601
|
+
}]
|
|
1602
|
+
})
|
|
1576
1603
|
}, {
|
|
1577
1604
|
type: 'fields',
|
|
1578
1605
|
isList: true,
|
package/lib/index.js
CHANGED
|
@@ -25,6 +25,7 @@ var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
|
25
25
|
var Heading = require('@micromag/element-heading');
|
|
26
26
|
var Layout = require('@micromag/element-layout');
|
|
27
27
|
var Text = require('@micromag/element-text');
|
|
28
|
+
var Visual = require('@micromag/element-visual');
|
|
28
29
|
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
29
30
|
var faCheck = require('@fortawesome/free-solid-svg-icons/faCheck');
|
|
30
31
|
var faTimes = require('@fortawesome/free-solid-svg-icons/faTimes');
|
|
@@ -48,6 +49,7 @@ var _objectSpread__default = /*#__PURE__*/_interopDefaultLegacy(_objectSpread);
|
|
|
48
49
|
var Heading__default = /*#__PURE__*/_interopDefaultLegacy(Heading);
|
|
49
50
|
var Layout__default = /*#__PURE__*/_interopDefaultLegacy(Layout);
|
|
50
51
|
var Text__default = /*#__PURE__*/_interopDefaultLegacy(Text);
|
|
52
|
+
var Visual__default = /*#__PURE__*/_interopDefaultLegacy(Visual);
|
|
51
53
|
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
|
|
52
54
|
var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
|
|
53
55
|
|
|
@@ -337,6 +339,7 @@ var propTypes$4 = {
|
|
|
337
339
|
image: core.PropTypes.imageElement,
|
|
338
340
|
text: core.PropTypes.textElement
|
|
339
341
|
}),
|
|
342
|
+
resultImage: core.PropTypes.visualElement,
|
|
340
343
|
index: PropTypes__default["default"].number,
|
|
341
344
|
totalCount: PropTypes__default["default"].number,
|
|
342
345
|
answeredIndex: PropTypes__default["default"].number,
|
|
@@ -366,6 +369,7 @@ var defaultProps$4 = {
|
|
|
366
369
|
question: null,
|
|
367
370
|
answers: null,
|
|
368
371
|
result: null,
|
|
372
|
+
resultImage: null,
|
|
369
373
|
index: null,
|
|
370
374
|
totalCount: null,
|
|
371
375
|
answeredIndex: null,
|
|
@@ -396,6 +400,7 @@ var Question = function Question(_ref) {
|
|
|
396
400
|
var question = _ref.question,
|
|
397
401
|
answers = _ref.answers,
|
|
398
402
|
result = _ref.result,
|
|
403
|
+
resultImage = _ref.resultImage,
|
|
399
404
|
index = _ref.index,
|
|
400
405
|
totalCount = _ref.totalCount,
|
|
401
406
|
answeredIndex = _ref.answeredIndex,
|
|
@@ -436,8 +441,11 @@ var Question = function Question(_ref) {
|
|
|
436
441
|
var answer = answeredIndex !== null && answers[answeredIndex] ? answers[answeredIndex] : null;
|
|
437
442
|
var _ref3 = answer || {},
|
|
438
443
|
_ref3$customAnswerLab = _ref3.customAnswerLabel,
|
|
439
|
-
customAnswerLabel = _ref3$customAnswerLab === void 0 ? null : _ref3$customAnswerLab
|
|
444
|
+
customAnswerLabel = _ref3$customAnswerLab === void 0 ? null : _ref3$customAnswerLab,
|
|
445
|
+
_ref3$answerImage = _ref3.answerImage,
|
|
446
|
+
answerImage = _ref3$answerImage === void 0 ? null : _ref3$answerImage;
|
|
440
447
|
var hasResult = utils.isTextFilled(customAnswerLabel) || utils.isTextFilled(result);
|
|
448
|
+
var hasResultVisual = utils.isImageFilled(answerImage) || utils.isImageFilled(resultImage);
|
|
441
449
|
var defaultResult = utils.isTextFilled(result) ? result : null;
|
|
442
450
|
var customResult = utils.isTextFilled(customAnswerLabel) ? customAnswerLabel : null;
|
|
443
451
|
var onAnswersCollapse = React.useCallback(function () {
|
|
@@ -515,14 +523,18 @@ var Question = function Question(_ref) {
|
|
|
515
523
|
}) : null,
|
|
516
524
|
isEmpty: answered && !hasResult,
|
|
517
525
|
emptyClassName: styles$3.emptyResult
|
|
518
|
-
}, hasResult && answers !== null ? /*#__PURE__*/React__default["default"].createElement(components.Transitions, {
|
|
526
|
+
}, (hasResult || hasResultVisual) && answers !== null ? /*#__PURE__*/React__default["default"].createElement(components.Transitions, {
|
|
519
527
|
transitions: transitions,
|
|
520
528
|
playing: transitionPlaying,
|
|
521
529
|
delay: (1 + answers.length) * transitionStagger,
|
|
522
530
|
disabled: transitionDisabled
|
|
523
|
-
}, /*#__PURE__*/React__default["default"].createElement(Text__default["default"], Object.assign({}, customResult || defaultResult, {
|
|
531
|
+
}, hasResult ? /*#__PURE__*/React__default["default"].createElement(Text__default["default"], Object.assign({}, customResult || defaultResult, {
|
|
524
532
|
className: styles$3.resultText
|
|
525
|
-
}))
|
|
533
|
+
})) : null, hasResultVisual ? /*#__PURE__*/React__default["default"].createElement(Visual__default["default"], {
|
|
534
|
+
media: answerImage || resultImage,
|
|
535
|
+
width: "100%",
|
|
536
|
+
height: "auto"
|
|
537
|
+
}) : null) : null))) : null]);
|
|
526
538
|
};
|
|
527
539
|
Question.propTypes = propTypes$4;
|
|
528
540
|
Question.defaultProps = defaultProps$4;
|
|
@@ -538,6 +550,7 @@ var propTypes$3 = {
|
|
|
538
550
|
image: core.PropTypes.imageElement,
|
|
539
551
|
text: core.PropTypes.textElement
|
|
540
552
|
}),
|
|
553
|
+
resultImage: core.PropTypes.visualElement,
|
|
541
554
|
buttonsStyle: core.PropTypes.boxStyle,
|
|
542
555
|
buttonsTextStyle: core.PropTypes.textStyle,
|
|
543
556
|
goodAnswerColor: core.PropTypes.color,
|
|
@@ -561,6 +574,7 @@ var defaultProps$3 = {
|
|
|
561
574
|
question: null,
|
|
562
575
|
answers: null,
|
|
563
576
|
result: null,
|
|
577
|
+
resultImage: null,
|
|
564
578
|
buttonsStyle: null,
|
|
565
579
|
buttonsTextStyle: null,
|
|
566
580
|
goodAnswerColor: null,
|
|
@@ -585,6 +599,7 @@ var QuizScreen = function QuizScreen(_ref) {
|
|
|
585
599
|
question = _ref.question,
|
|
586
600
|
answers = _ref.answers,
|
|
587
601
|
result = _ref.result,
|
|
602
|
+
resultImage = _ref.resultImage,
|
|
588
603
|
buttonsStyle = _ref.buttonsStyle,
|
|
589
604
|
buttonsTextStyle = _ref.buttonsTextStyle,
|
|
590
605
|
goodAnswerColor = _ref.goodAnswerColor,
|
|
@@ -737,13 +752,15 @@ var QuizScreen = function QuizScreen(_ref) {
|
|
|
737
752
|
}),
|
|
738
753
|
onClick: onQuizReset
|
|
739
754
|
}) : null, /*#__PURE__*/React__default["default"].createElement(Scroll__default["default"], {
|
|
740
|
-
verticalAlign: verticalAlign
|
|
741
|
-
disabled
|
|
755
|
+
verticalAlign: verticalAlign
|
|
756
|
+
// disabled={scrollingDisabled || userAnswerIndex !== null}
|
|
757
|
+
,
|
|
758
|
+
disabled: scrollingDisabled,
|
|
742
759
|
onScrolledBottom: onScrolledBottom,
|
|
743
760
|
onScrolledNotBottom: onScrolledNotBottom,
|
|
744
761
|
onScrollHeightChange: onScrollHeightChange
|
|
745
762
|
}, !isPlaceholder && hasHeader ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
746
|
-
className: classNames__default["default"]([styles$2.header, _defineProperty__default["default"]({}, styles$2.disabled, scrolledBottom && !scrollingDisabled && hasScroll)]),
|
|
763
|
+
className: classNames__default["default"]([styles$2.header, _defineProperty__default["default"]({}, styles$2.disabled, userAnswerIndex !== null || scrolledBottom && !scrollingDisabled && hasScroll)]),
|
|
747
764
|
ref: headerRef,
|
|
748
765
|
style: {
|
|
749
766
|
paddingTop: spacing / 2,
|
|
@@ -756,6 +773,7 @@ var QuizScreen = function QuizScreen(_ref) {
|
|
|
756
773
|
question: question,
|
|
757
774
|
answers: answers,
|
|
758
775
|
result: result,
|
|
776
|
+
resultImage: resultImage,
|
|
759
777
|
answeredIndex: userAnswerIndex,
|
|
760
778
|
buttonsStyle: buttonsStyle,
|
|
761
779
|
buttonsTextStyle: buttonsTextStyle,
|
|
@@ -1596,6 +1614,16 @@ var definition = [{
|
|
|
1596
1614
|
"value": "Default feedback"
|
|
1597
1615
|
}]
|
|
1598
1616
|
})
|
|
1617
|
+
}, {
|
|
1618
|
+
name: 'resultImage',
|
|
1619
|
+
type: 'visual',
|
|
1620
|
+
label: reactIntl.defineMessage({
|
|
1621
|
+
id: "yA4B6h",
|
|
1622
|
+
defaultMessage: [{
|
|
1623
|
+
"type": 0,
|
|
1624
|
+
"value": "Result feedback image"
|
|
1625
|
+
}]
|
|
1626
|
+
})
|
|
1599
1627
|
}, {
|
|
1600
1628
|
type: 'fields',
|
|
1601
1629
|
isList: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/screen-quiz",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.412",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -53,18 +53,19 @@
|
|
|
53
53
|
"@fortawesome/fontawesome-svg-core": "^1.2.32",
|
|
54
54
|
"@fortawesome/free-solid-svg-icons": "^5.15.1",
|
|
55
55
|
"@fortawesome/react-fontawesome": "^0.1.13",
|
|
56
|
-
"@micromag/core": "^0.3.
|
|
57
|
-
"@micromag/data": "^0.3.
|
|
58
|
-
"@micromag/element-background": "^0.3.
|
|
59
|
-
"@micromag/element-button": "^0.3.
|
|
60
|
-
"@micromag/element-container": "^0.3.
|
|
61
|
-
"@micromag/element-footer": "^0.3.
|
|
62
|
-
"@micromag/element-header": "^0.3.
|
|
63
|
-
"@micromag/element-heading": "^0.3.
|
|
64
|
-
"@micromag/element-layout": "^0.3.
|
|
65
|
-
"@micromag/element-scroll": "^0.3.
|
|
66
|
-
"@micromag/element-text": "^0.3.
|
|
67
|
-
"@micromag/
|
|
56
|
+
"@micromag/core": "^0.3.410",
|
|
57
|
+
"@micromag/data": "^0.3.410",
|
|
58
|
+
"@micromag/element-background": "^0.3.410",
|
|
59
|
+
"@micromag/element-button": "^0.3.410",
|
|
60
|
+
"@micromag/element-container": "^0.3.410",
|
|
61
|
+
"@micromag/element-footer": "^0.3.410",
|
|
62
|
+
"@micromag/element-header": "^0.3.410",
|
|
63
|
+
"@micromag/element-heading": "^0.3.410",
|
|
64
|
+
"@micromag/element-layout": "^0.3.410",
|
|
65
|
+
"@micromag/element-scroll": "^0.3.410",
|
|
66
|
+
"@micromag/element-text": "^0.3.410",
|
|
67
|
+
"@micromag/element-visual": "^0.3.410",
|
|
68
|
+
"@micromag/transforms": "^0.3.410",
|
|
68
69
|
"@react-spring/core": "^9.6.1",
|
|
69
70
|
"@react-spring/web": "^9.6.1",
|
|
70
71
|
"classnames": "^2.2.6",
|
|
@@ -78,5 +79,5 @@
|
|
|
78
79
|
"access": "public",
|
|
79
80
|
"registry": "https://registry.npmjs.org/"
|
|
80
81
|
},
|
|
81
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "4d0b827ed8a3282317d05f9c3a4c5346639c5fe7"
|
|
82
83
|
}
|