@micromag/screen-survey 0.3.86 → 0.3.88

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.
@@ -1 +1 @@
1
- .micromag-screen-survey-container{position:relative;width:100%;height:100%;overflow:hidden}.micromag-screen-survey-disabled.micromag-screen-survey-container{overflow:hidden;pointer-events:none}.micromag-screen-survey-hidden.micromag-screen-survey-container{display:none;visibility:hidden}.micromag-screen-survey-placeholder.micromag-screen-survey-container .micromag-screen-survey-content{position:relative;padding:6px}.micromag-screen-survey-container .micromag-screen-survey-emptyAnswer,.micromag-screen-survey-container .micromag-screen-survey-emptyQuestion{margin:5px auto;border:2px dashed #343434;color:#343434}.micromag-screen-survey-container .micromag-screen-survey-question{margin-bottom:20px}.micromag-screen-survey-container .micromag-screen-survey-answers,.micromag-screen-survey-container .micromag-screen-survey-items{position:relative}.micromag-screen-survey-container .micromag-screen-survey-item{padding:5px 0}.micromag-screen-survey-container .micromag-screen-survey-item:first-child .micromag-screen-survey-placeholderAnswer{width:80%}.micromag-screen-survey-container .micromag-screen-survey-item:last-child .micromag-screen-survey-placeholderAnswer{width:90%}.micromag-screen-survey-container .micromag-screen-survey-itemContent{display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-ms-flex-align:center;align-items:center}.micromag-screen-survey-container .micromag-screen-survey-resultContainer{-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;-webkit-align-self:center;-ms-flex-item-align:center;align-self:center;padding:15px 0;-webkit-transition-property:padding;-o-transition-property:padding;transition-property:padding;-webkit-transition-timing-function:ease;-o-transition-timing-function:ease;transition-timing-function:ease}.micromag-screen-survey-container .micromag-screen-survey-resultContent{width:0;height:1em;-webkit-transition-property:width opacity;-o-transition-property:width opacity;transition-property:width opacity;-webkit-transition-timing-function:ease;-o-transition-timing-function:ease;transition-timing-function:ease;opacity:0}.micromag-screen-survey-container .micromag-screen-survey-result{position:relative;height:100%;background-color:#fff}.micromag-screen-survey-container .micromag-screen-survey-resultLabel{position:absolute;top:50%;left:100%;margin-left:5px;-webkit-transform:translateY(-50%);-ms-transform:translateY(-50%);transform:translateY(-50%);color:#fff}.micromag-screen-survey-container .micromag-screen-survey-itemInner{width:100%;-webkit-transition-property:width;-o-transition-property:width;transition-property:width;-webkit-transition-timing-function:ease;-o-transition-timing-function:ease;transition-timing-function:ease}.micromag-screen-survey-container .micromag-screen-survey-button{display:-webkit-flex;display:-ms-flexbox;display:flex;position:relative;width:100%;padding:0;-webkit-transition:opacity .5s ease-out;-o-transition:opacity .5s ease-out;transition:opacity .5s ease-out}.micromag-screen-survey-container .micromag-screen-survey-button:disabled{opacity:1;pointer-events:none}.micromag-screen-survey-container .micromag-screen-survey-itemLabel{display:inline-block;padding:10px;-webkit-transition:margin-left .3s ease-out,-webkit-transform .3s ease-out;transition:margin-left .3s ease-out,-webkit-transform .3s ease-out;-o-transition:margin-left .3s ease-out,transform .3s ease-out;transition:margin-left .3s ease-out,transform .3s ease-out;transition:margin-left .3s ease-out,transform .3s ease-out,-webkit-transform .3s ease-out}.micromag-screen-survey-container .micromag-screen-survey-emptyAnswer,.micromag-screen-survey-container .micromag-screen-survey-emptyQuestion{width:100%;margin:0 auto}.micromag-screen-survey-container .micromag-screen-survey-emptyQuestion{height:75px}.micromag-screen-survey-container .micromag-screen-survey-emptyAnswer{height:50px}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-resultContainer{padding-right:50px;padding-left:15px}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-resultContent{width:100%;opacity:1}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-button{border-color:rgba(0,0,0,0);background-color:rgba(0,0,0,0)}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-button,.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-result,.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-resultLabel{opacity:.6}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-itemLabel{margin-left:0;-webkit-transform:translate(-10px);-ms-transform:translate(-10px);transform:translate(-10px);text-align:left}.micromag-screen-survey-container .micromag-screen-survey-userAnswer .micromag-screen-survey-button,.micromag-screen-survey-container .micromag-screen-survey-userAnswer .micromag-screen-survey-result,.micromag-screen-survey-container .micromag-screen-survey-userAnswer .micromag-screen-survey-resultLabel{opacity:1}.micromag-screen-survey-container.micromag-screen-survey-isPlaceholder .micromag-screen-survey-layout{padding:10px}.micromag-screen-survey-container.micromag-screen-survey-isPlaceholder .micromag-screen-survey-item{padding:1px 0}
1
+ .micromag-screen-survey-container{position:relative;width:100%;height:100%;overflow:hidden}.micromag-screen-survey-disabled.micromag-screen-survey-container{overflow:hidden;pointer-events:none}.micromag-screen-survey-hidden.micromag-screen-survey-container{display:none;visibility:hidden}.micromag-screen-survey-placeholder.micromag-screen-survey-container .micromag-screen-survey-content{position:relative;padding:6px}.micromag-screen-survey-container .micromag-screen-survey-emptyAnswer,.micromag-screen-survey-container .micromag-screen-survey-emptyQuestion{margin:5px auto;border:2px dashed #343434;color:#343434}.micromag-screen-survey-container .micromag-screen-survey-question{margin-bottom:20px}.micromag-screen-survey-container .micromag-screen-survey-answers,.micromag-screen-survey-container .micromag-screen-survey-items{position:relative}.micromag-screen-survey-container .micromag-screen-survey-item{padding:5px 0}.micromag-screen-survey-container .micromag-screen-survey-item:first-child .micromag-screen-survey-placeholderAnswer{width:80%}.micromag-screen-survey-container .micromag-screen-survey-item:last-child .micromag-screen-survey-placeholderAnswer{width:90%}.micromag-screen-survey-container .micromag-screen-survey-itemContent{display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-ms-flex-align:center;align-items:center}.micromag-screen-survey-container .micromag-screen-survey-resultBar{position:absolute;top:0;left:0;height:100%;background-color:hsla(0,0%,100%,.3)}.micromag-screen-survey-container .micromag-screen-survey-resultLabel{position:absolute;top:50%;right:0;width:4em;padding:0 5px;-webkit-transform:translateY(-50%);-ms-transform:translateY(-50%);transform:translateY(-50%);color:#fff;text-align:right}.micromag-screen-survey-container .micromag-screen-survey-itemInner{width:100%}.micromag-screen-survey-container .micromag-screen-survey-button{display:-webkit-flex;display:-ms-flexbox;display:flex;position:relative;width:100%;padding:0;-webkit-transition:opacity .5s ease-out;-o-transition:opacity .5s ease-out;transition:opacity .5s ease-out}.micromag-screen-survey-container .micromag-screen-survey-button:disabled{opacity:1;pointer-events:none}.micromag-screen-survey-container .micromag-screen-survey-itemLabel{width:100%;padding:10px}.micromag-screen-survey-container .micromag-screen-survey-itemLabel,.micromag-screen-survey-container .micromag-screen-survey-itemText{display:inline-block;-webkit-transition:margin-left .3s ease-out,-webkit-transform .3s ease-out;transition:margin-left .3s ease-out,-webkit-transform .3s ease-out;-o-transition:margin-left .3s ease-out,transform .3s ease-out;transition:margin-left .3s ease-out,transform .3s ease-out;transition:margin-left .3s ease-out,transform .3s ease-out,-webkit-transform .3s ease-out}.micromag-screen-survey-container .micromag-screen-survey-emptyAnswer,.micromag-screen-survey-container .micromag-screen-survey-emptyQuestion{width:100%;margin:0 auto}.micromag-screen-survey-container .micromag-screen-survey-emptyQuestion{height:75px}.micromag-screen-survey-container .micromag-screen-survey-emptyAnswer{height:50px}.micromag-screen-survey-container .micromag-screen-survey-userAnswer .micromag-screen-survey-button,.micromag-screen-survey-container .micromag-screen-survey-userAnswer .micromag-screen-survey-result,.micromag-screen-survey-container .micromag-screen-survey-userAnswer .micromag-screen-survey-resultLabel{opacity:1!important}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-resultContainer{padding-right:50px;padding-left:15px}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-resultContent{width:100%;opacity:1}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-button{border-color:rgba(0,0,0,0);background-color:rgba(0,0,0,0)}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-button,.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-result,.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-resultLabel{opacity:.6}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-itemLabel{margin-right:0;margin-left:0;text-align:left}.micromag-screen-survey-container.micromag-screen-survey-answered.micromag-screen-survey-withPercentage .micromag-screen-survey-itemText{-webkit-transform:translate(-2em);-ms-transform:translate(-2em);transform:translate(-2em)}.micromag-screen-survey-container.micromag-screen-survey-withPercentage .micromag-screen-survey-itemLabel{margin-right:2em;margin-left:2em}.micromag-screen-survey-container.micromag-screen-survey-isPlaceholder .micromag-screen-survey-layout{padding:10px}.micromag-screen-survey-container.micromag-screen-survey-isPlaceholder .micromag-screen-survey-item{padding:1px 0}
package/es/index.js CHANGED
@@ -5,7 +5,7 @@ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
5
5
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
6
6
  import classNames from 'classnames';
7
7
  import PropTypes from 'prop-types';
8
- import React, { useState, useMemo, useCallback, useEffect, useRef } from 'react';
8
+ import React, { useState, useMemo, useCallback, useEffect } from 'react';
9
9
  import { PropTypes as PropTypes$1 } from '@micromag/core';
10
10
  import { ScreenElement, Transitions } from '@micromag/core/components';
11
11
  import { useScreenSize, useViewer, useScreenRenderContext } from '@micromag/core/contexts';
@@ -20,7 +20,7 @@ import Heading from '@micromag/element-heading';
20
20
  import Layout, { Spacer } from '@micromag/element-layout';
21
21
  import Text from '@micromag/element-text';
22
22
 
23
- var styles = {"container":"micromag-screen-survey-container","disabled":"micromag-screen-survey-disabled","hidden":"micromag-screen-survey-hidden","placeholder":"micromag-screen-survey-placeholder","content":"micromag-screen-survey-content","emptyAnswer":"micromag-screen-survey-emptyAnswer","emptyQuestion":"micromag-screen-survey-emptyQuestion","question":"micromag-screen-survey-question","answers":"micromag-screen-survey-answers","items":"micromag-screen-survey-items","item":"micromag-screen-survey-item","placeholderAnswer":"micromag-screen-survey-placeholderAnswer","itemContent":"micromag-screen-survey-itemContent","resultContainer":"micromag-screen-survey-resultContainer","resultContent":"micromag-screen-survey-resultContent","result":"micromag-screen-survey-result","resultLabel":"micromag-screen-survey-resultLabel","itemInner":"micromag-screen-survey-itemInner","button":"micromag-screen-survey-button","itemLabel":"micromag-screen-survey-itemLabel","answered":"micromag-screen-survey-answered","userAnswer":"micromag-screen-survey-userAnswer","isPlaceholder":"micromag-screen-survey-isPlaceholder","layout":"micromag-screen-survey-layout"};
23
+ var styles = {"container":"micromag-screen-survey-container","disabled":"micromag-screen-survey-disabled","hidden":"micromag-screen-survey-hidden","placeholder":"micromag-screen-survey-placeholder","content":"micromag-screen-survey-content","emptyAnswer":"micromag-screen-survey-emptyAnswer","emptyQuestion":"micromag-screen-survey-emptyQuestion","question":"micromag-screen-survey-question","answers":"micromag-screen-survey-answers","items":"micromag-screen-survey-items","item":"micromag-screen-survey-item","placeholderAnswer":"micromag-screen-survey-placeholderAnswer","itemContent":"micromag-screen-survey-itemContent","resultBar":"micromag-screen-survey-resultBar","resultLabel":"micromag-screen-survey-resultLabel","itemInner":"micromag-screen-survey-itemInner","button":"micromag-screen-survey-button","itemLabel":"micromag-screen-survey-itemLabel","itemText":"micromag-screen-survey-itemText","userAnswer":"micromag-screen-survey-userAnswer","result":"micromag-screen-survey-result","answered":"micromag-screen-survey-answered","resultContainer":"micromag-screen-survey-resultContainer","resultContent":"micromag-screen-survey-resultContent","withPercentage":"micromag-screen-survey-withPercentage","isPlaceholder":"micromag-screen-survey-isPlaceholder","layout":"micromag-screen-survey-layout"};
24
24
 
25
25
  var propTypes = {
26
26
  id: PropTypes.string,
@@ -35,8 +35,8 @@ var propTypes = {
35
35
  spacing: PropTypes.number,
36
36
  background: PropTypes$1.backgroundElement,
37
37
  callToAction: PropTypes$1.callToAction,
38
- withPercentLabels: PropTypes.bool,
39
- withoutResults: PropTypes.bool,
38
+ withoutPercentage: PropTypes.bool,
39
+ withoutBar: PropTypes.bool,
40
40
  current: PropTypes.bool,
41
41
  active: PropTypes.bool,
42
42
  transitions: PropTypes$1.transitions,
@@ -55,8 +55,8 @@ var defaultProps = {
55
55
  spacing: 20,
56
56
  background: null,
57
57
  callToAction: null,
58
- withPercentLabels: true,
59
- withoutResults: false,
58
+ withoutPercentage: false,
59
+ withoutBar: false,
60
60
  current: true,
61
61
  active: true,
62
62
  transitions: null,
@@ -78,8 +78,8 @@ var SurveyScreen = function SurveyScreen(_ref) {
78
78
  spacing = _ref.spacing,
79
79
  background = _ref.background,
80
80
  callToAction = _ref.callToAction,
81
- withPercentLabels = _ref.withPercentLabels,
82
- withoutResults = _ref.withoutResults,
81
+ withoutPercentage = _ref.withoutPercentage,
82
+ withoutBar = _ref.withoutBar,
83
83
  current = _ref.current,
84
84
  active = _ref.active,
85
85
  transitions = _ref.transitions,
@@ -226,44 +226,10 @@ var SurveyScreen = function SurveyScreen(_ref) {
226
226
  items.push( /*#__PURE__*/React.createElement(Spacer, {
227
227
  key: "spacer"
228
228
  }));
229
- } // Answer
230
-
231
-
232
- var buttonsRefs = useRef([]);
233
- var labelsRefs = useRef([]);
234
-
235
- var _useState3 = useState(null),
236
- _useState4 = _slicedToArray(_useState3, 2),
237
- buttonMaxWidth = _useState4[0],
238
- setButtonMaxWidth = _useState4[1];
229
+ }
239
230
 
240
231
  var finalTransitionDuration = showInstantAnswer ? 0 : "".concat(resultTransitionDuration, "ms");
241
232
 
242
- var _useState5 = useState(false),
243
- _useState6 = _slicedToArray(_useState5, 2),
244
- ready = _useState6[0],
245
- setReady = _useState6[1];
246
-
247
- useEffect(function () {
248
- if (answers === null || isPlaceholder) {
249
- return;
250
- } // const maxWidth = answers.reduce((currentMaxWidth, answer, answerI) => {
251
- // const button = buttonsRefs.current[answerI] || null;
252
- // const label = labelsRefs.current[answerI] || null;
253
- // if (button !== null && label !== null) {
254
- // const borderWidth = button.offsetWidth - button.clientWidth;
255
- // const totalWidth = borderWidth + label.getBoundingClientRect().width + 20;
256
- // return Math.max(currentMaxWidth, totalWidth);
257
- // }
258
- // return currentMaxWidth;
259
- // }, 0);
260
- // setButtonMaxWidth(Math.min(width * 0.75, Math.max(width * 0.2, maxWidth)));
261
-
262
-
263
- setButtonMaxWidth(withoutResults ? '100%' : width * 0.75);
264
- setReady(true);
265
- }, [answers, width, height, setButtonMaxWidth, finalTransitionDuration, isPlaceholder, withoutResults]);
266
-
267
233
  var _ref6 = resultsStyle || {},
268
234
  _ref6$barColor = _ref6.barColor,
269
235
  resultsBarColor = _ref6$barColor === void 0 ? null : _ref6$barColor,
@@ -336,7 +302,7 @@ var SurveyScreen = function SurveyScreen(_ref) {
336
302
  }, /*#__PURE__*/React.createElement("div", {
337
303
  className: styles.itemInner,
338
304
  style: {
339
- width: buttonMaxWidth,
305
+ // width: buttonMaxWidth,
340
306
  transitionDuration: finalTransitionDuration
341
307
  }
342
308
  }, /*#__PURE__*/React.createElement(Button, {
@@ -344,41 +310,35 @@ var SurveyScreen = function SurveyScreen(_ref) {
344
310
  onClick: function onClick() {
345
311
  return onAnswerClick(answerIndex);
346
312
  },
347
- refButton: function refButton(el) {
348
- buttonsRefs.current[answerIndex] = el;
349
- },
350
313
  disabled: isPreview || userAnswerIndex !== null,
351
314
  focusable: current && isView,
352
- buttonStyle: !answered ? _objectSpread(_objectSpread({}, getStyleFromBox(buttonsStyle)), getStyleFromBox(answerButtonStyle)) : null
315
+ buttonStyle: _objectSpread(_objectSpread(_objectSpread({}, getStyleFromBox(buttonsStyle)), getStyleFromBox(answerButtonStyle)), answered ? {
316
+ textAlign: 'left'
317
+ } : null)
353
318
  }, /*#__PURE__*/React.createElement("span", {
354
- className: styles.itemLabel,
355
- ref: function ref(el) {
356
- labelsRefs.current[answerIndex] = el;
357
- }
319
+ className: styles.itemLabel
358
320
  }, /*#__PURE__*/React.createElement(Text, Object.assign({}, label, {
359
321
  textStyle: textStyle,
360
322
  inline: true,
361
323
  className: styles.itemText
362
- }))))), !withoutResults ? /*#__PURE__*/React.createElement("div", {
363
- className: styles.resultContainer,
364
- style: {
365
- transitionDuration: finalTransitionDuration
366
- }
367
- }, /*#__PURE__*/React.createElement("div", {
368
- className: styles.resultContent,
369
- style: {
370
- transitionDelay: finalTransitionDuration,
371
- transitionDuration: finalTransitionDuration
372
- }
373
- }, /*#__PURE__*/React.createElement("div", {
374
- className: styles.result,
375
- style: _objectSpread({
376
- width: percent !== null ? "".concat(percent, "%") : null
377
- }, getStyleFromColor(answered ? answerResultBarColor || resultsBarColor || labelColor : null, 'backgroundColor'))
378
- }, withPercentLabels ? /*#__PURE__*/React.createElement("div", {
324
+ })), !withoutPercentage ? /*#__PURE__*/React.createElement("div", {
379
325
  className: styles.resultLabel,
380
- style: _objectSpread({}, getStyleFromColor(answered ? answerResultTextColor || resultsTextColor || answerResultBarColor || resultsBarColor || labelColor : null, 'color'))
381
- }, "".concat(percent, "%")) : null))) : null)) : null));
326
+ style: _objectSpread(_objectSpread({}, getStyleFromColor(answered ? answerResultTextColor || resultsTextColor || answerResultBarColor || resultsBarColor || labelColor : null, 'color')), answered ? {
327
+ opacity: 1
328
+ } : {
329
+ opacity: 0
330
+ })
331
+ }, "".concat(percent, "%")) : null, !withoutBar ? /*#__PURE__*/React.createElement("div", {
332
+ className: styles.resultBar,
333
+ style: _objectSpread(_objectSpread({
334
+ transitionDuration: finalTransitionDuration,
335
+ width: percent !== null ? "".concat(percent, "%") : null
336
+ }, getStyleFromColor(answered ? answerResultBarColor || resultsBarColor || labelColor : null, 'backgroundColor')), answered ? {
337
+ opacity: 1
338
+ } : {
339
+ opacity: 0
340
+ })
341
+ }) : null))))) : null));
382
342
  })) : null)); // Call to Action
383
343
 
384
344
  if (!isPlaceholder && hasCallToAction) {
@@ -407,8 +367,7 @@ var SurveyScreen = function SurveyScreen(_ref) {
407
367
  }
408
368
 
409
369
  return /*#__PURE__*/React.createElement("div", {
410
- className: classNames([styles.container, (_ref14 = {}, _defineProperty(_ref14, className, className !== null), _defineProperty(_ref14, styles.answered, answered), _defineProperty(_ref14, styles.isPlaceholder, isPlaceholder), _ref14)]),
411
- "data-screen-ready": ready
370
+ className: classNames([styles.container, (_ref14 = {}, _defineProperty(_ref14, className, className !== null), _defineProperty(_ref14, styles.answered, answered), _defineProperty(_ref14, styles.withPercentage, !withoutPercentage), _defineProperty(_ref14, styles.isPlaceholder, isPlaceholder), _ref14)])
412
371
  }, !isPlaceholder ? /*#__PURE__*/React.createElement(Background, {
413
372
  background: background,
414
373
  width: width,
@@ -495,14 +454,25 @@ var definition = {
495
454
  }]
496
455
  })
497
456
  }, {
498
- name: 'withoutResults',
457
+ name: 'withoutPercentage',
458
+ type: 'toggle',
459
+ defaultValue: false,
460
+ label: defineMessage({
461
+ id: "crLqJd",
462
+ defaultMessage: [{
463
+ "type": 0,
464
+ "value": "Without percentage"
465
+ }]
466
+ })
467
+ }, {
468
+ name: 'withoutBar',
499
469
  type: 'toggle',
500
470
  defaultValue: false,
501
471
  label: defineMessage({
502
- id: "W3aj7x",
472
+ id: "D7kxD3",
503
473
  defaultMessage: [{
504
474
  "type": 0,
505
- "value": "Without results"
475
+ "value": "Without bar"
506
476
  }]
507
477
  })
508
478
  }, {
package/lib/index.js CHANGED
@@ -41,7 +41,7 @@ var Heading__default = /*#__PURE__*/_interopDefaultLegacy(Heading);
41
41
  var Layout__default = /*#__PURE__*/_interopDefaultLegacy(Layout);
42
42
  var Text__default = /*#__PURE__*/_interopDefaultLegacy(Text);
43
43
 
44
- var styles = {"container":"micromag-screen-survey-container","disabled":"micromag-screen-survey-disabled","hidden":"micromag-screen-survey-hidden","placeholder":"micromag-screen-survey-placeholder","content":"micromag-screen-survey-content","emptyAnswer":"micromag-screen-survey-emptyAnswer","emptyQuestion":"micromag-screen-survey-emptyQuestion","question":"micromag-screen-survey-question","answers":"micromag-screen-survey-answers","items":"micromag-screen-survey-items","item":"micromag-screen-survey-item","placeholderAnswer":"micromag-screen-survey-placeholderAnswer","itemContent":"micromag-screen-survey-itemContent","resultContainer":"micromag-screen-survey-resultContainer","resultContent":"micromag-screen-survey-resultContent","result":"micromag-screen-survey-result","resultLabel":"micromag-screen-survey-resultLabel","itemInner":"micromag-screen-survey-itemInner","button":"micromag-screen-survey-button","itemLabel":"micromag-screen-survey-itemLabel","answered":"micromag-screen-survey-answered","userAnswer":"micromag-screen-survey-userAnswer","isPlaceholder":"micromag-screen-survey-isPlaceholder","layout":"micromag-screen-survey-layout"};
44
+ var styles = {"container":"micromag-screen-survey-container","disabled":"micromag-screen-survey-disabled","hidden":"micromag-screen-survey-hidden","placeholder":"micromag-screen-survey-placeholder","content":"micromag-screen-survey-content","emptyAnswer":"micromag-screen-survey-emptyAnswer","emptyQuestion":"micromag-screen-survey-emptyQuestion","question":"micromag-screen-survey-question","answers":"micromag-screen-survey-answers","items":"micromag-screen-survey-items","item":"micromag-screen-survey-item","placeholderAnswer":"micromag-screen-survey-placeholderAnswer","itemContent":"micromag-screen-survey-itemContent","resultBar":"micromag-screen-survey-resultBar","resultLabel":"micromag-screen-survey-resultLabel","itemInner":"micromag-screen-survey-itemInner","button":"micromag-screen-survey-button","itemLabel":"micromag-screen-survey-itemLabel","itemText":"micromag-screen-survey-itemText","userAnswer":"micromag-screen-survey-userAnswer","result":"micromag-screen-survey-result","answered":"micromag-screen-survey-answered","resultContainer":"micromag-screen-survey-resultContainer","resultContent":"micromag-screen-survey-resultContent","withPercentage":"micromag-screen-survey-withPercentage","isPlaceholder":"micromag-screen-survey-isPlaceholder","layout":"micromag-screen-survey-layout"};
45
45
 
46
46
  var propTypes = {
47
47
  id: PropTypes__default["default"].string,
@@ -56,8 +56,8 @@ var propTypes = {
56
56
  spacing: PropTypes__default["default"].number,
57
57
  background: core.PropTypes.backgroundElement,
58
58
  callToAction: core.PropTypes.callToAction,
59
- withPercentLabels: PropTypes__default["default"].bool,
60
- withoutResults: PropTypes__default["default"].bool,
59
+ withoutPercentage: PropTypes__default["default"].bool,
60
+ withoutBar: PropTypes__default["default"].bool,
61
61
  current: PropTypes__default["default"].bool,
62
62
  active: PropTypes__default["default"].bool,
63
63
  transitions: core.PropTypes.transitions,
@@ -76,8 +76,8 @@ var defaultProps = {
76
76
  spacing: 20,
77
77
  background: null,
78
78
  callToAction: null,
79
- withPercentLabels: true,
80
- withoutResults: false,
79
+ withoutPercentage: false,
80
+ withoutBar: false,
81
81
  current: true,
82
82
  active: true,
83
83
  transitions: null,
@@ -99,8 +99,8 @@ var SurveyScreen = function SurveyScreen(_ref) {
99
99
  spacing = _ref.spacing,
100
100
  background = _ref.background,
101
101
  callToAction = _ref.callToAction,
102
- withPercentLabels = _ref.withPercentLabels,
103
- withoutResults = _ref.withoutResults,
102
+ withoutPercentage = _ref.withoutPercentage,
103
+ withoutBar = _ref.withoutBar,
104
104
  current = _ref.current,
105
105
  active = _ref.active,
106
106
  transitions = _ref.transitions,
@@ -247,44 +247,10 @@ var SurveyScreen = function SurveyScreen(_ref) {
247
247
  items.push( /*#__PURE__*/React__default["default"].createElement(Layout.Spacer, {
248
248
  key: "spacer"
249
249
  }));
250
- } // Answer
251
-
252
-
253
- var buttonsRefs = React.useRef([]);
254
- var labelsRefs = React.useRef([]);
255
-
256
- var _useState3 = React.useState(null),
257
- _useState4 = _slicedToArray__default["default"](_useState3, 2),
258
- buttonMaxWidth = _useState4[0],
259
- setButtonMaxWidth = _useState4[1];
250
+ }
260
251
 
261
252
  var finalTransitionDuration = showInstantAnswer ? 0 : "".concat(resultTransitionDuration, "ms");
262
253
 
263
- var _useState5 = React.useState(false),
264
- _useState6 = _slicedToArray__default["default"](_useState5, 2),
265
- ready = _useState6[0],
266
- setReady = _useState6[1];
267
-
268
- React.useEffect(function () {
269
- if (answers === null || isPlaceholder) {
270
- return;
271
- } // const maxWidth = answers.reduce((currentMaxWidth, answer, answerI) => {
272
- // const button = buttonsRefs.current[answerI] || null;
273
- // const label = labelsRefs.current[answerI] || null;
274
- // if (button !== null && label !== null) {
275
- // const borderWidth = button.offsetWidth - button.clientWidth;
276
- // const totalWidth = borderWidth + label.getBoundingClientRect().width + 20;
277
- // return Math.max(currentMaxWidth, totalWidth);
278
- // }
279
- // return currentMaxWidth;
280
- // }, 0);
281
- // setButtonMaxWidth(Math.min(width * 0.75, Math.max(width * 0.2, maxWidth)));
282
-
283
-
284
- setButtonMaxWidth(withoutResults ? '100%' : width * 0.75);
285
- setReady(true);
286
- }, [answers, width, height, setButtonMaxWidth, finalTransitionDuration, isPlaceholder, withoutResults]);
287
-
288
254
  var _ref6 = resultsStyle || {},
289
255
  _ref6$barColor = _ref6.barColor,
290
256
  resultsBarColor = _ref6$barColor === void 0 ? null : _ref6$barColor,
@@ -357,7 +323,7 @@ var SurveyScreen = function SurveyScreen(_ref) {
357
323
  }, /*#__PURE__*/React__default["default"].createElement("div", {
358
324
  className: styles.itemInner,
359
325
  style: {
360
- width: buttonMaxWidth,
326
+ // width: buttonMaxWidth,
361
327
  transitionDuration: finalTransitionDuration
362
328
  }
363
329
  }, /*#__PURE__*/React__default["default"].createElement(Button__default["default"], {
@@ -365,41 +331,35 @@ var SurveyScreen = function SurveyScreen(_ref) {
365
331
  onClick: function onClick() {
366
332
  return onAnswerClick(answerIndex);
367
333
  },
368
- refButton: function refButton(el) {
369
- buttonsRefs.current[answerIndex] = el;
370
- },
371
334
  disabled: isPreview || userAnswerIndex !== null,
372
335
  focusable: current && isView,
373
- buttonStyle: !answered ? _objectSpread__default["default"](_objectSpread__default["default"]({}, utils.getStyleFromBox(buttonsStyle)), utils.getStyleFromBox(answerButtonStyle)) : null
336
+ buttonStyle: _objectSpread__default["default"](_objectSpread__default["default"](_objectSpread__default["default"]({}, utils.getStyleFromBox(buttonsStyle)), utils.getStyleFromBox(answerButtonStyle)), answered ? {
337
+ textAlign: 'left'
338
+ } : null)
374
339
  }, /*#__PURE__*/React__default["default"].createElement("span", {
375
- className: styles.itemLabel,
376
- ref: function ref(el) {
377
- labelsRefs.current[answerIndex] = el;
378
- }
340
+ className: styles.itemLabel
379
341
  }, /*#__PURE__*/React__default["default"].createElement(Text__default["default"], Object.assign({}, label, {
380
342
  textStyle: textStyle,
381
343
  inline: true,
382
344
  className: styles.itemText
383
- }))))), !withoutResults ? /*#__PURE__*/React__default["default"].createElement("div", {
384
- className: styles.resultContainer,
385
- style: {
386
- transitionDuration: finalTransitionDuration
387
- }
388
- }, /*#__PURE__*/React__default["default"].createElement("div", {
389
- className: styles.resultContent,
390
- style: {
391
- transitionDelay: finalTransitionDuration,
392
- transitionDuration: finalTransitionDuration
393
- }
394
- }, /*#__PURE__*/React__default["default"].createElement("div", {
395
- className: styles.result,
396
- style: _objectSpread__default["default"]({
397
- width: percent !== null ? "".concat(percent, "%") : null
398
- }, utils.getStyleFromColor(answered ? answerResultBarColor || resultsBarColor || labelColor : null, 'backgroundColor'))
399
- }, withPercentLabels ? /*#__PURE__*/React__default["default"].createElement("div", {
345
+ })), !withoutPercentage ? /*#__PURE__*/React__default["default"].createElement("div", {
400
346
  className: styles.resultLabel,
401
- style: _objectSpread__default["default"]({}, utils.getStyleFromColor(answered ? answerResultTextColor || resultsTextColor || answerResultBarColor || resultsBarColor || labelColor : null, 'color'))
402
- }, "".concat(percent, "%")) : null))) : null)) : null));
347
+ style: _objectSpread__default["default"](_objectSpread__default["default"]({}, utils.getStyleFromColor(answered ? answerResultTextColor || resultsTextColor || answerResultBarColor || resultsBarColor || labelColor : null, 'color')), answered ? {
348
+ opacity: 1
349
+ } : {
350
+ opacity: 0
351
+ })
352
+ }, "".concat(percent, "%")) : null, !withoutBar ? /*#__PURE__*/React__default["default"].createElement("div", {
353
+ className: styles.resultBar,
354
+ style: _objectSpread__default["default"](_objectSpread__default["default"]({
355
+ transitionDuration: finalTransitionDuration,
356
+ width: percent !== null ? "".concat(percent, "%") : null
357
+ }, utils.getStyleFromColor(answered ? answerResultBarColor || resultsBarColor || labelColor : null, 'backgroundColor')), answered ? {
358
+ opacity: 1
359
+ } : {
360
+ opacity: 0
361
+ })
362
+ }) : null))))) : null));
403
363
  })) : null)); // Call to Action
404
364
 
405
365
  if (!isPlaceholder && hasCallToAction) {
@@ -428,8 +388,7 @@ var SurveyScreen = function SurveyScreen(_ref) {
428
388
  }
429
389
 
430
390
  return /*#__PURE__*/React__default["default"].createElement("div", {
431
- className: classNames__default["default"]([styles.container, (_ref14 = {}, _defineProperty__default["default"](_ref14, className, className !== null), _defineProperty__default["default"](_ref14, styles.answered, answered), _defineProperty__default["default"](_ref14, styles.isPlaceholder, isPlaceholder), _ref14)]),
432
- "data-screen-ready": ready
391
+ className: classNames__default["default"]([styles.container, (_ref14 = {}, _defineProperty__default["default"](_ref14, className, className !== null), _defineProperty__default["default"](_ref14, styles.answered, answered), _defineProperty__default["default"](_ref14, styles.withPercentage, !withoutPercentage), _defineProperty__default["default"](_ref14, styles.isPlaceholder, isPlaceholder), _ref14)])
433
392
  }, !isPlaceholder ? /*#__PURE__*/React__default["default"].createElement(Background__default["default"], {
434
393
  background: background,
435
394
  width: width,
@@ -516,14 +475,25 @@ var definition = {
516
475
  }]
517
476
  })
518
477
  }, {
519
- name: 'withoutResults',
478
+ name: 'withoutPercentage',
479
+ type: 'toggle',
480
+ defaultValue: false,
481
+ label: reactIntl.defineMessage({
482
+ id: "crLqJd",
483
+ defaultMessage: [{
484
+ "type": 0,
485
+ "value": "Without percentage"
486
+ }]
487
+ })
488
+ }, {
489
+ name: 'withoutBar',
520
490
  type: 'toggle',
521
491
  defaultValue: false,
522
492
  label: reactIntl.defineMessage({
523
- id: "W3aj7x",
493
+ id: "D7kxD3",
524
494
  defaultMessage: [{
525
495
  "type": 0,
526
- "value": "Without results"
496
+ "value": "Without bar"
527
497
  }]
528
498
  })
529
499
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/screen-survey",
3
- "version": "0.3.86",
3
+ "version": "0.3.88",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -49,17 +49,17 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@babel/runtime": "^7.13.10",
52
- "@micromag/core": "^0.3.86",
53
- "@micromag/data": "^0.3.86",
54
- "@micromag/element-background": "^0.3.86",
55
- "@micromag/element-button": "^0.3.86",
56
- "@micromag/element-call-to-action": "^0.3.86",
57
- "@micromag/element-container": "^0.3.86",
58
- "@micromag/element-heading": "^0.3.86",
59
- "@micromag/element-layout": "^0.3.86",
60
- "@micromag/element-scroll": "^0.3.86",
61
- "@micromag/element-text": "^0.3.86",
62
- "@micromag/transforms": "^0.3.86",
52
+ "@micromag/core": "^0.3.88",
53
+ "@micromag/data": "^0.3.88",
54
+ "@micromag/element-background": "^0.3.88",
55
+ "@micromag/element-button": "^0.3.88",
56
+ "@micromag/element-call-to-action": "^0.3.88",
57
+ "@micromag/element-container": "^0.3.88",
58
+ "@micromag/element-heading": "^0.3.88",
59
+ "@micromag/element-layout": "^0.3.88",
60
+ "@micromag/element-scroll": "^0.3.88",
61
+ "@micromag/element-text": "^0.3.88",
62
+ "@micromag/transforms": "^0.3.88",
63
63
  "classnames": "^2.2.6",
64
64
  "lodash": "^4.17.21",
65
65
  "prop-types": "^15.7.2",
@@ -69,5 +69,5 @@
69
69
  "publishConfig": {
70
70
  "access": "public"
71
71
  },
72
- "gitHead": "063af274982885b7696d265e6567ab8d44c8b9ad"
72
+ "gitHead": "d0fb1f7d4ae6bfa1fd07dc856307c1c4225ab889"
73
73
  }