@micromag/screen-quiz 0.3.361 → 0.3.362
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 +59 -59
- package/lib/index.js +59 -59
- package/package.json +14 -14
package/assets/css/styles.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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{position:relative;-webkit-transition:opacity .15s ease-out;-o-transition:opacity .15s ease-out;transition:opacity .15s 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:.7!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{-ms-flex-align:center;-ms-flex-pack:center;align-items:center;background-color:#ff2945;border:2px solid #1c1c1c;border-radius:50%;display:-ms-flexbox;display:flex;height:32px;justify-content:center;left:5px;margin-top:-16px;opacity:0;padding:5px;position:absolute;top:50%;-webkit-transition:opacity .15s ease;-o-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}
|
|
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 .15s ease-out;-o-transition:opacity .15s ease-out;transition:opacity .15s 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:.7!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{-ms-flex-align:center;-ms-flex-pack:center;align-items:center;background-color:#ff2945;border:2px solid #1c1c1c;border-radius:50%;display:-ms-flexbox;display:flex;height:32px;justify-content:center;left:5px;margin-top:-16px;opacity:0;padding:5px;position:absolute;top:50%;-webkit-transition:opacity .15s ease;-o-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;-o-transition:opacity .5s ease;transition:opacity .5s ease;-webkit-transition-delay:.3s;-o-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
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;-o-transition:opacity .15s ease-out,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;-o-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;-o-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;-o-transition: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;-o-transition: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;-o-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;-o-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}
|
package/es/index.js
CHANGED
|
@@ -42,6 +42,7 @@ var propTypes$5 = {
|
|
|
42
42
|
withoutGoodAnswer: PropTypes$1.bool,
|
|
43
43
|
withoutIcon: PropTypes$1.bool,
|
|
44
44
|
focusable: PropTypes$1.bool,
|
|
45
|
+
animated: PropTypes$1.bool,
|
|
45
46
|
collapsed: PropTypes$1.bool,
|
|
46
47
|
onClick: PropTypes$1.func,
|
|
47
48
|
onCollapse: PropTypes$1.func,
|
|
@@ -60,6 +61,7 @@ var defaultProps$5 = {
|
|
|
60
61
|
withoutGoodAnswer: false,
|
|
61
62
|
withoutIcon: false,
|
|
62
63
|
focusable: false,
|
|
64
|
+
animated: false,
|
|
63
65
|
collapsed: false,
|
|
64
66
|
onClick: null,
|
|
65
67
|
onCollapse: null,
|
|
@@ -68,7 +70,7 @@ var defaultProps$5 = {
|
|
|
68
70
|
className: null
|
|
69
71
|
};
|
|
70
72
|
var Answers = function Answers(_ref) {
|
|
71
|
-
var
|
|
73
|
+
var _ref8;
|
|
72
74
|
var items = _ref.items,
|
|
73
75
|
answeredIndex = _ref.answeredIndex,
|
|
74
76
|
answersCollapseDelay = _ref.answersCollapseDelay,
|
|
@@ -80,6 +82,7 @@ var Answers = function Answers(_ref) {
|
|
|
80
82
|
withoutGoodAnswer = _ref.withoutGoodAnswer,
|
|
81
83
|
withoutIcon = _ref.withoutIcon,
|
|
82
84
|
focusable = _ref.focusable,
|
|
85
|
+
collapseAnimated = _ref.animated,
|
|
83
86
|
initialCollapsed = _ref.collapsed,
|
|
84
87
|
onClick = _ref.onClick,
|
|
85
88
|
onCollapse = _ref.onCollapse,
|
|
@@ -145,24 +148,25 @@ var Answers = function Answers(_ref) {
|
|
|
145
148
|
}, [shouldCollapse, answersCollapsed, answersDidCollapse, setAnswersCollapsed, onCollapsed, onTransitionEnd]);
|
|
146
149
|
var itemsRefs = useRef([]);
|
|
147
150
|
var listOfItems = isPlaceholder || isEdit && items.length === 0 ? _toConsumableArray(new Array(2)) : items;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
151
|
+
var heights = useMemo(function () {
|
|
152
|
+
var allHeights = listOfItems.reduce(function (acc, it, i) {
|
|
153
|
+
if (itemsRefs.current[i] && collapseAnimated) {
|
|
154
|
+
var _ref4 = itemsRefs.current[i].getBoundingClientRect() || {},
|
|
155
|
+
_ref4$height = _ref4.height,
|
|
156
|
+
height = _ref4$height === void 0 ? 0 : _ref4$height;
|
|
157
|
+
acc.push(height);
|
|
158
|
+
}
|
|
159
|
+
return acc;
|
|
160
|
+
}, []);
|
|
161
|
+
return allHeights;
|
|
162
|
+
}, [answeredIndex, shouldCollapse, collapseAnimated, listOfItems]);
|
|
159
163
|
var showAnimation = isView || isEdit;
|
|
160
164
|
var filteredListOfItems = listOfItems.map(function (answer, answerI) {
|
|
161
|
-
|
|
165
|
+
var height = heights[answerI] ? heights[answerI] : 0;
|
|
162
166
|
var userAnswer = answerI === answeredIndex;
|
|
163
|
-
var
|
|
164
|
-
|
|
165
|
-
rightAnswer =
|
|
167
|
+
var _ref5 = answer || {},
|
|
168
|
+
_ref5$good = _ref5.good,
|
|
169
|
+
rightAnswer = _ref5$good === void 0 ? false : _ref5$good;
|
|
166
170
|
var hidden = false;
|
|
167
171
|
if (answeredIndex !== null && showAnimation && answersDidCollapse && !rightAnswer && (hasRightAnswer || !userAnswer)) {
|
|
168
172
|
hidden = true;
|
|
@@ -173,71 +177,62 @@ var Answers = function Answers(_ref) {
|
|
|
173
177
|
return _objectSpread(_objectSpread({}, answer), {}, {
|
|
174
178
|
hidden: hidden,
|
|
175
179
|
userAnswer: userAnswer,
|
|
176
|
-
index: answerI
|
|
180
|
+
index: answerI,
|
|
181
|
+
maxHeight: height
|
|
177
182
|
});
|
|
178
183
|
});
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
var transitions = useTransition(filteredListOfItems.map(function (data) {
|
|
187
|
-
return _objectSpread(_objectSpread({}, data), {}, {
|
|
188
|
-
hidden: data.hidden
|
|
189
|
-
});
|
|
190
|
-
}), {
|
|
191
|
-
key: function key(_ref5) {
|
|
192
|
-
var _ref5$index = _ref5.index,
|
|
193
|
-
index = _ref5$index === void 0 ? 0 : _ref5$index,
|
|
194
|
-
_ref5$label = _ref5.label,
|
|
195
|
-
label = _ref5$label === void 0 ? null : _ref5$label;
|
|
184
|
+
var transitions = useTransition(filteredListOfItems, {
|
|
185
|
+
key: function key(_ref6) {
|
|
186
|
+
var _ref6$index = _ref6.index,
|
|
187
|
+
index = _ref6$index === void 0 ? 0 : _ref6$index,
|
|
188
|
+
_ref6$label = _ref6.label,
|
|
189
|
+
label = _ref6$label === void 0 ? null : _ref6$label;
|
|
196
190
|
return "key-".concat(index, "-").concat((label === null || label === void 0 ? void 0 : label.body) || null);
|
|
197
191
|
},
|
|
198
|
-
update: function update(
|
|
199
|
-
var
|
|
200
|
-
hidden =
|
|
192
|
+
update: function update(_ref7) {
|
|
193
|
+
var _ref7$hidden = _ref7.hidden,
|
|
194
|
+
hidden = _ref7$hidden === void 0 ? false : _ref7$hidden,
|
|
195
|
+
_ref7$maxHeight = _ref7.maxHeight,
|
|
196
|
+
maxHeight = _ref7$maxHeight === void 0 ? 0 : _ref7$maxHeight;
|
|
201
197
|
return {
|
|
202
198
|
opacity: hidden && showAnimation && !withoutGoodAnswer ? 0 : 1,
|
|
203
|
-
|
|
199
|
+
// Animate this, not height
|
|
200
|
+
maxHeight:
|
|
201
|
+
// eslint-disable-next-line no-nested-ternary
|
|
202
|
+
hidden && showAnimation && !withoutGoodAnswer ? 0 : maxHeight > 0 ? maxHeight : null
|
|
204
203
|
};
|
|
205
204
|
},
|
|
206
205
|
config: config.gentle
|
|
207
|
-
// onRest: () => {
|
|
208
|
-
// console.log('rest');
|
|
209
|
-
// },
|
|
210
206
|
});
|
|
211
|
-
|
|
212
207
|
return /*#__PURE__*/React.createElement("div", {
|
|
213
|
-
className: classNames([styles$4.container, (
|
|
208
|
+
className: classNames([styles$4.container, (_ref8 = {}, _defineProperty(_ref8, styles$4.answered, answered), _defineProperty(_ref8, styles$4.withIcon, !withoutIcon), _defineProperty(_ref8, styles$4.isPlaceholder, isPlaceholder), _defineProperty(_ref8, className, className !== null), _ref8)])
|
|
214
209
|
}, filteredListOfItems !== null || isPlaceholder ? /*#__PURE__*/React.createElement("div", {
|
|
215
210
|
className: styles$4.items
|
|
216
211
|
}, transitions(function (style, answer, t, answerI) {
|
|
217
|
-
var
|
|
212
|
+
var _ref11;
|
|
218
213
|
var userAnswer = answerI === answeredIndex;
|
|
219
|
-
var
|
|
220
|
-
|
|
221
|
-
rightAnswer =
|
|
222
|
-
|
|
223
|
-
label =
|
|
224
|
-
|
|
225
|
-
answerButtonStyle =
|
|
226
|
-
_ref8$textStyle = _ref8.textStyle,
|
|
227
|
-
answerButtonTextStyle = _ref8$textStyle === void 0 ? null : _ref8$textStyle;
|
|
228
|
-
var _ref9 = label || {},
|
|
214
|
+
var _ref9 = answer || {},
|
|
215
|
+
_ref9$good = _ref9.good,
|
|
216
|
+
rightAnswer = _ref9$good === void 0 ? null : _ref9$good,
|
|
217
|
+
_ref9$label = _ref9.label,
|
|
218
|
+
label = _ref9$label === void 0 ? null : _ref9$label,
|
|
219
|
+
_ref9$buttonStyle = _ref9.buttonStyle,
|
|
220
|
+
answerButtonStyle = _ref9$buttonStyle === void 0 ? null : _ref9$buttonStyle,
|
|
229
221
|
_ref9$textStyle = _ref9.textStyle,
|
|
230
|
-
|
|
222
|
+
answerButtonTextStyle = _ref9$textStyle === void 0 ? null : _ref9$textStyle;
|
|
223
|
+
var _ref10 = label || {},
|
|
224
|
+
_ref10$textStyle = _ref10.textStyle,
|
|
225
|
+
textStyle = _ref10$textStyle === void 0 ? null : _ref10$textStyle;
|
|
231
226
|
var hasAnswer = isTextFilled(label);
|
|
232
227
|
return /*#__PURE__*/React.createElement(animated.div, {
|
|
233
228
|
key: "answer-".concat(answerI),
|
|
234
|
-
className: classNames([styles$4.item, (
|
|
235
|
-
style: _objectSpread({}, style)
|
|
229
|
+
className: classNames([styles$4.item, (_ref11 = {}, _defineProperty(_ref11, styles$4.rightAnswer, !withoutGoodAnswer && rightAnswer === true), _defineProperty(_ref11, styles$4.userAnswer, withoutGoodAnswer && userAnswer), _defineProperty(_ref11, styles$4.otherAnswer, withoutGoodAnswer && !userAnswer), _ref11)]),
|
|
230
|
+
style: _objectSpread({}, style)
|
|
231
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
232
|
+
className: styles$4.itemContent,
|
|
236
233
|
ref: function ref(el) {
|
|
237
234
|
itemsRefs.current[answerI] = el;
|
|
238
235
|
}
|
|
239
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
240
|
-
className: styles$4.itemContent
|
|
241
236
|
}, /*#__PURE__*/React.createElement(ScreenElement, {
|
|
242
237
|
placeholder: "quizAnswer",
|
|
243
238
|
placeholderProps: {
|
|
@@ -303,6 +298,7 @@ var propTypes$4 = {
|
|
|
303
298
|
goodAnswerColor: PropTypes.color,
|
|
304
299
|
badAnswerColor: PropTypes.color,
|
|
305
300
|
focusable: PropTypes$1.bool,
|
|
301
|
+
animated: PropTypes$1.bool,
|
|
306
302
|
layout: PropTypes$1.string,
|
|
307
303
|
showInstantAnswer: PropTypes$1.bool,
|
|
308
304
|
withResult: PropTypes$1.bool,
|
|
@@ -331,6 +327,7 @@ var defaultProps$4 = {
|
|
|
331
327
|
goodAnswerColor: null,
|
|
332
328
|
badAnswerColor: null,
|
|
333
329
|
focusable: false,
|
|
330
|
+
animated: false,
|
|
334
331
|
layout: null,
|
|
335
332
|
showInstantAnswer: false,
|
|
336
333
|
withResult: false,
|
|
@@ -360,6 +357,7 @@ var Question = function Question(_ref) {
|
|
|
360
357
|
goodAnswerColor = _ref.goodAnswerColor,
|
|
361
358
|
badAnswerColor = _ref.badAnswerColor,
|
|
362
359
|
focusable = _ref.focusable,
|
|
360
|
+
animated = _ref.animated,
|
|
363
361
|
showInstantAnswer = _ref.showInstantAnswer,
|
|
364
362
|
withResult = _ref.withResult,
|
|
365
363
|
withoutGoodAnswer = _ref.withoutGoodAnswer,
|
|
@@ -446,6 +444,7 @@ var Question = function Question(_ref) {
|
|
|
446
444
|
buttonsStyle: buttonsStyle,
|
|
447
445
|
buttonsTextStyle: buttonsTextStyle,
|
|
448
446
|
focusable: focusable,
|
|
447
|
+
animated: animated,
|
|
449
448
|
transitions: transitions,
|
|
450
449
|
transitionStagger: transitionStagger,
|
|
451
450
|
transitionPlaying: transitionPlaying,
|
|
@@ -713,6 +712,7 @@ var QuizScreen = function QuizScreen(_ref) {
|
|
|
713
712
|
withoutTrueFalse: withoutTrueFalse,
|
|
714
713
|
withoutGoodAnswer: withoutGoodAnswer,
|
|
715
714
|
focusable: current && isView,
|
|
715
|
+
animated: isView,
|
|
716
716
|
showInstantAnswer: showInstantAnswer,
|
|
717
717
|
withResult: true,
|
|
718
718
|
layout: layout,
|
package/lib/index.js
CHANGED
|
@@ -65,6 +65,7 @@ var propTypes$5 = {
|
|
|
65
65
|
withoutGoodAnswer: PropTypes__default["default"].bool,
|
|
66
66
|
withoutIcon: PropTypes__default["default"].bool,
|
|
67
67
|
focusable: PropTypes__default["default"].bool,
|
|
68
|
+
animated: PropTypes__default["default"].bool,
|
|
68
69
|
collapsed: PropTypes__default["default"].bool,
|
|
69
70
|
onClick: PropTypes__default["default"].func,
|
|
70
71
|
onCollapse: PropTypes__default["default"].func,
|
|
@@ -83,6 +84,7 @@ var defaultProps$5 = {
|
|
|
83
84
|
withoutGoodAnswer: false,
|
|
84
85
|
withoutIcon: false,
|
|
85
86
|
focusable: false,
|
|
87
|
+
animated: false,
|
|
86
88
|
collapsed: false,
|
|
87
89
|
onClick: null,
|
|
88
90
|
onCollapse: null,
|
|
@@ -91,7 +93,7 @@ var defaultProps$5 = {
|
|
|
91
93
|
className: null
|
|
92
94
|
};
|
|
93
95
|
var Answers = function Answers(_ref) {
|
|
94
|
-
var
|
|
96
|
+
var _ref8;
|
|
95
97
|
var items = _ref.items,
|
|
96
98
|
answeredIndex = _ref.answeredIndex,
|
|
97
99
|
answersCollapseDelay = _ref.answersCollapseDelay,
|
|
@@ -103,6 +105,7 @@ var Answers = function Answers(_ref) {
|
|
|
103
105
|
withoutGoodAnswer = _ref.withoutGoodAnswer,
|
|
104
106
|
withoutIcon = _ref.withoutIcon,
|
|
105
107
|
focusable = _ref.focusable,
|
|
108
|
+
collapseAnimated = _ref.animated,
|
|
106
109
|
initialCollapsed = _ref.collapsed,
|
|
107
110
|
onClick = _ref.onClick,
|
|
108
111
|
onCollapse = _ref.onCollapse,
|
|
@@ -168,24 +171,25 @@ var Answers = function Answers(_ref) {
|
|
|
168
171
|
}, [shouldCollapse, answersCollapsed, answersDidCollapse, setAnswersCollapsed, onCollapsed, onTransitionEnd]);
|
|
169
172
|
var itemsRefs = React.useRef([]);
|
|
170
173
|
var listOfItems = isPlaceholder || isEdit && items.length === 0 ? _toConsumableArray__default["default"](new Array(2)) : items;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
174
|
+
var heights = React.useMemo(function () {
|
|
175
|
+
var allHeights = listOfItems.reduce(function (acc, it, i) {
|
|
176
|
+
if (itemsRefs.current[i] && collapseAnimated) {
|
|
177
|
+
var _ref4 = itemsRefs.current[i].getBoundingClientRect() || {},
|
|
178
|
+
_ref4$height = _ref4.height,
|
|
179
|
+
height = _ref4$height === void 0 ? 0 : _ref4$height;
|
|
180
|
+
acc.push(height);
|
|
181
|
+
}
|
|
182
|
+
return acc;
|
|
183
|
+
}, []);
|
|
184
|
+
return allHeights;
|
|
185
|
+
}, [answeredIndex, shouldCollapse, collapseAnimated, listOfItems]);
|
|
182
186
|
var showAnimation = isView || isEdit;
|
|
183
187
|
var filteredListOfItems = listOfItems.map(function (answer, answerI) {
|
|
184
|
-
|
|
188
|
+
var height = heights[answerI] ? heights[answerI] : 0;
|
|
185
189
|
var userAnswer = answerI === answeredIndex;
|
|
186
|
-
var
|
|
187
|
-
|
|
188
|
-
rightAnswer =
|
|
190
|
+
var _ref5 = answer || {},
|
|
191
|
+
_ref5$good = _ref5.good,
|
|
192
|
+
rightAnswer = _ref5$good === void 0 ? false : _ref5$good;
|
|
189
193
|
var hidden = false;
|
|
190
194
|
if (answeredIndex !== null && showAnimation && answersDidCollapse && !rightAnswer && (hasRightAnswer || !userAnswer)) {
|
|
191
195
|
hidden = true;
|
|
@@ -196,71 +200,62 @@ var Answers = function Answers(_ref) {
|
|
|
196
200
|
return _objectSpread__default["default"](_objectSpread__default["default"]({}, answer), {}, {
|
|
197
201
|
hidden: hidden,
|
|
198
202
|
userAnswer: userAnswer,
|
|
199
|
-
index: answerI
|
|
203
|
+
index: answerI,
|
|
204
|
+
maxHeight: height
|
|
200
205
|
});
|
|
201
206
|
});
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
var transitions = web.useTransition(filteredListOfItems.map(function (data) {
|
|
210
|
-
return _objectSpread__default["default"](_objectSpread__default["default"]({}, data), {}, {
|
|
211
|
-
hidden: data.hidden
|
|
212
|
-
});
|
|
213
|
-
}), {
|
|
214
|
-
key: function key(_ref5) {
|
|
215
|
-
var _ref5$index = _ref5.index,
|
|
216
|
-
index = _ref5$index === void 0 ? 0 : _ref5$index,
|
|
217
|
-
_ref5$label = _ref5.label,
|
|
218
|
-
label = _ref5$label === void 0 ? null : _ref5$label;
|
|
207
|
+
var transitions = web.useTransition(filteredListOfItems, {
|
|
208
|
+
key: function key(_ref6) {
|
|
209
|
+
var _ref6$index = _ref6.index,
|
|
210
|
+
index = _ref6$index === void 0 ? 0 : _ref6$index,
|
|
211
|
+
_ref6$label = _ref6.label,
|
|
212
|
+
label = _ref6$label === void 0 ? null : _ref6$label;
|
|
219
213
|
return "key-".concat(index, "-").concat((label === null || label === void 0 ? void 0 : label.body) || null);
|
|
220
214
|
},
|
|
221
|
-
update: function update(
|
|
222
|
-
var
|
|
223
|
-
hidden =
|
|
215
|
+
update: function update(_ref7) {
|
|
216
|
+
var _ref7$hidden = _ref7.hidden,
|
|
217
|
+
hidden = _ref7$hidden === void 0 ? false : _ref7$hidden,
|
|
218
|
+
_ref7$maxHeight = _ref7.maxHeight,
|
|
219
|
+
maxHeight = _ref7$maxHeight === void 0 ? 0 : _ref7$maxHeight;
|
|
224
220
|
return {
|
|
225
221
|
opacity: hidden && showAnimation && !withoutGoodAnswer ? 0 : 1,
|
|
226
|
-
|
|
222
|
+
// Animate this, not height
|
|
223
|
+
maxHeight:
|
|
224
|
+
// eslint-disable-next-line no-nested-ternary
|
|
225
|
+
hidden && showAnimation && !withoutGoodAnswer ? 0 : maxHeight > 0 ? maxHeight : null
|
|
227
226
|
};
|
|
228
227
|
},
|
|
229
228
|
config: web.config.gentle
|
|
230
|
-
// onRest: () => {
|
|
231
|
-
// console.log('rest');
|
|
232
|
-
// },
|
|
233
229
|
});
|
|
234
|
-
|
|
235
230
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
236
|
-
className: classNames__default["default"]([styles$4.container, (
|
|
231
|
+
className: classNames__default["default"]([styles$4.container, (_ref8 = {}, _defineProperty__default["default"](_ref8, styles$4.answered, answered), _defineProperty__default["default"](_ref8, styles$4.withIcon, !withoutIcon), _defineProperty__default["default"](_ref8, styles$4.isPlaceholder, isPlaceholder), _defineProperty__default["default"](_ref8, className, className !== null), _ref8)])
|
|
237
232
|
}, filteredListOfItems !== null || isPlaceholder ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
238
233
|
className: styles$4.items
|
|
239
234
|
}, transitions(function (style, answer, t, answerI) {
|
|
240
|
-
var
|
|
235
|
+
var _ref11;
|
|
241
236
|
var userAnswer = answerI === answeredIndex;
|
|
242
|
-
var
|
|
243
|
-
|
|
244
|
-
rightAnswer =
|
|
245
|
-
|
|
246
|
-
label =
|
|
247
|
-
|
|
248
|
-
answerButtonStyle =
|
|
249
|
-
_ref8$textStyle = _ref8.textStyle,
|
|
250
|
-
answerButtonTextStyle = _ref8$textStyle === void 0 ? null : _ref8$textStyle;
|
|
251
|
-
var _ref9 = label || {},
|
|
237
|
+
var _ref9 = answer || {},
|
|
238
|
+
_ref9$good = _ref9.good,
|
|
239
|
+
rightAnswer = _ref9$good === void 0 ? null : _ref9$good,
|
|
240
|
+
_ref9$label = _ref9.label,
|
|
241
|
+
label = _ref9$label === void 0 ? null : _ref9$label,
|
|
242
|
+
_ref9$buttonStyle = _ref9.buttonStyle,
|
|
243
|
+
answerButtonStyle = _ref9$buttonStyle === void 0 ? null : _ref9$buttonStyle,
|
|
252
244
|
_ref9$textStyle = _ref9.textStyle,
|
|
253
|
-
|
|
245
|
+
answerButtonTextStyle = _ref9$textStyle === void 0 ? null : _ref9$textStyle;
|
|
246
|
+
var _ref10 = label || {},
|
|
247
|
+
_ref10$textStyle = _ref10.textStyle,
|
|
248
|
+
textStyle = _ref10$textStyle === void 0 ? null : _ref10$textStyle;
|
|
254
249
|
var hasAnswer = utils.isTextFilled(label);
|
|
255
250
|
return /*#__PURE__*/React__default["default"].createElement(web.animated.div, {
|
|
256
251
|
key: "answer-".concat(answerI),
|
|
257
|
-
className: classNames__default["default"]([styles$4.item, (
|
|
258
|
-
style: _objectSpread__default["default"]({}, style)
|
|
252
|
+
className: classNames__default["default"]([styles$4.item, (_ref11 = {}, _defineProperty__default["default"](_ref11, styles$4.rightAnswer, !withoutGoodAnswer && rightAnswer === true), _defineProperty__default["default"](_ref11, styles$4.userAnswer, withoutGoodAnswer && userAnswer), _defineProperty__default["default"](_ref11, styles$4.otherAnswer, withoutGoodAnswer && !userAnswer), _ref11)]),
|
|
253
|
+
style: _objectSpread__default["default"]({}, style)
|
|
254
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
255
|
+
className: styles$4.itemContent,
|
|
259
256
|
ref: function ref(el) {
|
|
260
257
|
itemsRefs.current[answerI] = el;
|
|
261
258
|
}
|
|
262
|
-
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
263
|
-
className: styles$4.itemContent
|
|
264
259
|
}, /*#__PURE__*/React__default["default"].createElement(components.ScreenElement, {
|
|
265
260
|
placeholder: "quizAnswer",
|
|
266
261
|
placeholderProps: {
|
|
@@ -326,6 +321,7 @@ var propTypes$4 = {
|
|
|
326
321
|
goodAnswerColor: core.PropTypes.color,
|
|
327
322
|
badAnswerColor: core.PropTypes.color,
|
|
328
323
|
focusable: PropTypes__default["default"].bool,
|
|
324
|
+
animated: PropTypes__default["default"].bool,
|
|
329
325
|
layout: PropTypes__default["default"].string,
|
|
330
326
|
showInstantAnswer: PropTypes__default["default"].bool,
|
|
331
327
|
withResult: PropTypes__default["default"].bool,
|
|
@@ -354,6 +350,7 @@ var defaultProps$4 = {
|
|
|
354
350
|
goodAnswerColor: null,
|
|
355
351
|
badAnswerColor: null,
|
|
356
352
|
focusable: false,
|
|
353
|
+
animated: false,
|
|
357
354
|
layout: null,
|
|
358
355
|
showInstantAnswer: false,
|
|
359
356
|
withResult: false,
|
|
@@ -383,6 +380,7 @@ var Question = function Question(_ref) {
|
|
|
383
380
|
goodAnswerColor = _ref.goodAnswerColor,
|
|
384
381
|
badAnswerColor = _ref.badAnswerColor,
|
|
385
382
|
focusable = _ref.focusable,
|
|
383
|
+
animated = _ref.animated,
|
|
386
384
|
showInstantAnswer = _ref.showInstantAnswer,
|
|
387
385
|
withResult = _ref.withResult,
|
|
388
386
|
withoutGoodAnswer = _ref.withoutGoodAnswer,
|
|
@@ -469,6 +467,7 @@ var Question = function Question(_ref) {
|
|
|
469
467
|
buttonsStyle: buttonsStyle,
|
|
470
468
|
buttonsTextStyle: buttonsTextStyle,
|
|
471
469
|
focusable: focusable,
|
|
470
|
+
animated: animated,
|
|
472
471
|
transitions: transitions,
|
|
473
472
|
transitionStagger: transitionStagger,
|
|
474
473
|
transitionPlaying: transitionPlaying,
|
|
@@ -736,6 +735,7 @@ var QuizScreen = function QuizScreen(_ref) {
|
|
|
736
735
|
withoutTrueFalse: withoutTrueFalse,
|
|
737
736
|
withoutGoodAnswer: withoutGoodAnswer,
|
|
738
737
|
focusable: current && isView,
|
|
738
|
+
animated: isView,
|
|
739
739
|
showInstantAnswer: showInstantAnswer,
|
|
740
740
|
withResult: true,
|
|
741
741
|
layout: layout,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/screen-quiz",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.362",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -52,18 +52,18 @@
|
|
|
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-container": "^0.3.
|
|
60
|
-
"@micromag/element-footer": "^0.3.
|
|
61
|
-
"@micromag/element-header": "^0.3.
|
|
62
|
-
"@micromag/element-heading": "^0.3.
|
|
63
|
-
"@micromag/element-layout": "^0.3.
|
|
64
|
-
"@micromag/element-scroll": "^0.3.
|
|
65
|
-
"@micromag/element-text": "^0.3.
|
|
66
|
-
"@micromag/transforms": "^0.3.
|
|
55
|
+
"@micromag/core": "^0.3.362",
|
|
56
|
+
"@micromag/data": "^0.3.362",
|
|
57
|
+
"@micromag/element-background": "^0.3.362",
|
|
58
|
+
"@micromag/element-button": "^0.3.362",
|
|
59
|
+
"@micromag/element-container": "^0.3.362",
|
|
60
|
+
"@micromag/element-footer": "^0.3.362",
|
|
61
|
+
"@micromag/element-header": "^0.3.362",
|
|
62
|
+
"@micromag/element-heading": "^0.3.362",
|
|
63
|
+
"@micromag/element-layout": "^0.3.362",
|
|
64
|
+
"@micromag/element-scroll": "^0.3.362",
|
|
65
|
+
"@micromag/element-text": "^0.3.362",
|
|
66
|
+
"@micromag/transforms": "^0.3.362",
|
|
67
67
|
"@react-spring/core": "^9.6.1",
|
|
68
68
|
"@react-spring/web": "^9.6.1",
|
|
69
69
|
"classnames": "^2.2.6",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"publishConfig": {
|
|
77
77
|
"access": "public"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "21619f51536d95517afabfdf316ef8fc345f6562"
|
|
80
80
|
}
|