@atlaskit/contextual-survey 2.0.11
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/CHANGELOG.md +258 -0
- package/LICENSE +13 -0
- package/README.md +13 -0
- package/build/tsconfig.json +17 -0
- package/constants/package.json +7 -0
- package/dist/cjs/components/ContextualSurvey.js +274 -0
- package/dist/cjs/components/FeedbackAcknowledgement.js +26 -0
- package/dist/cjs/components/FeedbackScoreButtons.js +60 -0
- package/dist/cjs/components/SignUpPrompt.js +84 -0
- package/dist/cjs/components/SignUpSuccess.js +29 -0
- package/dist/cjs/components/SuccessContainer.js +35 -0
- package/dist/cjs/components/SurveyContainer.js +48 -0
- package/dist/cjs/components/SurveyForm.js +159 -0
- package/dist/cjs/components/SurveyMarshal.js +67 -0
- package/dist/cjs/components/useEscapeToDismiss.js +78 -0
- package/dist/cjs/constants.js +15 -0
- package/dist/cjs/index.js +35 -0
- package/dist/cjs/types.js +5 -0
- package/dist/cjs/version.json +5 -0
- package/dist/es2019/components/ContextualSurvey.js +178 -0
- package/dist/es2019/components/FeedbackAcknowledgement.js +12 -0
- package/dist/es2019/components/FeedbackScoreButtons.js +69 -0
- package/dist/es2019/components/SignUpPrompt.js +46 -0
- package/dist/es2019/components/SignUpSuccess.js +12 -0
- package/dist/es2019/components/SuccessContainer.js +22 -0
- package/dist/es2019/components/SurveyContainer.js +37 -0
- package/dist/es2019/components/SurveyForm.js +121 -0
- package/dist/es2019/components/SurveyMarshal.js +62 -0
- package/dist/es2019/components/useEscapeToDismiss.js +69 -0
- package/dist/es2019/constants.js +4 -0
- package/dist/es2019/index.js +2 -0
- package/dist/es2019/types.js +1 -0
- package/dist/es2019/version.json +5 -0
- package/dist/esm/components/ContextualSurvey.js +244 -0
- package/dist/esm/components/FeedbackAcknowledgement.js +13 -0
- package/dist/esm/components/FeedbackScoreButtons.js +44 -0
- package/dist/esm/components/SignUpPrompt.js +66 -0
- package/dist/esm/components/SignUpSuccess.js +16 -0
- package/dist/esm/components/SuccessContainer.js +21 -0
- package/dist/esm/components/SurveyContainer.js +30 -0
- package/dist/esm/components/SurveyForm.js +132 -0
- package/dist/esm/components/SurveyMarshal.js +55 -0
- package/dist/esm/components/useEscapeToDismiss.js +68 -0
- package/dist/esm/constants.js +4 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/version.json +5 -0
- package/dist/types/components/ContextualSurvey.d.ts +39 -0
- package/dist/types/components/FeedbackAcknowledgement.d.ts +2 -0
- package/dist/types/components/FeedbackScoreButtons.d.ts +6 -0
- package/dist/types/components/SignUpPrompt.d.ts +5 -0
- package/dist/types/components/SignUpSuccess.d.ts +4 -0
- package/dist/types/components/SuccessContainer.d.ts +6 -0
- package/dist/types/components/SurveyContainer.d.ts +7 -0
- package/dist/types/components/SurveyForm.d.ts +11 -0
- package/dist/types/components/SurveyMarshal.d.ts +13 -0
- package/dist/types/components/useEscapeToDismiss.d.ts +6 -0
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/types.d.ts +5 -0
- package/docs/0-intro.tsx +115 -0
- package/package.json +58 -0
- package/tsconfig.json +16 -0
- package/types/package.json +7 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = SurveyMarshal;
|
|
9
|
+
|
|
10
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
11
|
+
|
|
12
|
+
var _core = require("@emotion/core");
|
|
13
|
+
|
|
14
|
+
var _reactTransitionGroup = require("react-transition-group");
|
|
15
|
+
|
|
16
|
+
var _constants = require("@atlaskit/theme/constants");
|
|
17
|
+
|
|
18
|
+
var _constants2 = require("../constants");
|
|
19
|
+
|
|
20
|
+
var _templateObject;
|
|
21
|
+
|
|
22
|
+
var animationDuration = 300;
|
|
23
|
+
var offscreen = {
|
|
24
|
+
translateX: "".concat(_constants2.surveyInnerWidth + _constants2.surveyOffset, "px"),
|
|
25
|
+
opacity: '0'
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var getAnimationProps = function getAnimationProps(state) {
|
|
29
|
+
switch (state) {
|
|
30
|
+
case 'entering':
|
|
31
|
+
{
|
|
32
|
+
return offscreen;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
case 'entered':
|
|
36
|
+
{
|
|
37
|
+
return {
|
|
38
|
+
translateX: '0',
|
|
39
|
+
opacity: '1'
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
case 'exited':
|
|
44
|
+
case 'exiting':
|
|
45
|
+
{
|
|
46
|
+
return offscreen;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
function SurveyMarshal(props) {
|
|
52
|
+
var children = props.children,
|
|
53
|
+
shouldShow = props.shouldShow;
|
|
54
|
+
return (0, _core.jsx)(_reactTransitionGroup.Transition, {
|
|
55
|
+
in: shouldShow,
|
|
56
|
+
timeout: animationDuration,
|
|
57
|
+
unmountOnExit: true
|
|
58
|
+
}, function (state) {
|
|
59
|
+
var _getAnimationProps = getAnimationProps(state),
|
|
60
|
+
translateX = _getAnimationProps.translateX,
|
|
61
|
+
opacity = _getAnimationProps.opacity;
|
|
62
|
+
|
|
63
|
+
return (0, _core.jsx)("div", {
|
|
64
|
+
css: (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n position: fixed;\n right: ", "px;\n bottom: ", "px;\n z-index: ", ";\n transform: translateX(", ");\n opacity: ", ";\n transition: all ", "ms ease-in-out;\n transition-property: transform, opacity;\n "])), _constants2.surveyOffset, _constants2.surveyOffset, _constants.layers.flag(), translateX, opacity, animationDuration)
|
|
65
|
+
}, children());
|
|
66
|
+
});
|
|
67
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useEscapeToDismiss;
|
|
7
|
+
exports.escape = void 0;
|
|
8
|
+
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
|
|
11
|
+
var escape = 27;
|
|
12
|
+
exports.escape = escape;
|
|
13
|
+
|
|
14
|
+
function bind(target, eventName, handler, options) {
|
|
15
|
+
target.addEventListener(eventName, handler, options);
|
|
16
|
+
return function unbind() {
|
|
17
|
+
target.removeEventListener(eventName, handler, options);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function shouldDismiss(target) {
|
|
22
|
+
if (!target) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!(target instanceof HTMLElement)) {
|
|
27
|
+
return true;
|
|
28
|
+
} // Closest doesn't exist for ie11
|
|
29
|
+
// Because we cannot be sure if in a text area - just don't allow dismissing
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
if (!target.closest) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var inTextArea = Boolean(target.closest('textarea')); // Allow dismissing if not in a textarea
|
|
37
|
+
|
|
38
|
+
return !inTextArea;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function useEscapeToDismiss(_ref) {
|
|
42
|
+
var onDismiss = _ref.onDismiss;
|
|
43
|
+
var onDismissRef = (0, _react.useRef)(onDismiss); // Defensively accounting for consumer passing in a new function
|
|
44
|
+
// each time. We just want to call the latest one
|
|
45
|
+
|
|
46
|
+
(0, _react.useEffect)(function () {
|
|
47
|
+
onDismissRef.current = onDismiss;
|
|
48
|
+
}, [onDismiss]);
|
|
49
|
+
(0, _react.useEffect)(function () {
|
|
50
|
+
var unbind;
|
|
51
|
+
|
|
52
|
+
function onKeyDown(event) {
|
|
53
|
+
if (event.keyCode !== escape) {
|
|
54
|
+
return;
|
|
55
|
+
} // Escape pressed
|
|
56
|
+
// We don't want to close if the user is typing in the text area
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
if (!shouldDismiss(event.target)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (unbind) {
|
|
64
|
+
// only want to call dismiss once
|
|
65
|
+
unbind();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
onDismissRef.current();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
unbind = bind(window, 'keydown', // @ts-ignore: the typescript for this is lame
|
|
72
|
+
onKeyDown, {
|
|
73
|
+
passive: true
|
|
74
|
+
}); // double calls to unbind is fine
|
|
75
|
+
|
|
76
|
+
return unbind;
|
|
77
|
+
}, []);
|
|
78
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.surveyOffset = exports.surveyInnerWidth = void 0;
|
|
7
|
+
|
|
8
|
+
var _constants = require("@atlaskit/theme/constants");
|
|
9
|
+
|
|
10
|
+
var surveyInnerWidth = (0, _constants.gridSize)() * 55; // 440
|
|
11
|
+
|
|
12
|
+
exports.surveyInnerWidth = surveyInnerWidth;
|
|
13
|
+
var surveyOffset = (0, _constants.gridSize)() * 6; // 48
|
|
14
|
+
|
|
15
|
+
exports.surveyOffset = surveyOffset;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
Object.defineProperty(exports, "ContextualSurvey", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _ContextualSurvey.default;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "DismissTrigger", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function get() {
|
|
19
|
+
return _ContextualSurvey.DismissTrigger;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(exports, "SurveyMarshal", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function get() {
|
|
25
|
+
return _SurveyMarshal.default;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
var _ContextualSurvey = _interopRequireWildcard(require("./components/ContextualSurvey"));
|
|
30
|
+
|
|
31
|
+
var _SurveyMarshal = _interopRequireDefault(require("./components/SurveyMarshal"));
|
|
32
|
+
|
|
33
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
34
|
+
|
|
35
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import FeedbackAcknowledgement from './FeedbackAcknowledgement';
|
|
3
|
+
import SignUpPrompt from './SignUpPrompt';
|
|
4
|
+
import SignUpSuccess from './SignUpSuccess';
|
|
5
|
+
import SurveyContainer from './SurveyContainer';
|
|
6
|
+
import SurveyForm from './SurveyForm';
|
|
7
|
+
import useEscapeToDismiss from './useEscapeToDismiss';
|
|
8
|
+
export let DismissTrigger;
|
|
9
|
+
|
|
10
|
+
(function (DismissTrigger) {
|
|
11
|
+
DismissTrigger["AutoDismiss"] = "AUTO_DISMISS";
|
|
12
|
+
DismissTrigger["Manual"] = "MANUAL";
|
|
13
|
+
DismissTrigger["Finished"] = "FINISHED";
|
|
14
|
+
DismissTrigger["Unmount"] = "UNMOUNT";
|
|
15
|
+
})(DismissTrigger || (DismissTrigger = {}));
|
|
16
|
+
|
|
17
|
+
export const AUTO_DISAPPEAR_DURATION = 8000;
|
|
18
|
+
export default (({
|
|
19
|
+
question,
|
|
20
|
+
statement,
|
|
21
|
+
onDismiss,
|
|
22
|
+
onSubmit,
|
|
23
|
+
onMailingListAnswer,
|
|
24
|
+
getUserHasAnsweredMailingList,
|
|
25
|
+
textLabel = 'Why did you give that rating',
|
|
26
|
+
textPlaceholder = 'Tell us why'
|
|
27
|
+
}) => {
|
|
28
|
+
const autoDisappearTimeoutRef = useRef(null); // only allow a single dismiss for a component
|
|
29
|
+
|
|
30
|
+
const isDismissedRef = useRef(false);
|
|
31
|
+
const tryDismiss = useCallback(trigger => {
|
|
32
|
+
// Already called dismiss once
|
|
33
|
+
if (isDismissedRef.current) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
isDismissedRef.current = true;
|
|
38
|
+
onDismissRef.current({
|
|
39
|
+
trigger
|
|
40
|
+
});
|
|
41
|
+
}, []);
|
|
42
|
+
const [currentStep, setCurrentStep] = useState('SURVEY');
|
|
43
|
+
const trySetCurrentStep = useCallback(step => {
|
|
44
|
+
// Already dismissed - cannot update the step
|
|
45
|
+
if (isDismissedRef.current) {
|
|
46
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
47
|
+
// eslint-disable-next-line no-console
|
|
48
|
+
console.log(`not setting step "${step}" as survey is already dismissed`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
setCurrentStep(step);
|
|
55
|
+
}, [setCurrentStep]); // using a ref so that we don't break all of our caches if a consumer is using an arrow function
|
|
56
|
+
|
|
57
|
+
const onDismissRef = useRef(onDismiss);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
onDismissRef.current = onDismiss;
|
|
60
|
+
}, [onDismiss]);
|
|
61
|
+
const tryClearTimeout = useCallback(() => {
|
|
62
|
+
const id = autoDisappearTimeoutRef.current;
|
|
63
|
+
|
|
64
|
+
if (id) {
|
|
65
|
+
clearTimeout(id);
|
|
66
|
+
autoDisappearTimeoutRef.current = null;
|
|
67
|
+
}
|
|
68
|
+
}, []); // Cleanup any auto dismiss after dismiss
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
return function unmount() {
|
|
72
|
+
tryClearTimeout();
|
|
73
|
+
tryDismiss(DismissTrigger.Unmount);
|
|
74
|
+
};
|
|
75
|
+
}, [tryClearTimeout, tryDismiss]);
|
|
76
|
+
const onSurveySubmit = useCallback(async (formValues, form, callback = () => {}) => {
|
|
77
|
+
// Submitting form: Phase 1 complete
|
|
78
|
+
await onSubmit(formValues); // Note: need to call callback just before we navigate away
|
|
79
|
+
// It cleans up the form (required)
|
|
80
|
+
// Optional Phase 2: Asking to join Atlassian Research Group
|
|
81
|
+
// Only enter phase 2 if:
|
|
82
|
+
// 1. not already dismissed; AND
|
|
83
|
+
// 2. permission given to contact; AND
|
|
84
|
+
// 3. user has previously not answered mailing list question (getUserHasAnsweredMailingList returns false)
|
|
85
|
+
// Not entering phase 2: User has dismissed while the submit promise was resolving
|
|
86
|
+
|
|
87
|
+
if (isDismissedRef.current) {
|
|
88
|
+
callback();
|
|
89
|
+
return;
|
|
90
|
+
} // Not entering phase 2: no permission given to respond to feedback
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
if (!formValues.canContact) {
|
|
94
|
+
callback();
|
|
95
|
+
trySetCurrentStep('POST_SURVEY_NO_CONSENT');
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const userHasAnswered = await getUserHasAnsweredMailingList();
|
|
100
|
+
callback(); // Not entering phase 2: user has already answered this question
|
|
101
|
+
|
|
102
|
+
if (userHasAnswered) {
|
|
103
|
+
trySetCurrentStep('POST_SURVEY_HAS_SIGN_UP');
|
|
104
|
+
return;
|
|
105
|
+
} // Enter phase 2
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
trySetCurrentStep('SIGN_UP_PROMPT');
|
|
109
|
+
}, [getUserHasAnsweredMailingList, onSubmit, trySetCurrentStep]);
|
|
110
|
+
const onMailingListResponse = useCallback(async answer => {
|
|
111
|
+
await onMailingListAnswer(answer);
|
|
112
|
+
|
|
113
|
+
if (answer) {
|
|
114
|
+
trySetCurrentStep('SIGN_UP_SUCCESS');
|
|
115
|
+
return;
|
|
116
|
+
} // We have already thanked to user, we can simply close
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
tryDismiss(DismissTrigger.Finished);
|
|
120
|
+
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
121
|
+
[tryDismiss, trySetCurrentStep]); // Start the auto disappear when we are finished
|
|
122
|
+
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
// Already dismissed
|
|
125
|
+
if (isDismissedRef.current) {
|
|
126
|
+
return;
|
|
127
|
+
} // Timeout already scheduled
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
if (autoDisappearTimeoutRef.current) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (['SIGN_UP_SUCCESS', 'POST_SURVEY_NO_CONSENT', 'POST_SURVEY_HAS_SIGN_UP'].includes(currentStep)) {
|
|
135
|
+
autoDisappearTimeoutRef.current = window.setTimeout(() => tryDismiss(DismissTrigger.AutoDismiss), AUTO_DISAPPEAR_DURATION);
|
|
136
|
+
}
|
|
137
|
+
}, [currentStep, tryDismiss]);
|
|
138
|
+
useEscapeToDismiss({
|
|
139
|
+
onDismiss: () => tryDismiss(DismissTrigger.Manual)
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const content = (() => {
|
|
143
|
+
if (currentStep === 'SURVEY') {
|
|
144
|
+
return /*#__PURE__*/React.createElement(SurveyForm, {
|
|
145
|
+
question: question,
|
|
146
|
+
statement: statement,
|
|
147
|
+
textLabel: textLabel,
|
|
148
|
+
textPlaceholder: textPlaceholder,
|
|
149
|
+
onSubmit: onSurveySubmit
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (currentStep === 'SIGN_UP_PROMPT') {
|
|
154
|
+
return /*#__PURE__*/React.createElement(SignUpPrompt, {
|
|
155
|
+
onAnswer: onMailingListResponse
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (currentStep === 'SIGN_UP_SUCCESS') {
|
|
160
|
+
return /*#__PURE__*/React.createElement(SignUpSuccess, null);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (currentStep === 'POST_SURVEY_NO_CONSENT' || currentStep === 'POST_SURVEY_HAS_SIGN_UP') {
|
|
164
|
+
return /*#__PURE__*/React.createElement(FeedbackAcknowledgement, null);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return null;
|
|
168
|
+
})();
|
|
169
|
+
|
|
170
|
+
const manualDismiss = useCallback(() => {
|
|
171
|
+
// clear any pending timers
|
|
172
|
+
tryClearTimeout();
|
|
173
|
+
tryDismiss(DismissTrigger.Manual);
|
|
174
|
+
}, [tryDismiss, tryClearTimeout]);
|
|
175
|
+
return /*#__PURE__*/React.createElement(SurveyContainer, {
|
|
176
|
+
onDismiss: manualDismiss
|
|
177
|
+
}, content);
|
|
178
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { css, jsx } from '@emotion/core';
|
|
3
|
+
import { fontSize, gridSize } from '@atlaskit/theme/constants';
|
|
4
|
+
import SuccessContainer from './SuccessContainer';
|
|
5
|
+
export default (() => jsx(SuccessContainer, null, jsx("h1", {
|
|
6
|
+
css: css`
|
|
7
|
+
font-size: ${fontSize()}px;
|
|
8
|
+
font-weight: 600;
|
|
9
|
+
margin-top: 0;
|
|
10
|
+
line-height: ${gridSize() * 3}px;
|
|
11
|
+
`
|
|
12
|
+
}, "Thanks for your feedback")));
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { css, jsx } from '@emotion/core';
|
|
3
|
+
import Button from '@atlaskit/button/custom-theme-button';
|
|
4
|
+
import { N200 } from '@atlaskit/theme/colors';
|
|
5
|
+
import { gridSize } from '@atlaskit/theme/constants';
|
|
6
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
7
|
+
const tooltipMessage = ['Strongly disagree', 'Disagree', 'Slightly disagree', 'Neutral', 'Slightly agree', 'Agree', 'Strongly agree'];
|
|
8
|
+
export default (({
|
|
9
|
+
onChange,
|
|
10
|
+
value
|
|
11
|
+
}) => jsx("div", null, jsx("div", {
|
|
12
|
+
css: css`
|
|
13
|
+
display: flex;
|
|
14
|
+
justify-content: space-between;
|
|
15
|
+
|
|
16
|
+
& > * + * {
|
|
17
|
+
margin-left: ${gridSize()}px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
& > * {
|
|
21
|
+
flex: 1;
|
|
22
|
+
|
|
23
|
+
& > button {
|
|
24
|
+
justify-content: center;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
`
|
|
28
|
+
}, Array.from({
|
|
29
|
+
length: 7
|
|
30
|
+
}, (_, i) => {
|
|
31
|
+
const score = i + 1;
|
|
32
|
+
const isSelected = value === score;
|
|
33
|
+
return jsx(Tooltip, {
|
|
34
|
+
content: tooltipMessage[i],
|
|
35
|
+
key: score,
|
|
36
|
+
hideTooltipOnClick: true
|
|
37
|
+
}, jsx(Button, {
|
|
38
|
+
onClick: () => onChange(score),
|
|
39
|
+
isSelected: isSelected,
|
|
40
|
+
"aria-pressed": isSelected,
|
|
41
|
+
"aria-describedby": "contextualSurveyStatement",
|
|
42
|
+
"aria-label": tooltipMessage[i],
|
|
43
|
+
shouldFitContainer: true
|
|
44
|
+
}, score));
|
|
45
|
+
})), jsx("div", {
|
|
46
|
+
css: css`
|
|
47
|
+
font-size: 12px;
|
|
48
|
+
font-weight: 600;
|
|
49
|
+
color: ${N200};
|
|
50
|
+
display: flex;
|
|
51
|
+
margin-top: ${gridSize()}px;
|
|
52
|
+
margin-bottom: ${gridSize() * 3}px;
|
|
53
|
+
|
|
54
|
+
& > span {
|
|
55
|
+
width: ${gridSize() * 10}px;
|
|
56
|
+
}
|
|
57
|
+
`,
|
|
58
|
+
"aria-hidden": true
|
|
59
|
+
}, jsx("span", null, "Strongly disagree"), jsx("span", {
|
|
60
|
+
css: css`
|
|
61
|
+
text-align: center;
|
|
62
|
+
margin: 0 auto;
|
|
63
|
+
padding: 0 ${gridSize() * 6}px;
|
|
64
|
+
`
|
|
65
|
+
}, "Neutral"), jsx("span", {
|
|
66
|
+
css: css`
|
|
67
|
+
text-align: right;
|
|
68
|
+
`
|
|
69
|
+
}, "Strongly agree"))));
|