@micromag/screen-contribution 0.2.286

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.
@@ -0,0 +1 @@
1
+ .micromag-screen-contribution-container .micromag-screen-contribution-content{position:absolute;top:0;left:0;width:100%;height:100%}.micromag-screen-contribution-container{position:relative}@-webkit-keyframes micromag-screen-contribution-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes micromag-screen-contribution-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}.micromag-screen-contribution-container .micromag-screen-contribution-emptyInputMessage,.micromag-screen-contribution-container .micromag-screen-contribution-emptyInputName,.micromag-screen-contribution-container .micromag-screen-contribution-emptySubmit,.micromag-screen-contribution-container .micromag-screen-contribution-emptyTitle{margin-bottom:10px;padding:10px}.micromag-screen-contribution-container .micromag-screen-contribution-emptyInputMessage{height:100px}.micromag-screen-contribution-container .micromag-screen-contribution-title{padding-bottom:20px}.micromag-screen-contribution-container .micromag-screen-contribution-interactiveContainer{-webkit-transition-property:height;-o-transition-property:height;transition-property:height;-webkit-transition-timing-function:ease;-o-transition-timing-function:ease;transition-timing-function:ease}.micromag-screen-contribution-container .micromag-screen-contribution-form{position:relative}.micromag-screen-contribution-container .micromag-screen-contribution-buttonSubmit,.micromag-screen-contribution-container .micromag-screen-contribution-inputMessage,.micromag-screen-contribution-container .micromag-screen-contribution-inputName{display:block;width:100%;padding:4px}.micromag-screen-contribution-container .micromag-screen-contribution-inputMessage,.micromag-screen-contribution-container .micromag-screen-contribution-inputName{margin-bottom:10px}.micromag-screen-contribution-container .micromag-screen-contribution-inputMessage{height:100px}.micromag-screen-contribution-container .micromag-screen-contribution-buttonSubmit{border:0}.micromag-screen-contribution-container .micromag-screen-contribution-buttonSubmit:disabled{opacity:1}.micromag-screen-contribution-container .micromag-screen-contribution-formContent{-webkit-transition-property:opacity;-o-transition-property:opacity;transition-property:opacity;-webkit-transition-timing-function:ease;-o-transition-timing-function:ease;transition-timing-function:ease}.micromag-screen-contribution-container .micromag-screen-contribution-formLoading{position:absolute;top:50%;left:50%;width:40px;height:40px;margin-top:-20px;margin-left:-20px;-webkit-transition:opacity .25s ease;-o-transition:opacity .25s ease;transition:opacity .25s ease;-webkit-animation:micromag-screen-contribution-rotate 1s linear infinite;animation:micromag-screen-contribution-rotate 1s linear infinite;opacity:0;pointer-events:none}.micromag-screen-contribution-container .micromag-screen-contribution-formLoading .micromag-screen-contribution-loadingIcon{display:block;width:100%;height:100%}.micromag-screen-contribution-container .micromag-screen-contribution-contributionsContainer{position:relative;-webkit-transition:opacity .25s ease;-o-transition:opacity .25s ease;transition:opacity .25s ease;opacity:0}.micromag-screen-contribution-container .micromag-screen-contribution-contributionsContent{position:absolute;width:100%;height:0;overflow:hidden}.micromag-screen-contribution-container .micromag-screen-contribution-contributions{position:relative}.micromag-screen-contribution-container .micromag-screen-contribution-contribution{margin-bottom:20px;padding-bottom:20px;border-bottom:1px solid #fff}.micromag-screen-contribution-container .micromag-screen-contribution-contribution:first-child{padding-top:20px;border-top:1px solid #fff}.micromag-screen-contribution-container .micromag-screen-contribution-contribution:last-child{margin-bottom:0;padding-bottom:0;border-bottom:0}.micromag-screen-contribution-container .micromag-screen-contribution-callToAction{position:absolute;bottom:0;left:0;width:100%}.micromag-screen-contribution-container.micromag-screen-contribution-submitting .micromag-screen-contribution-form{pointer-events:none}.micromag-screen-contribution-container.micromag-screen-contribution-submitting .micromag-screen-contribution-formContent{opacity:.4}.micromag-screen-contribution-container.micromag-screen-contribution-submitting .micromag-screen-contribution-formLoading{opacity:1}.micromag-screen-contribution-container.micromag-screen-contribution-submitted .micromag-screen-contribution-formContent{opacity:0}.micromag-screen-contribution-container.micromag-screen-contribution-showContributions .micromag-screen-contribution-form{display:none}.micromag-screen-contribution-container.micromag-screen-contribution-showContributions .micromag-screen-contribution-contributionsContainer{opacity:1}.micromag-screen-contribution-container.micromag-screen-contribution-showContributions .micromag-screen-contribution-contributionsContent{position:relative;height:auto;overflow:visible}.micromag-screen-contribution-container.micromag-screen-contribution-isPlaceholder .micromag-screen-contribution-content{padding:10px}
package/es/index.js ADDED
@@ -0,0 +1,574 @@
1
+ import { FormattedMessage, defineMessage } from 'react-intl';
2
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
4
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
5
+ import React, { useRef, useState, useCallback, useEffect } from 'react';
6
+ import PropTypes from 'prop-types';
7
+ import classNames from 'classnames';
8
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
9
+ import { faSpinner } from '@fortawesome/free-solid-svg-icons';
10
+ import { PropTypes as PropTypes$1 } from '@micromag/core';
11
+ import { useScreenSize, useViewer, useScreenRenderContext } from '@micromag/core/contexts';
12
+ import { useTrackScreenEvent, useResizeObserver } from '@micromag/core/hooks';
13
+ import { ScreenElement, Transitions } from '@micromag/core/components';
14
+ import { isTextFilled, isLabelFilled, getStyleFromColor } from '@micromag/core/utils';
15
+ import { useContributionCreate, useContributions } from '@micromag/data';
16
+ import Background from '@micromag/element-background';
17
+ import Button from '@micromag/element-button';
18
+ import Container from '@micromag/element-container';
19
+ import Heading from '@micromag/element-heading';
20
+ import Scroll from '@micromag/element-scroll';
21
+ import CallToAction from '@micromag/element-call-to-action';
22
+ import Text from '@micromag/element-text';
23
+ import TextInput from '@micromag/element-text-input';
24
+
25
+ var styles = {"container":"micromag-screen-contribution-container","content":"micromag-screen-contribution-content","emptyInputMessage":"micromag-screen-contribution-emptyInputMessage","emptyInputName":"micromag-screen-contribution-emptyInputName","emptySubmit":"micromag-screen-contribution-emptySubmit","emptyTitle":"micromag-screen-contribution-emptyTitle","title":"micromag-screen-contribution-title","interactiveContainer":"micromag-screen-contribution-interactiveContainer","form":"micromag-screen-contribution-form","buttonSubmit":"micromag-screen-contribution-buttonSubmit","inputMessage":"micromag-screen-contribution-inputMessage","inputName":"micromag-screen-contribution-inputName","formContent":"micromag-screen-contribution-formContent","formLoading":"micromag-screen-contribution-formLoading","rotate":"micromag-screen-contribution-rotate","loadingIcon":"micromag-screen-contribution-loadingIcon","contributionsContainer":"micromag-screen-contribution-contributionsContainer","contributionsContent":"micromag-screen-contribution-contributionsContent","contributions":"micromag-screen-contribution-contributions","contribution":"micromag-screen-contribution-contribution","callToAction":"micromag-screen-contribution-callToAction","submitting":"micromag-screen-contribution-submitting","submitted":"micromag-screen-contribution-submitted","showContributions":"micromag-screen-contribution-showContributions","isPlaceholder":"micromag-screen-contribution-isPlaceholder"};
26
+
27
+ var propTypes = {
28
+ id: PropTypes.string,
29
+ layout: PropTypes.oneOf(['top', 'middle', 'bottom']),
30
+ title: PropTypes$1.headingElement,
31
+ name: PropTypes$1.inputElement,
32
+ message: PropTypes$1.inputElement,
33
+ submit: PropTypes$1.textElement,
34
+ nameStyle: PropTypes$1.textStyle,
35
+ messageStyle: PropTypes$1.textStyle,
36
+ spacing: PropTypes.number,
37
+ background: PropTypes$1.backgroundElement,
38
+ callToAction: PropTypes$1.callToAction,
39
+ current: PropTypes.bool,
40
+ transitions: PropTypes$1.transitions,
41
+ transitionStagger: PropTypes.number,
42
+ resizeTransitionDuration: PropTypes.number,
43
+ type: PropTypes.string,
44
+ className: PropTypes.string
45
+ };
46
+ var defaultProps = {
47
+ id: null,
48
+ layout: 'middle',
49
+ title: null,
50
+ name: null,
51
+ message: null,
52
+ submit: null,
53
+ nameStyle: null,
54
+ messageStyle: null,
55
+ spacing: 20,
56
+ background: null,
57
+ callToAction: null,
58
+ current: true,
59
+ transitions: null,
60
+ transitionStagger: 100,
61
+ resizeTransitionDuration: 750,
62
+ type: null,
63
+ className: null
64
+ };
65
+
66
+ var ContributionScreen = function ContributionScreen(_ref) {
67
+ var _ref4;
68
+
69
+ var id = _ref.id,
70
+ layout = _ref.layout,
71
+ title = _ref.title,
72
+ name = _ref.name,
73
+ message = _ref.message,
74
+ submit = _ref.submit,
75
+ nameStyle = _ref.nameStyle,
76
+ messageStyle = _ref.messageStyle,
77
+ spacing = _ref.spacing,
78
+ background = _ref.background,
79
+ callToAction = _ref.callToAction,
80
+ current = _ref.current,
81
+ transitions = _ref.transitions,
82
+ transitionStagger = _ref.transitionStagger,
83
+ resizeTransitionDuration = _ref.resizeTransitionDuration,
84
+ type = _ref.type,
85
+ className = _ref.className;
86
+ var screenId = id || 'screen-id';
87
+ var trackScreenEvent = useTrackScreenEvent(type);
88
+
89
+ var _useScreenSize = useScreenSize(),
90
+ width = _useScreenSize.width,
91
+ height = _useScreenSize.height,
92
+ menuOverScreen = _useScreenSize.menuOverScreen;
93
+
94
+ var _useViewer = useViewer(),
95
+ menuSize = _useViewer.menuSize;
96
+
97
+ var _useScreenRenderConte = useScreenRenderContext(),
98
+ isView = _useScreenRenderConte.isView,
99
+ isPreview = _useScreenRenderConte.isPreview,
100
+ isPlaceholder = _useScreenRenderConte.isPlaceholder,
101
+ isEdit = _useScreenRenderConte.isEdit,
102
+ isStatic = _useScreenRenderConte.isStatic,
103
+ isCapture = _useScreenRenderConte.isCapture;
104
+
105
+ var backgroundPlaying = current && (isView || isEdit);
106
+ var transitionPlaying = current;
107
+ var transitionDisabled = isStatic || isCapture || isPlaceholder || isPreview || isEdit;
108
+ var scrollingDisabled = !isEdit && transitionDisabled || !current;
109
+ var hasTitle = isTextFilled(title);
110
+ var hasNameLabel = isLabelFilled(name);
111
+ var hasMessageLabel = isLabelFilled(message);
112
+ var hasSubmit = isTextFilled(submit);
113
+ var contributionsRef = useRef(null);
114
+ var formRef = useRef(null);
115
+
116
+ var _useState = useState(null),
117
+ _useState2 = _slicedToArray(_useState, 2),
118
+ interactiveContainerHeight = _useState2[0],
119
+ setInteractiveContainerHeight = _useState2[1];
120
+
121
+ var _useState3 = useState(''),
122
+ _useState4 = _slicedToArray(_useState3, 2),
123
+ userName = _useState4[0],
124
+ setUserName = _useState4[1];
125
+
126
+ var _useState5 = useState(''),
127
+ _useState6 = _slicedToArray(_useState5, 2),
128
+ userMessage = _useState6[0],
129
+ setUserMessage = _useState6[1]; // 0 = default, 1 = submitting, 2 = submitted, 3 = resizing, 4 = done
130
+
131
+
132
+ var _useState7 = useState(isStatic || isCapture ? 4 : 0),
133
+ _useState8 = _slicedToArray(_useState7, 2),
134
+ submitState = _useState8[0],
135
+ setSubmitState = _useState8[1];
136
+
137
+ var onContributionSubmitted = useCallback(function () {
138
+ setSubmitState(2);
139
+ trackScreenEvent('submit_success', "".concat(userName, ": ").concat(userMessage));
140
+ }, [setSubmitState, trackScreenEvent, userName, userMessage]);
141
+
142
+ var _useContributionCreat = useContributionCreate({
143
+ screenId: screenId
144
+ }),
145
+ submitContribution = _useContributionCreat.create;
146
+
147
+ var _useContributions = useContributions({
148
+ screenId: screenId,
149
+ opts: {
150
+ autoload: !isPlaceholder
151
+ }
152
+ }),
153
+ contributions = _useContributions.contributions;
154
+
155
+ var onNameChange = useCallback(function (e) {
156
+ setUserName(e.currentTarget.value);
157
+ }, [setUserName]);
158
+ var onMessageChange = useCallback(function (e) {
159
+ setUserMessage(e.currentTarget.value);
160
+ }, [setUserMessage]);
161
+ var nameFilled = useRef(false);
162
+ var onNameBlur = useCallback(function (e) {
163
+ if (!nameFilled.current && e.currentTarget.value.length > 0) {
164
+ nameFilled.current = true;
165
+ trackScreenEvent('input_filled', 'Name', {
166
+ userName: e.currentTarget.value,
167
+ userMessage: userMessage
168
+ });
169
+ }
170
+ }, [trackScreenEvent, userMessage]);
171
+ var messageFilled = useRef(false);
172
+ var onMessageBlur = useCallback(function (e) {
173
+ if (!messageFilled.current && e.currentTarget.value.length > 0) {
174
+ messageFilled.current = true;
175
+ trackScreenEvent('input_filled', 'Message', {
176
+ userName: userName,
177
+ userMessage: e.currentTarget.value
178
+ });
179
+ }
180
+ }, [trackScreenEvent, userName]); // Call to Action
181
+
182
+ var hasCallToAction = callToAction !== null && callToAction.active === true;
183
+
184
+ var _useState9 = useState(false),
185
+ _useState10 = _slicedToArray(_useState9, 2),
186
+ scrolledBottom = _useState10[0],
187
+ setScrolledBottom = _useState10[1];
188
+
189
+ var swipeUpLinkActive = scrolledBottom && submitState === 4;
190
+
191
+ var _useResizeObserver = useResizeObserver(),
192
+ callToActionRef = _useResizeObserver.ref,
193
+ callToActionRect = _useResizeObserver.entry.contentRect;
194
+
195
+ var _ref2 = callToActionRect || {},
196
+ _ref2$height = _ref2.height,
197
+ callToActionHeight = _ref2$height === void 0 ? 0 : _ref2$height;
198
+
199
+ var onScrolledBottom = useCallback(function (_ref3) {
200
+ var initial = _ref3.initial;
201
+
202
+ if (initial) {
203
+ trackScreenEvent('scroll', 'Contributions list');
204
+ }
205
+
206
+ setScrolledBottom(true);
207
+ }, [trackScreenEvent, setScrolledBottom]);
208
+ var onScrolledNotBottom = useCallback(function () {
209
+ setScrolledBottom(false);
210
+ }, [setScrolledBottom]);
211
+ var onSubmit = useCallback(function (e) {
212
+ e.preventDefault();
213
+
214
+ if (submitState === 0) {
215
+ setInteractiveContainerHeight(formRef.current.offsetHeight);
216
+ setSubmitState(1);
217
+ submitContribution({
218
+ name: userName,
219
+ message: userMessage
220
+ });
221
+ onContributionSubmitted();
222
+ trackScreenEvent('click_submit', "".concat(userName, ": ").concat(userMessage), {
223
+ userName: userName,
224
+ userMessage: userMessage
225
+ });
226
+ }
227
+ }, [submitState, setSubmitState, userName, userMessage, trackScreenEvent, onContributionSubmitted]);
228
+ useEffect(function () {
229
+ var timeout = null;
230
+
231
+ if (submitState === 2) {
232
+ timeout = setTimeout(setSubmitState, resizeTransitionDuration, 4);
233
+ setInteractiveContainerHeight(contributionsRef.current.offsetHeight);
234
+ setSubmitState(3);
235
+ }
236
+
237
+ return function () {
238
+ if (submitState === 3 && timeout !== null) {
239
+ clearTimeout(timeout);
240
+ }
241
+ };
242
+ }, [submitState, setInteractiveContainerHeight, setSubmitState, resizeTransitionDuration]); // Title
243
+
244
+ var items = [/*#__PURE__*/React.createElement(ScreenElement, {
245
+ key: "title",
246
+ placeholder: "title",
247
+ placeholderProps: {
248
+ height: '0.75em'
249
+ },
250
+ emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
251
+ id: "2ZOPe+",
252
+ defaultMessage: [{
253
+ "type": 0,
254
+ "value": "Title"
255
+ }]
256
+ }),
257
+ emptyClassName: styles.emptyTitle,
258
+ isEmpty: !hasTitle
259
+ }, hasTitle ? /*#__PURE__*/React.createElement(Transitions, {
260
+ transitions: transitions,
261
+ playing: transitionPlaying,
262
+ disabled: transitionDisabled
263
+ }, /*#__PURE__*/React.createElement(Heading, Object.assign({}, title, {
264
+ className: styles.title
265
+ }))) : null)];
266
+ var allContributions = [].concat(_toConsumableArray(userName !== null && userMessage !== null ? [{
267
+ name: userName,
268
+ message: userMessage
269
+ }] : []), _toConsumableArray(contributions || [])); // Form
270
+
271
+ items.push( /*#__PURE__*/React.createElement("div", {
272
+ key: "form",
273
+ className: styles.interactiveContainer,
274
+ style: {
275
+ height: submitState < 4 ? interactiveContainerHeight : null,
276
+ transitionDuration: "".concat(resizeTransitionDuration, "ms")
277
+ }
278
+ }, /*#__PURE__*/React.createElement("form", {
279
+ className: styles.form,
280
+ onSubmit: onSubmit,
281
+ ref: formRef
282
+ }, /*#__PURE__*/React.createElement("div", {
283
+ className: styles.formContent
284
+ }, /*#__PURE__*/React.createElement(ScreenElement, {
285
+ placeholder: "inputText",
286
+ placeholderProps: {
287
+ height: '0.25em'
288
+ },
289
+ emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
290
+ id: "G/ITGY",
291
+ defaultMessage: [{
292
+ "type": 0,
293
+ "value": "Your name"
294
+ }]
295
+ }),
296
+ emptyClassName: styles.emptyInputName,
297
+ isEmpty: !hasNameLabel
298
+ }, /*#__PURE__*/React.createElement(Transitions, {
299
+ transitions: transitions,
300
+ playing: transitionPlaying,
301
+ delay: transitionStagger,
302
+ disabled: transitionDisabled
303
+ }, /*#__PURE__*/React.createElement(TextInput, Object.assign({
304
+ className: styles.inputName
305
+ }, name, {
306
+ value: userName,
307
+ onChange: function onChange(e) {
308
+ return onNameChange(e);
309
+ },
310
+ onBlur: function onBlur(e) {
311
+ return onNameBlur(e);
312
+ },
313
+ disabled: isPreview,
314
+ required: true
315
+ })))), /*#__PURE__*/React.createElement(ScreenElement, {
316
+ placeholder: "inputText",
317
+ placeholderProps: {
318
+ height: '0.75em'
319
+ },
320
+ emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
321
+ id: "JAguka",
322
+ defaultMessage: [{
323
+ "type": 0,
324
+ "value": "Your message"
325
+ }]
326
+ }),
327
+ emptyClassName: styles.emptyInputMessage,
328
+ isEmpty: !hasMessageLabel
329
+ }, /*#__PURE__*/React.createElement(Transitions, {
330
+ transitions: transitions,
331
+ playing: transitionPlaying,
332
+ delay: transitionStagger * 2,
333
+ disabled: transitionDisabled
334
+ }, /*#__PURE__*/React.createElement(TextInput, Object.assign({
335
+ className: styles.inputMessage
336
+ }, message, {
337
+ value: userMessage,
338
+ onChange: function onChange(e) {
339
+ return onMessageChange(e);
340
+ },
341
+ onBlur: function onBlur(e) {
342
+ return onMessageBlur(e);
343
+ },
344
+ disabled: isPreview,
345
+ multiline: true,
346
+ required: true
347
+ })))), /*#__PURE__*/React.createElement(ScreenElement, {
348
+ placeholder: "button",
349
+ emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
350
+ id: "5uH4x7",
351
+ defaultMessage: [{
352
+ "type": 0,
353
+ "value": "Submit"
354
+ }]
355
+ }),
356
+ emptyClassName: styles.emptySubmit,
357
+ isEmpty: !hasSubmit
358
+ }, /*#__PURE__*/React.createElement(Transitions, {
359
+ transitions: transitions,
360
+ playing: transitionPlaying,
361
+ delay: transitionStagger * 3,
362
+ disabled: transitionDisabled
363
+ }, /*#__PURE__*/React.createElement(Button, {
364
+ type: "submit",
365
+ className: styles.buttonSubmit,
366
+ disabled: isPreview,
367
+ buttonStyle: submit !== null ? submit.buttonStyle : null
368
+ }, /*#__PURE__*/React.createElement(Text, Object.assign({}, submit, {
369
+ inline: true
370
+ })))))), /*#__PURE__*/React.createElement("div", {
371
+ className: styles.formLoading
372
+ }, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
373
+ className: styles.loadingIcon,
374
+ icon: faSpinner
375
+ }))), /*#__PURE__*/React.createElement("div", {
376
+ className: styles.contributionsContainer
377
+ }, /*#__PURE__*/React.createElement("div", {
378
+ className: styles.contributionsContent
379
+ }, /*#__PURE__*/React.createElement("div", {
380
+ className: styles.contributions,
381
+ ref: contributionsRef
382
+ }, allContributions.map(function (contribution, contributionIndex) {
383
+ var nameInnerStyle = nameStyle !== null ? nameStyle.style || null : null;
384
+ var messageInnerStyle = messageStyle !== null ? messageStyle.style || null : null;
385
+ return /*#__PURE__*/React.createElement("div", {
386
+ key: "contribution-".concat(contributionIndex),
387
+ className: styles.contribution,
388
+ style: nameInnerStyle !== null ? getStyleFromColor(nameInnerStyle.color, 'borderColor') : null
389
+ }, /*#__PURE__*/React.createElement(Heading, {
390
+ className: styles.contributionName,
391
+ body: contribution.name,
392
+ size: 2,
393
+ textStyle: nameInnerStyle
394
+ }), /*#__PURE__*/React.createElement(Text, {
395
+ className: styles.contributionMessage,
396
+ body: contribution.message,
397
+ textStyle: messageInnerStyle
398
+ }));
399
+ })))), hasCallToAction ? /*#__PURE__*/React.createElement("div", {
400
+ style: {
401
+ height: callToActionHeight
402
+ }
403
+ }) : null));
404
+ return /*#__PURE__*/React.createElement("div", {
405
+ className: classNames([styles.container, (_ref4 = {}, _defineProperty(_ref4, className, className !== null), _defineProperty(_ref4, styles.isPlaceholder, isPlaceholder), _defineProperty(_ref4, styles.submitting, submitState === 1), _defineProperty(_ref4, styles.submitted, submitState > 1), _defineProperty(_ref4, styles.showContributions, submitState === 4), _ref4)]),
406
+ "data-screen-ready": true
407
+ }, !isPlaceholder ? /*#__PURE__*/React.createElement(Background, Object.assign({}, background, {
408
+ width: width,
409
+ height: height,
410
+ playing: backgroundPlaying
411
+ })) : null, /*#__PURE__*/React.createElement(Container, {
412
+ width: width,
413
+ height: height
414
+ }, /*#__PURE__*/React.createElement("div", {
415
+ className: styles.content,
416
+ style: !isPlaceholder ? {
417
+ padding: spacing,
418
+ paddingTop: (menuOverScreen && !isPreview ? menuSize : 0) + spacing
419
+ } : null
420
+ }, /*#__PURE__*/React.createElement(Scroll, {
421
+ verticalAlign: layout,
422
+ disabled: scrollingDisabled,
423
+ onScrolledBottom: onScrolledBottom,
424
+ onScrolledNotBottom: onScrolledNotBottom
425
+ }, items), !isPlaceholder && hasCallToAction ? /*#__PURE__*/React.createElement(CallToAction, {
426
+ ref: callToActionRef,
427
+ className: styles.callToAction,
428
+ disabled: !swipeUpLinkActive,
429
+ animationDisabled: isPreview,
430
+ callToAction: callToAction
431
+ }) : null)));
432
+ };
433
+
434
+ ContributionScreen.propTypes = propTypes;
435
+ ContributionScreen.defaultProps = defaultProps;
436
+
437
+ var definition = {
438
+ id: 'contribution',
439
+ type: 'screen',
440
+ group: {
441
+ label: defineMessage({
442
+ "id": "ZqwBOx",
443
+ "defaultMessage": [{
444
+ "type": 0,
445
+ "value": "Questions"
446
+ }]
447
+ }),
448
+ order: 7
449
+ },
450
+ title: defineMessage({
451
+ "id": "g6b9Lg",
452
+ "defaultMessage": [{
453
+ "type": 0,
454
+ "value": "Contribution"
455
+ }]
456
+ }),
457
+ component: ContributionScreen,
458
+ layouts: ['top', 'middle', 'bottom'],
459
+ fields: [{
460
+ name: 'layout',
461
+ type: 'screen-layout',
462
+ defaultValue: 'top',
463
+ label: defineMessage({
464
+ "id": "4iBXj2",
465
+ "defaultMessage": [{
466
+ "type": 0,
467
+ "value": "Layout"
468
+ }]
469
+ })
470
+ }, {
471
+ name: 'title',
472
+ type: 'heading-element',
473
+ theme: {
474
+ textStyle: 'heading2'
475
+ },
476
+ label: defineMessage({
477
+ "id": "N25iDO",
478
+ "defaultMessage": [{
479
+ "type": 0,
480
+ "value": "Title"
481
+ }]
482
+ })
483
+ }, {
484
+ name: 'name',
485
+ type: 'input-element',
486
+ theme: {
487
+ textStyle: 'text'
488
+ },
489
+ label: defineMessage({
490
+ "id": "nXVNeg",
491
+ "defaultMessage": [{
492
+ "type": 0,
493
+ "value": "Name"
494
+ }]
495
+ })
496
+ }, {
497
+ name: 'message',
498
+ type: 'input-element',
499
+ theme: {
500
+ textStyle: 'text'
501
+ },
502
+ label: defineMessage({
503
+ "id": "RcLsua",
504
+ "defaultMessage": [{
505
+ "type": 0,
506
+ "value": "Message"
507
+ }]
508
+ })
509
+ }, {
510
+ name: 'submit',
511
+ type: 'button-element',
512
+ theme: {
513
+ textStyle: 'button'
514
+ },
515
+ label: defineMessage({
516
+ "id": "uAKPQ9",
517
+ "defaultMessage": [{
518
+ "type": 0,
519
+ "value": "Submit"
520
+ }]
521
+ })
522
+ }, {
523
+ name: 'nameStyle',
524
+ type: 'item-text-style',
525
+ theme: {
526
+ style: {
527
+ textStyle: 'heading2'
528
+ }
529
+ },
530
+ label: defineMessage({
531
+ "id": "SyMSDa",
532
+ "defaultMessage": [{
533
+ "type": 0,
534
+ "value": "Published name style"
535
+ }]
536
+ })
537
+ }, {
538
+ name: 'messageStyle',
539
+ type: 'item-text-style',
540
+ theme: {
541
+ style: {
542
+ textStyle: 'text'
543
+ }
544
+ },
545
+ label: defineMessage({
546
+ "id": "+SlKOi",
547
+ "defaultMessage": [{
548
+ "type": 0,
549
+ "value": "Published message style"
550
+ }]
551
+ })
552
+ }, {
553
+ name: 'background',
554
+ type: 'background',
555
+ label: defineMessage({
556
+ "id": "+MPZRu",
557
+ "defaultMessage": [{
558
+ "type": 0,
559
+ "value": "Background"
560
+ }]
561
+ })
562
+ }, {
563
+ name: 'callToAction',
564
+ type: 'call-to-action',
565
+ theme: {
566
+ label: {
567
+ textStyle: 'heading2'
568
+ }
569
+ }
570
+ }]
571
+ };
572
+
573
+ export default definition;
574
+ export { ContributionScreen };
package/lib/index.js ADDED
@@ -0,0 +1,595 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var reactIntl = require('react-intl');
6
+ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
7
+ var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
8
+ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
9
+ var React = require('react');
10
+ var PropTypes = require('prop-types');
11
+ var classNames = require('classnames');
12
+ var reactFontawesome = require('@fortawesome/react-fontawesome');
13
+ var freeSolidSvgIcons = require('@fortawesome/free-solid-svg-icons');
14
+ var core = require('@micromag/core');
15
+ var contexts = require('@micromag/core/contexts');
16
+ var hooks = require('@micromag/core/hooks');
17
+ var components = require('@micromag/core/components');
18
+ var utils = require('@micromag/core/utils');
19
+ var data = require('@micromag/data');
20
+ var Background = require('@micromag/element-background');
21
+ var Button = require('@micromag/element-button');
22
+ var Container = require('@micromag/element-container');
23
+ var Heading = require('@micromag/element-heading');
24
+ var Scroll = require('@micromag/element-scroll');
25
+ var CallToAction = require('@micromag/element-call-to-action');
26
+ var Text = require('@micromag/element-text');
27
+ var TextInput = require('@micromag/element-text-input');
28
+
29
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
30
+
31
+ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
32
+ var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
33
+ var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
34
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
35
+ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
36
+ var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
37
+ var Background__default = /*#__PURE__*/_interopDefaultLegacy(Background);
38
+ var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
39
+ var Container__default = /*#__PURE__*/_interopDefaultLegacy(Container);
40
+ var Heading__default = /*#__PURE__*/_interopDefaultLegacy(Heading);
41
+ var Scroll__default = /*#__PURE__*/_interopDefaultLegacy(Scroll);
42
+ var CallToAction__default = /*#__PURE__*/_interopDefaultLegacy(CallToAction);
43
+ var Text__default = /*#__PURE__*/_interopDefaultLegacy(Text);
44
+ var TextInput__default = /*#__PURE__*/_interopDefaultLegacy(TextInput);
45
+
46
+ var styles = {"container":"micromag-screen-contribution-container","content":"micromag-screen-contribution-content","emptyInputMessage":"micromag-screen-contribution-emptyInputMessage","emptyInputName":"micromag-screen-contribution-emptyInputName","emptySubmit":"micromag-screen-contribution-emptySubmit","emptyTitle":"micromag-screen-contribution-emptyTitle","title":"micromag-screen-contribution-title","interactiveContainer":"micromag-screen-contribution-interactiveContainer","form":"micromag-screen-contribution-form","buttonSubmit":"micromag-screen-contribution-buttonSubmit","inputMessage":"micromag-screen-contribution-inputMessage","inputName":"micromag-screen-contribution-inputName","formContent":"micromag-screen-contribution-formContent","formLoading":"micromag-screen-contribution-formLoading","rotate":"micromag-screen-contribution-rotate","loadingIcon":"micromag-screen-contribution-loadingIcon","contributionsContainer":"micromag-screen-contribution-contributionsContainer","contributionsContent":"micromag-screen-contribution-contributionsContent","contributions":"micromag-screen-contribution-contributions","contribution":"micromag-screen-contribution-contribution","callToAction":"micromag-screen-contribution-callToAction","submitting":"micromag-screen-contribution-submitting","submitted":"micromag-screen-contribution-submitted","showContributions":"micromag-screen-contribution-showContributions","isPlaceholder":"micromag-screen-contribution-isPlaceholder"};
47
+
48
+ var propTypes = {
49
+ id: PropTypes__default['default'].string,
50
+ layout: PropTypes__default['default'].oneOf(['top', 'middle', 'bottom']),
51
+ title: core.PropTypes.headingElement,
52
+ name: core.PropTypes.inputElement,
53
+ message: core.PropTypes.inputElement,
54
+ submit: core.PropTypes.textElement,
55
+ nameStyle: core.PropTypes.textStyle,
56
+ messageStyle: core.PropTypes.textStyle,
57
+ spacing: PropTypes__default['default'].number,
58
+ background: core.PropTypes.backgroundElement,
59
+ callToAction: core.PropTypes.callToAction,
60
+ current: PropTypes__default['default'].bool,
61
+ transitions: core.PropTypes.transitions,
62
+ transitionStagger: PropTypes__default['default'].number,
63
+ resizeTransitionDuration: PropTypes__default['default'].number,
64
+ type: PropTypes__default['default'].string,
65
+ className: PropTypes__default['default'].string
66
+ };
67
+ var defaultProps = {
68
+ id: null,
69
+ layout: 'middle',
70
+ title: null,
71
+ name: null,
72
+ message: null,
73
+ submit: null,
74
+ nameStyle: null,
75
+ messageStyle: null,
76
+ spacing: 20,
77
+ background: null,
78
+ callToAction: null,
79
+ current: true,
80
+ transitions: null,
81
+ transitionStagger: 100,
82
+ resizeTransitionDuration: 750,
83
+ type: null,
84
+ className: null
85
+ };
86
+
87
+ var ContributionScreen = function ContributionScreen(_ref) {
88
+ var _ref4;
89
+
90
+ var id = _ref.id,
91
+ layout = _ref.layout,
92
+ title = _ref.title,
93
+ name = _ref.name,
94
+ message = _ref.message,
95
+ submit = _ref.submit,
96
+ nameStyle = _ref.nameStyle,
97
+ messageStyle = _ref.messageStyle,
98
+ spacing = _ref.spacing,
99
+ background = _ref.background,
100
+ callToAction = _ref.callToAction,
101
+ current = _ref.current,
102
+ transitions = _ref.transitions,
103
+ transitionStagger = _ref.transitionStagger,
104
+ resizeTransitionDuration = _ref.resizeTransitionDuration,
105
+ type = _ref.type,
106
+ className = _ref.className;
107
+ var screenId = id || 'screen-id';
108
+ var trackScreenEvent = hooks.useTrackScreenEvent(type);
109
+
110
+ var _useScreenSize = contexts.useScreenSize(),
111
+ width = _useScreenSize.width,
112
+ height = _useScreenSize.height,
113
+ menuOverScreen = _useScreenSize.menuOverScreen;
114
+
115
+ var _useViewer = contexts.useViewer(),
116
+ menuSize = _useViewer.menuSize;
117
+
118
+ var _useScreenRenderConte = contexts.useScreenRenderContext(),
119
+ isView = _useScreenRenderConte.isView,
120
+ isPreview = _useScreenRenderConte.isPreview,
121
+ isPlaceholder = _useScreenRenderConte.isPlaceholder,
122
+ isEdit = _useScreenRenderConte.isEdit,
123
+ isStatic = _useScreenRenderConte.isStatic,
124
+ isCapture = _useScreenRenderConte.isCapture;
125
+
126
+ var backgroundPlaying = current && (isView || isEdit);
127
+ var transitionPlaying = current;
128
+ var transitionDisabled = isStatic || isCapture || isPlaceholder || isPreview || isEdit;
129
+ var scrollingDisabled = !isEdit && transitionDisabled || !current;
130
+ var hasTitle = utils.isTextFilled(title);
131
+ var hasNameLabel = utils.isLabelFilled(name);
132
+ var hasMessageLabel = utils.isLabelFilled(message);
133
+ var hasSubmit = utils.isTextFilled(submit);
134
+ var contributionsRef = React.useRef(null);
135
+ var formRef = React.useRef(null);
136
+
137
+ var _useState = React.useState(null),
138
+ _useState2 = _slicedToArray__default['default'](_useState, 2),
139
+ interactiveContainerHeight = _useState2[0],
140
+ setInteractiveContainerHeight = _useState2[1];
141
+
142
+ var _useState3 = React.useState(''),
143
+ _useState4 = _slicedToArray__default['default'](_useState3, 2),
144
+ userName = _useState4[0],
145
+ setUserName = _useState4[1];
146
+
147
+ var _useState5 = React.useState(''),
148
+ _useState6 = _slicedToArray__default['default'](_useState5, 2),
149
+ userMessage = _useState6[0],
150
+ setUserMessage = _useState6[1]; // 0 = default, 1 = submitting, 2 = submitted, 3 = resizing, 4 = done
151
+
152
+
153
+ var _useState7 = React.useState(isStatic || isCapture ? 4 : 0),
154
+ _useState8 = _slicedToArray__default['default'](_useState7, 2),
155
+ submitState = _useState8[0],
156
+ setSubmitState = _useState8[1];
157
+
158
+ var onContributionSubmitted = React.useCallback(function () {
159
+ setSubmitState(2);
160
+ trackScreenEvent('submit_success', "".concat(userName, ": ").concat(userMessage));
161
+ }, [setSubmitState, trackScreenEvent, userName, userMessage]);
162
+
163
+ var _useContributionCreat = data.useContributionCreate({
164
+ screenId: screenId
165
+ }),
166
+ submitContribution = _useContributionCreat.create;
167
+
168
+ var _useContributions = data.useContributions({
169
+ screenId: screenId,
170
+ opts: {
171
+ autoload: !isPlaceholder
172
+ }
173
+ }),
174
+ contributions = _useContributions.contributions;
175
+
176
+ var onNameChange = React.useCallback(function (e) {
177
+ setUserName(e.currentTarget.value);
178
+ }, [setUserName]);
179
+ var onMessageChange = React.useCallback(function (e) {
180
+ setUserMessage(e.currentTarget.value);
181
+ }, [setUserMessage]);
182
+ var nameFilled = React.useRef(false);
183
+ var onNameBlur = React.useCallback(function (e) {
184
+ if (!nameFilled.current && e.currentTarget.value.length > 0) {
185
+ nameFilled.current = true;
186
+ trackScreenEvent('input_filled', 'Name', {
187
+ userName: e.currentTarget.value,
188
+ userMessage: userMessage
189
+ });
190
+ }
191
+ }, [trackScreenEvent, userMessage]);
192
+ var messageFilled = React.useRef(false);
193
+ var onMessageBlur = React.useCallback(function (e) {
194
+ if (!messageFilled.current && e.currentTarget.value.length > 0) {
195
+ messageFilled.current = true;
196
+ trackScreenEvent('input_filled', 'Message', {
197
+ userName: userName,
198
+ userMessage: e.currentTarget.value
199
+ });
200
+ }
201
+ }, [trackScreenEvent, userName]); // Call to Action
202
+
203
+ var hasCallToAction = callToAction !== null && callToAction.active === true;
204
+
205
+ var _useState9 = React.useState(false),
206
+ _useState10 = _slicedToArray__default['default'](_useState9, 2),
207
+ scrolledBottom = _useState10[0],
208
+ setScrolledBottom = _useState10[1];
209
+
210
+ var swipeUpLinkActive = scrolledBottom && submitState === 4;
211
+
212
+ var _useResizeObserver = hooks.useResizeObserver(),
213
+ callToActionRef = _useResizeObserver.ref,
214
+ callToActionRect = _useResizeObserver.entry.contentRect;
215
+
216
+ var _ref2 = callToActionRect || {},
217
+ _ref2$height = _ref2.height,
218
+ callToActionHeight = _ref2$height === void 0 ? 0 : _ref2$height;
219
+
220
+ var onScrolledBottom = React.useCallback(function (_ref3) {
221
+ var initial = _ref3.initial;
222
+
223
+ if (initial) {
224
+ trackScreenEvent('scroll', 'Contributions list');
225
+ }
226
+
227
+ setScrolledBottom(true);
228
+ }, [trackScreenEvent, setScrolledBottom]);
229
+ var onScrolledNotBottom = React.useCallback(function () {
230
+ setScrolledBottom(false);
231
+ }, [setScrolledBottom]);
232
+ var onSubmit = React.useCallback(function (e) {
233
+ e.preventDefault();
234
+
235
+ if (submitState === 0) {
236
+ setInteractiveContainerHeight(formRef.current.offsetHeight);
237
+ setSubmitState(1);
238
+ submitContribution({
239
+ name: userName,
240
+ message: userMessage
241
+ });
242
+ onContributionSubmitted();
243
+ trackScreenEvent('click_submit', "".concat(userName, ": ").concat(userMessage), {
244
+ userName: userName,
245
+ userMessage: userMessage
246
+ });
247
+ }
248
+ }, [submitState, setSubmitState, userName, userMessage, trackScreenEvent, onContributionSubmitted]);
249
+ React.useEffect(function () {
250
+ var timeout = null;
251
+
252
+ if (submitState === 2) {
253
+ timeout = setTimeout(setSubmitState, resizeTransitionDuration, 4);
254
+ setInteractiveContainerHeight(contributionsRef.current.offsetHeight);
255
+ setSubmitState(3);
256
+ }
257
+
258
+ return function () {
259
+ if (submitState === 3 && timeout !== null) {
260
+ clearTimeout(timeout);
261
+ }
262
+ };
263
+ }, [submitState, setInteractiveContainerHeight, setSubmitState, resizeTransitionDuration]); // Title
264
+
265
+ var items = [/*#__PURE__*/React__default['default'].createElement(components.ScreenElement, {
266
+ key: "title",
267
+ placeholder: "title",
268
+ placeholderProps: {
269
+ height: '0.75em'
270
+ },
271
+ emptyLabel: /*#__PURE__*/React__default['default'].createElement(reactIntl.FormattedMessage, {
272
+ id: "2ZOPe+",
273
+ defaultMessage: [{
274
+ "type": 0,
275
+ "value": "Title"
276
+ }]
277
+ }),
278
+ emptyClassName: styles.emptyTitle,
279
+ isEmpty: !hasTitle
280
+ }, hasTitle ? /*#__PURE__*/React__default['default'].createElement(components.Transitions, {
281
+ transitions: transitions,
282
+ playing: transitionPlaying,
283
+ disabled: transitionDisabled
284
+ }, /*#__PURE__*/React__default['default'].createElement(Heading__default['default'], Object.assign({}, title, {
285
+ className: styles.title
286
+ }))) : null)];
287
+ var allContributions = [].concat(_toConsumableArray__default['default'](userName !== null && userMessage !== null ? [{
288
+ name: userName,
289
+ message: userMessage
290
+ }] : []), _toConsumableArray__default['default'](contributions || [])); // Form
291
+
292
+ items.push( /*#__PURE__*/React__default['default'].createElement("div", {
293
+ key: "form",
294
+ className: styles.interactiveContainer,
295
+ style: {
296
+ height: submitState < 4 ? interactiveContainerHeight : null,
297
+ transitionDuration: "".concat(resizeTransitionDuration, "ms")
298
+ }
299
+ }, /*#__PURE__*/React__default['default'].createElement("form", {
300
+ className: styles.form,
301
+ onSubmit: onSubmit,
302
+ ref: formRef
303
+ }, /*#__PURE__*/React__default['default'].createElement("div", {
304
+ className: styles.formContent
305
+ }, /*#__PURE__*/React__default['default'].createElement(components.ScreenElement, {
306
+ placeholder: "inputText",
307
+ placeholderProps: {
308
+ height: '0.25em'
309
+ },
310
+ emptyLabel: /*#__PURE__*/React__default['default'].createElement(reactIntl.FormattedMessage, {
311
+ id: "G/ITGY",
312
+ defaultMessage: [{
313
+ "type": 0,
314
+ "value": "Your name"
315
+ }]
316
+ }),
317
+ emptyClassName: styles.emptyInputName,
318
+ isEmpty: !hasNameLabel
319
+ }, /*#__PURE__*/React__default['default'].createElement(components.Transitions, {
320
+ transitions: transitions,
321
+ playing: transitionPlaying,
322
+ delay: transitionStagger,
323
+ disabled: transitionDisabled
324
+ }, /*#__PURE__*/React__default['default'].createElement(TextInput__default['default'], Object.assign({
325
+ className: styles.inputName
326
+ }, name, {
327
+ value: userName,
328
+ onChange: function onChange(e) {
329
+ return onNameChange(e);
330
+ },
331
+ onBlur: function onBlur(e) {
332
+ return onNameBlur(e);
333
+ },
334
+ disabled: isPreview,
335
+ required: true
336
+ })))), /*#__PURE__*/React__default['default'].createElement(components.ScreenElement, {
337
+ placeholder: "inputText",
338
+ placeholderProps: {
339
+ height: '0.75em'
340
+ },
341
+ emptyLabel: /*#__PURE__*/React__default['default'].createElement(reactIntl.FormattedMessage, {
342
+ id: "JAguka",
343
+ defaultMessage: [{
344
+ "type": 0,
345
+ "value": "Your message"
346
+ }]
347
+ }),
348
+ emptyClassName: styles.emptyInputMessage,
349
+ isEmpty: !hasMessageLabel
350
+ }, /*#__PURE__*/React__default['default'].createElement(components.Transitions, {
351
+ transitions: transitions,
352
+ playing: transitionPlaying,
353
+ delay: transitionStagger * 2,
354
+ disabled: transitionDisabled
355
+ }, /*#__PURE__*/React__default['default'].createElement(TextInput__default['default'], Object.assign({
356
+ className: styles.inputMessage
357
+ }, message, {
358
+ value: userMessage,
359
+ onChange: function onChange(e) {
360
+ return onMessageChange(e);
361
+ },
362
+ onBlur: function onBlur(e) {
363
+ return onMessageBlur(e);
364
+ },
365
+ disabled: isPreview,
366
+ multiline: true,
367
+ required: true
368
+ })))), /*#__PURE__*/React__default['default'].createElement(components.ScreenElement, {
369
+ placeholder: "button",
370
+ emptyLabel: /*#__PURE__*/React__default['default'].createElement(reactIntl.FormattedMessage, {
371
+ id: "5uH4x7",
372
+ defaultMessage: [{
373
+ "type": 0,
374
+ "value": "Submit"
375
+ }]
376
+ }),
377
+ emptyClassName: styles.emptySubmit,
378
+ isEmpty: !hasSubmit
379
+ }, /*#__PURE__*/React__default['default'].createElement(components.Transitions, {
380
+ transitions: transitions,
381
+ playing: transitionPlaying,
382
+ delay: transitionStagger * 3,
383
+ disabled: transitionDisabled
384
+ }, /*#__PURE__*/React__default['default'].createElement(Button__default['default'], {
385
+ type: "submit",
386
+ className: styles.buttonSubmit,
387
+ disabled: isPreview,
388
+ buttonStyle: submit !== null ? submit.buttonStyle : null
389
+ }, /*#__PURE__*/React__default['default'].createElement(Text__default['default'], Object.assign({}, submit, {
390
+ inline: true
391
+ })))))), /*#__PURE__*/React__default['default'].createElement("div", {
392
+ className: styles.formLoading
393
+ }, /*#__PURE__*/React__default['default'].createElement(reactFontawesome.FontAwesomeIcon, {
394
+ className: styles.loadingIcon,
395
+ icon: freeSolidSvgIcons.faSpinner
396
+ }))), /*#__PURE__*/React__default['default'].createElement("div", {
397
+ className: styles.contributionsContainer
398
+ }, /*#__PURE__*/React__default['default'].createElement("div", {
399
+ className: styles.contributionsContent
400
+ }, /*#__PURE__*/React__default['default'].createElement("div", {
401
+ className: styles.contributions,
402
+ ref: contributionsRef
403
+ }, allContributions.map(function (contribution, contributionIndex) {
404
+ var nameInnerStyle = nameStyle !== null ? nameStyle.style || null : null;
405
+ var messageInnerStyle = messageStyle !== null ? messageStyle.style || null : null;
406
+ return /*#__PURE__*/React__default['default'].createElement("div", {
407
+ key: "contribution-".concat(contributionIndex),
408
+ className: styles.contribution,
409
+ style: nameInnerStyle !== null ? utils.getStyleFromColor(nameInnerStyle.color, 'borderColor') : null
410
+ }, /*#__PURE__*/React__default['default'].createElement(Heading__default['default'], {
411
+ className: styles.contributionName,
412
+ body: contribution.name,
413
+ size: 2,
414
+ textStyle: nameInnerStyle
415
+ }), /*#__PURE__*/React__default['default'].createElement(Text__default['default'], {
416
+ className: styles.contributionMessage,
417
+ body: contribution.message,
418
+ textStyle: messageInnerStyle
419
+ }));
420
+ })))), hasCallToAction ? /*#__PURE__*/React__default['default'].createElement("div", {
421
+ style: {
422
+ height: callToActionHeight
423
+ }
424
+ }) : null));
425
+ return /*#__PURE__*/React__default['default'].createElement("div", {
426
+ className: classNames__default['default']([styles.container, (_ref4 = {}, _defineProperty__default['default'](_ref4, className, className !== null), _defineProperty__default['default'](_ref4, styles.isPlaceholder, isPlaceholder), _defineProperty__default['default'](_ref4, styles.submitting, submitState === 1), _defineProperty__default['default'](_ref4, styles.submitted, submitState > 1), _defineProperty__default['default'](_ref4, styles.showContributions, submitState === 4), _ref4)]),
427
+ "data-screen-ready": true
428
+ }, !isPlaceholder ? /*#__PURE__*/React__default['default'].createElement(Background__default['default'], Object.assign({}, background, {
429
+ width: width,
430
+ height: height,
431
+ playing: backgroundPlaying
432
+ })) : null, /*#__PURE__*/React__default['default'].createElement(Container__default['default'], {
433
+ width: width,
434
+ height: height
435
+ }, /*#__PURE__*/React__default['default'].createElement("div", {
436
+ className: styles.content,
437
+ style: !isPlaceholder ? {
438
+ padding: spacing,
439
+ paddingTop: (menuOverScreen && !isPreview ? menuSize : 0) + spacing
440
+ } : null
441
+ }, /*#__PURE__*/React__default['default'].createElement(Scroll__default['default'], {
442
+ verticalAlign: layout,
443
+ disabled: scrollingDisabled,
444
+ onScrolledBottom: onScrolledBottom,
445
+ onScrolledNotBottom: onScrolledNotBottom
446
+ }, items), !isPlaceholder && hasCallToAction ? /*#__PURE__*/React__default['default'].createElement(CallToAction__default['default'], {
447
+ ref: callToActionRef,
448
+ className: styles.callToAction,
449
+ disabled: !swipeUpLinkActive,
450
+ animationDisabled: isPreview,
451
+ callToAction: callToAction
452
+ }) : null)));
453
+ };
454
+
455
+ ContributionScreen.propTypes = propTypes;
456
+ ContributionScreen.defaultProps = defaultProps;
457
+
458
+ var definition = {
459
+ id: 'contribution',
460
+ type: 'screen',
461
+ group: {
462
+ label: reactIntl.defineMessage({
463
+ "id": "ZqwBOx",
464
+ "defaultMessage": [{
465
+ "type": 0,
466
+ "value": "Questions"
467
+ }]
468
+ }),
469
+ order: 7
470
+ },
471
+ title: reactIntl.defineMessage({
472
+ "id": "g6b9Lg",
473
+ "defaultMessage": [{
474
+ "type": 0,
475
+ "value": "Contribution"
476
+ }]
477
+ }),
478
+ component: ContributionScreen,
479
+ layouts: ['top', 'middle', 'bottom'],
480
+ fields: [{
481
+ name: 'layout',
482
+ type: 'screen-layout',
483
+ defaultValue: 'top',
484
+ label: reactIntl.defineMessage({
485
+ "id": "4iBXj2",
486
+ "defaultMessage": [{
487
+ "type": 0,
488
+ "value": "Layout"
489
+ }]
490
+ })
491
+ }, {
492
+ name: 'title',
493
+ type: 'heading-element',
494
+ theme: {
495
+ textStyle: 'heading2'
496
+ },
497
+ label: reactIntl.defineMessage({
498
+ "id": "N25iDO",
499
+ "defaultMessage": [{
500
+ "type": 0,
501
+ "value": "Title"
502
+ }]
503
+ })
504
+ }, {
505
+ name: 'name',
506
+ type: 'input-element',
507
+ theme: {
508
+ textStyle: 'text'
509
+ },
510
+ label: reactIntl.defineMessage({
511
+ "id": "nXVNeg",
512
+ "defaultMessage": [{
513
+ "type": 0,
514
+ "value": "Name"
515
+ }]
516
+ })
517
+ }, {
518
+ name: 'message',
519
+ type: 'input-element',
520
+ theme: {
521
+ textStyle: 'text'
522
+ },
523
+ label: reactIntl.defineMessage({
524
+ "id": "RcLsua",
525
+ "defaultMessage": [{
526
+ "type": 0,
527
+ "value": "Message"
528
+ }]
529
+ })
530
+ }, {
531
+ name: 'submit',
532
+ type: 'button-element',
533
+ theme: {
534
+ textStyle: 'button'
535
+ },
536
+ label: reactIntl.defineMessage({
537
+ "id": "uAKPQ9",
538
+ "defaultMessage": [{
539
+ "type": 0,
540
+ "value": "Submit"
541
+ }]
542
+ })
543
+ }, {
544
+ name: 'nameStyle',
545
+ type: 'item-text-style',
546
+ theme: {
547
+ style: {
548
+ textStyle: 'heading2'
549
+ }
550
+ },
551
+ label: reactIntl.defineMessage({
552
+ "id": "SyMSDa",
553
+ "defaultMessage": [{
554
+ "type": 0,
555
+ "value": "Published name style"
556
+ }]
557
+ })
558
+ }, {
559
+ name: 'messageStyle',
560
+ type: 'item-text-style',
561
+ theme: {
562
+ style: {
563
+ textStyle: 'text'
564
+ }
565
+ },
566
+ label: reactIntl.defineMessage({
567
+ "id": "+SlKOi",
568
+ "defaultMessage": [{
569
+ "type": 0,
570
+ "value": "Published message style"
571
+ }]
572
+ })
573
+ }, {
574
+ name: 'background',
575
+ type: 'background',
576
+ label: reactIntl.defineMessage({
577
+ "id": "+MPZRu",
578
+ "defaultMessage": [{
579
+ "type": 0,
580
+ "value": "Background"
581
+ }]
582
+ })
583
+ }, {
584
+ name: 'callToAction',
585
+ type: 'call-to-action',
586
+ theme: {
587
+ label: {
588
+ textStyle: 'heading2'
589
+ }
590
+ }
591
+ }]
592
+ };
593
+
594
+ exports.ContributionScreen = ContributionScreen;
595
+ exports.default = definition;
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "@micromag/screen-contribution",
3
+ "version": "0.2.286",
4
+ "description": "",
5
+ "keywords": [
6
+ "javascript"
7
+ ],
8
+ "homepage": "https://github.com/urbania-media/micromag-js",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/urbania-media/micromag-js.git"
12
+ },
13
+ "author": {
14
+ "name": "Folklore",
15
+ "email": "info@folklore.email"
16
+ },
17
+ "contributors": [
18
+ {
19
+ "name": "David Mongeau-Petitpas",
20
+ "email": "dmp@folklore.email"
21
+ },
22
+ {
23
+ "name": "Nicolas Roy-Bourdages",
24
+ "email": "nrb@folklore.email"
25
+ },
26
+ {
27
+ "name": "Julien Carignan",
28
+ "email": "jc@folklore.email"
29
+ }
30
+ ],
31
+ "license": "ISC",
32
+ "main": "lib/index.js",
33
+ "module": "es/index.js",
34
+ "files": [
35
+ "lib",
36
+ "es",
37
+ "assets"
38
+ ],
39
+ "scripts": {
40
+ "prepare": "../../scripts/prepare-package.sh"
41
+ },
42
+ "devDependencies": {
43
+ "react": "^16.8.0",
44
+ "react-dom": "^16.8.0"
45
+ },
46
+ "peerDependencies": {
47
+ "react": "^16.8.0",
48
+ "react-dom": "^16.8.0"
49
+ },
50
+ "dependencies": {
51
+ "@babel/runtime": "^7.13.10",
52
+ "@fortawesome/fontawesome-svg-core": "^1.2.32",
53
+ "@fortawesome/free-solid-svg-icons": "^5.15.1",
54
+ "@fortawesome/react-fontawesome": "^0.1.13",
55
+ "@micromag/core": "^0.2.286",
56
+ "@micromag/data": "^0.2.286",
57
+ "@micromag/element-background": "^0.2.286",
58
+ "@micromag/element-button": "^0.2.286",
59
+ "@micromag/element-call-to-action": "^0.2.286",
60
+ "@micromag/element-container": "^0.2.286",
61
+ "@micromag/element-heading": "^0.2.286",
62
+ "@micromag/element-scroll": "^0.2.286",
63
+ "@micromag/element-text": "^0.2.286",
64
+ "@micromag/element-text-input": "^0.2.286",
65
+ "@micromag/transforms": "^0.2.286",
66
+ "classnames": "^2.2.6",
67
+ "lodash": "^4.17.20",
68
+ "prop-types": "^15.7.2",
69
+ "react-intl": "^5.12.1",
70
+ "uuid": "^8.3.2"
71
+ },
72
+ "publishConfig": {
73
+ "access": "public"
74
+ },
75
+ "gitHead": "380a52b4b3f57dc2535014af6241032f09055d40"
76
+ }