@redocly/theme 0.25.3 → 0.27.0
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/lib/components/Feedback/Comment.d.ts +1 -1
- package/lib/components/Feedback/Comment.js +28 -9
- package/lib/components/Feedback/Emotions.js +8 -25
- package/lib/components/Feedback/Feedback.js +6 -0
- package/lib/components/Feedback/Mood.js +127 -47
- package/lib/components/Feedback/Rating.d.ts +1 -0
- package/lib/components/Feedback/Rating.js +81 -42
- package/lib/components/Feedback/Reasons.d.ts +1 -1
- package/lib/components/Feedback/Reasons.js +4 -16
- package/lib/components/Feedback/Scale.d.ts +4 -0
- package/lib/components/Feedback/Scale.js +178 -0
- package/lib/components/Feedback/Sentiment.js +105 -35
- package/lib/components/Feedback/Stars.d.ts +8 -0
- package/lib/components/Feedback/Stars.js +54 -0
- package/lib/components/Feedback/Thumbs.d.ts +2 -6
- package/lib/components/Feedback/Thumbs.js +9 -46
- package/lib/components/Feedback/index.d.ts +1 -0
- package/lib/components/Feedback/index.js +3 -1
- package/lib/components/Feedback/types.d.ts +27 -6
- package/lib/components/Feedback/useReportDialog.js +3 -1
- package/lib/components/Markdown/MarkdownLayout.js +1 -0
- package/lib/config.d.ts +7 -4
- package/lib/config.js +3 -2
- package/lib/icons/CheckboxIcon/CheckboxIcon.js +3 -3
- package/lib/icons/ColorModeIcon/ColorModeIcon.js +4 -4
- package/lib/icons/DissatisfiedIcon/DissatisfiedIcon.js +5 -5
- package/lib/icons/NeutralIcon/NeutralIcon.js +5 -5
- package/lib/icons/RadioCheckButtonIcon/RadioCheckButtonIcon.d.ts +4 -0
- package/lib/icons/RadioCheckButtonIcon/RadioCheckButtonIcon.js +16 -0
- package/lib/icons/RadioCheckButtonIcon/index.d.ts +1 -0
- package/lib/icons/RadioCheckButtonIcon/index.js +18 -0
- package/lib/icons/SatisfiedIcon/SatisfiedIcon.js +5 -5
- package/lib/icons/ThumbDownIcon/ThumbDownIcon.d.ts +4 -0
- package/lib/icons/ThumbDownIcon/ThumbDownIcon.js +14 -0
- package/lib/icons/ThumbDownIcon/index.d.ts +1 -0
- package/lib/icons/ThumbDownIcon/index.js +18 -0
- package/lib/icons/ThumbUpIcon/ThumbUpIcon.d.ts +4 -0
- package/lib/icons/ThumbUpIcon/ThumbUpIcon.js +14 -0
- package/lib/icons/ThumbUpIcon/index.d.ts +1 -0
- package/lib/icons/ThumbUpIcon/index.js +18 -0
- package/lib/types/portal/src/shared/constants.d.ts +2 -1
- package/lib/types/portal/src/shared/constants.js +1 -0
- package/lib/types/portal/src/shared/types/feedback.d.ts +2 -2
- package/package.json +2 -2
- package/src/components/Feedback/Comment.tsx +53 -20
- package/src/components/Feedback/Emotions.tsx +11 -32
- package/src/components/Feedback/Feedback.tsx +13 -1
- package/src/components/Feedback/Mood.tsx +177 -80
- package/src/components/Feedback/Rating.tsx +106 -79
- package/src/components/Feedback/Reasons.tsx +3 -19
- package/src/components/Feedback/Scale.tsx +229 -0
- package/src/components/Feedback/Sentiment.tsx +150 -56
- package/src/components/Feedback/Stars.tsx +51 -0
- package/src/components/Feedback/Thumbs.tsx +9 -106
- package/src/components/Feedback/index.ts +1 -0
- package/src/components/Feedback/types.ts +24 -5
- package/src/components/Feedback/useReportDialog.ts +3 -1
- package/src/components/Markdown/MarkdownLayout.tsx +1 -0
- package/src/config.ts +3 -2
- package/src/icons/CheckboxIcon/CheckboxIcon.tsx +4 -4
- package/src/icons/ColorModeIcon/ColorModeIcon.tsx +4 -4
- package/src/icons/DissatisfiedIcon/DissatisfiedIcon.tsx +5 -15
- package/src/icons/NeutralIcon/NeutralIcon.tsx +5 -14
- package/src/icons/RadioCheckButtonIcon/RadioCheckButtonIcon.tsx +19 -0
- package/src/icons/RadioCheckButtonIcon/index.ts +1 -0
- package/src/icons/SatisfiedIcon/SatisfiedIcon.tsx +5 -9
- package/src/icons/ThumbDownIcon/ThumbDownIcon.tsx +15 -0
- package/src/icons/ThumbDownIcon/index.ts +1 -0
- package/src/icons/ThumbUpIcon/ThumbUpIcon.tsx +15 -0
- package/src/icons/ThumbUpIcon/index.ts +1 -0
- package/src/types/portal/src/shared/constants.ts +1 -0
- package/src/types/portal/src/shared/types/feedback.ts +2 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { CommentProps } from '../../components/Feedback';
|
|
3
|
-
export declare const Comment: ({ settings, onSubmit, onCancel, className }: CommentProps) => JSX.Element;
|
|
3
|
+
export declare const Comment: ({ settings, onSubmit, onCancel, className, standAlone, }: CommentProps) => JSX.Element;
|
|
@@ -31,7 +31,9 @@ const React = __importStar(require("react"));
|
|
|
31
31
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
32
|
const Button_1 = require("../../components/Button/Button");
|
|
33
33
|
const hooks_1 = require("../../mocks/hooks");
|
|
34
|
-
const
|
|
34
|
+
const RadioCheckButtonIcon_1 = require("../../icons/RadioCheckButtonIcon");
|
|
35
|
+
const media_css_1 = require("../../mocks/media-css");
|
|
36
|
+
const Comment = ({ settings, onSubmit, onCancel, className, standAlone = true, }) => {
|
|
35
37
|
const { label, submitText } = settings || {};
|
|
36
38
|
const [text, setText] = React.useState('');
|
|
37
39
|
const [submitValue, setSubmitValue] = React.useState('');
|
|
@@ -43,25 +45,42 @@ const Comment = ({ settings, onSubmit, onCancel, className }) => {
|
|
|
43
45
|
onSubmit({ comment: text });
|
|
44
46
|
};
|
|
45
47
|
const handleTextAreaChange = (e) => {
|
|
46
|
-
|
|
48
|
+
const commentValue = e.target.value;
|
|
49
|
+
setText(commentValue);
|
|
50
|
+
if (!standAlone) {
|
|
51
|
+
onSubmit({ comment: commentValue });
|
|
52
|
+
}
|
|
47
53
|
};
|
|
48
54
|
if (submitValue) {
|
|
49
|
-
return (React.createElement(
|
|
50
|
-
React.createElement(Label, { "data-translation-key": "theme.feedback.settings.comment.submitText" }, translate('theme.feedback.settings.comment.submitText', submitText || 'Thank you for helping improve our documentation!'))
|
|
55
|
+
return (React.createElement(StateWrapper, { className: className },
|
|
56
|
+
React.createElement(Label, { "data-translation-key": "theme.feedback.settings.comment.submitText" }, translate('theme.feedback.settings.comment.submitText', submitText || 'Thank you for helping improve our documentation!')),
|
|
57
|
+
React.createElement(RadioCheckButtonIcon_1.RadioCheckButtonIcon, null)));
|
|
51
58
|
}
|
|
52
|
-
return (React.createElement(Wrapper, { "data-component-name": "Feedback/Comment", className: className },
|
|
59
|
+
return (React.createElement(Wrapper, { "data-component-name": "Feedback/Comment", className: className, style: standAlone ? { width: '424px', padding: '16px 24px' } : { width: 'auto' } },
|
|
53
60
|
React.createElement(Label, { "data-translation-key": "theme.feedback.settings.comment.label" }, translate('theme.feedback.settings.comment.label', label || 'Please share your feedback with us.')),
|
|
54
61
|
React.createElement(TextArea, { rows: 3, onChange: handleTextAreaChange }),
|
|
55
|
-
React.createElement(ButtonsContainer, null,
|
|
62
|
+
standAlone && (React.createElement(ButtonsContainer, null,
|
|
56
63
|
React.createElement(SendButton, { "data-translation-key": "theme.feedback.settings.comment.send", onClick: send }, translate('theme.feedback.settings.comment.send', 'Send')),
|
|
57
|
-
onCancel && (React.createElement(CancelButton, { "data-translation-key": "theme.feedback.settings.comment.cancel", onClick: onCancel }, translate('theme.feedback.settings.comment.cancel', 'Cancel'))))));
|
|
64
|
+
onCancel && (React.createElement(CancelButton, { "data-translation-key": "theme.feedback.settings.comment.cancel", onClick: onCancel }, translate('theme.feedback.settings.comment.cancel', 'Cancel')))))));
|
|
58
65
|
};
|
|
59
66
|
exports.Comment = Comment;
|
|
60
67
|
const Wrapper = styled_components_1.default.div `
|
|
61
68
|
font-family: var(--font-family-base);
|
|
62
69
|
display: flex;
|
|
63
70
|
flex-direction: column;
|
|
64
|
-
|
|
71
|
+
justify-content: space-between;
|
|
72
|
+
border-radius: 8px;
|
|
73
|
+
background: var(--bg-raised);
|
|
74
|
+
`;
|
|
75
|
+
const StateWrapper = (0, styled_components_1.default)(Wrapper) `
|
|
76
|
+
flex-direction: row;
|
|
77
|
+
align-items: center;
|
|
78
|
+
width: 424px;
|
|
79
|
+
padding: 16px 24px;
|
|
80
|
+
|
|
81
|
+
@media screen and (max-width: ${media_css_1.breakpoints.small}) {
|
|
82
|
+
width: 100%;
|
|
83
|
+
}
|
|
65
84
|
`;
|
|
66
85
|
const Label = styled_components_1.default.h3 `
|
|
67
86
|
font-family: var(--h3-font-family);
|
|
@@ -81,7 +100,7 @@ const TextArea = styled_components_1.default.textarea `
|
|
|
81
100
|
`;
|
|
82
101
|
const ButtonsContainer = styled_components_1.default.div `
|
|
83
102
|
display: flex;
|
|
84
|
-
justify-content:
|
|
103
|
+
justify-content: end;
|
|
85
104
|
`;
|
|
86
105
|
const SendButton = (0, styled_components_1.default)(Button_1.Button).attrs(() => ({
|
|
87
106
|
color: 'primary',
|
|
@@ -31,40 +31,23 @@ const React = __importStar(require("react"));
|
|
|
31
31
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
32
|
const icons_1 = require("../../icons");
|
|
33
33
|
const Satisfied = () => {
|
|
34
|
-
return (React.createElement(
|
|
35
|
-
React.createElement(
|
|
36
|
-
React.createElement(icons_1.SatisfiedIcon, null))));
|
|
34
|
+
return (React.createElement(Icon, null,
|
|
35
|
+
React.createElement(icons_1.SatisfiedIcon, null)));
|
|
37
36
|
};
|
|
38
37
|
exports.Satisfied = Satisfied;
|
|
39
38
|
const Dissatisfied = () => {
|
|
40
|
-
return (React.createElement(
|
|
41
|
-
React.createElement(
|
|
42
|
-
React.createElement(icons_1.DissatisfiedIcon, null))));
|
|
39
|
+
return (React.createElement(Icon, null,
|
|
40
|
+
React.createElement(icons_1.DissatisfiedIcon, null)));
|
|
43
41
|
};
|
|
44
42
|
exports.Dissatisfied = Dissatisfied;
|
|
45
43
|
const Neutral = () => {
|
|
46
|
-
return (React.createElement(
|
|
47
|
-
React.createElement(
|
|
48
|
-
React.createElement(icons_1.NeutralIcon, null))));
|
|
44
|
+
return (React.createElement(Icon, null,
|
|
45
|
+
React.createElement(icons_1.NeutralIcon, null)));
|
|
49
46
|
};
|
|
50
47
|
exports.Neutral = Neutral;
|
|
51
|
-
const Wrapper = styled_components_1.default.div `
|
|
52
|
-
font-family: var(--font-family-base);
|
|
53
|
-
display: flex;
|
|
54
|
-
color: var(--color-info-text);
|
|
55
|
-
&:hover {
|
|
56
|
-
color: var(--color-info-text-active);
|
|
57
|
-
svg {
|
|
58
|
-
> g {
|
|
59
|
-
fill: var(--color-info-text-active);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
`;
|
|
64
48
|
const Icon = styled_components_1.default.div `
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
margin-right: 5px;
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
68
51
|
> svg {
|
|
69
52
|
> g {
|
|
70
53
|
fill: var(--color-info-text);
|
|
@@ -60,6 +60,12 @@ const Feedback = (props) => {
|
|
|
60
60
|
submitFeedback({ type: 'mood', values, path });
|
|
61
61
|
telemetry_1.telemetry.send('feedback_sent', { type: 'mood' });
|
|
62
62
|
} })));
|
|
63
|
+
case 'scale':
|
|
64
|
+
return (React.createElement(Wrapper, null,
|
|
65
|
+
React.createElement(Feedback_1.Scale, { settings: settings, onSubmit: (values) => {
|
|
66
|
+
submitFeedback({ type: 'scale', values, path });
|
|
67
|
+
telemetry_1.telemetry.send('feedback_sent', { type: 'scale' });
|
|
68
|
+
} })));
|
|
63
69
|
case 'comment':
|
|
64
70
|
return (React.createElement(Wrapper, null,
|
|
65
71
|
React.createElement(Feedback_1.Comment, { settings: settings, onSubmit: (values) => {
|
|
@@ -28,10 +28,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.Mood = exports.MOOD_STATES = void 0;
|
|
30
30
|
const React = __importStar(require("react"));
|
|
31
|
+
const react_1 = require("react");
|
|
31
32
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
33
|
const hooks_1 = require("../../mocks/hooks");
|
|
33
34
|
const Emotions_1 = require("../../components/Feedback/Emotions");
|
|
34
35
|
const Feedback_1 = require("../../components/Feedback");
|
|
36
|
+
const RadioCheckButtonIcon_1 = require("../../icons/RadioCheckButtonIcon");
|
|
37
|
+
const components_1 = require("../../components");
|
|
38
|
+
const media_css_1 = require("../../mocks/media-css");
|
|
35
39
|
var MOOD_STATES;
|
|
36
40
|
(function (MOOD_STATES) {
|
|
37
41
|
MOOD_STATES["SATISFIED"] = "satisfied";
|
|
@@ -45,69 +49,145 @@ const Mood = ({ settings, onSubmit, className }) => {
|
|
|
45
49
|
const [comment, setComment] = React.useState('');
|
|
46
50
|
const [reasons, setReasons] = React.useState([]);
|
|
47
51
|
const { translate } = (0, hooks_1.useTranslate)();
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
52
|
+
const renderCommentLabel = (score) => {
|
|
53
|
+
if (!(commentSettings === null || commentSettings === void 0 ? void 0 : commentSettings.enable))
|
|
54
|
+
return '';
|
|
55
|
+
switch (score) {
|
|
56
|
+
case MOOD_STATES.SATISFIED:
|
|
57
|
+
return translate('theme.feedback.settings.comment.satisfiedLabel', commentSettings.satisfiedLabel || 'What was most helpful?');
|
|
58
|
+
case MOOD_STATES.NEUTRAL:
|
|
59
|
+
return translate('theme.feedback.settings.comment.neutralLabel', commentSettings.neutralLabel || 'What can we improve?');
|
|
60
|
+
case MOOD_STATES.DISSATISFIED:
|
|
61
|
+
return translate('theme.feedback.settings.comment.dissatisfiedLabel', commentSettings.dissatisfiedLabel || 'What can we improve?');
|
|
62
|
+
default:
|
|
63
|
+
return translate('theme.feedback.settings.comment.satisfiedLabel', 'What can we improve?');
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const displayReasons = !!score && (reasonsSettings === null || reasonsSettings === void 0 ? void 0 : reasonsSettings.enable);
|
|
67
|
+
const displayComment = !!score && (commentSettings === null || commentSettings === void 0 ? void 0 : commentSettings.enable);
|
|
68
|
+
const displaySubmitBnt = !!score && (displayReasons || displayComment);
|
|
69
|
+
const onSubmitMoodForm = () => {
|
|
70
|
+
onSubmit({
|
|
71
|
+
score: remapScore(score),
|
|
72
|
+
comment,
|
|
73
|
+
reasons,
|
|
74
|
+
});
|
|
75
|
+
setIsSubmitted(true);
|
|
76
|
+
};
|
|
77
|
+
(0, react_1.useEffect)(() => {
|
|
78
|
+
if (score && !displayComment && !displayReasons) {
|
|
79
|
+
onSubmitMoodForm();
|
|
76
80
|
}
|
|
81
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
82
|
+
}, [score, displayComment, displayReasons]);
|
|
83
|
+
if (isSubmitted) {
|
|
77
84
|
return (React.createElement(Wrapper, null,
|
|
78
|
-
React.createElement(Label, { "data-translation-key": "theme.feedback.settings.submitText" }, translate('theme.feedback.settings.submitText', submitText || 'Thank you for
|
|
85
|
+
React.createElement(Label, { "data-translation-key": "theme.feedback.settings.submitText" }, translate('theme.feedback.settings.submitText', submitText || 'Thank you for helping improve our documentation!')),
|
|
86
|
+
React.createElement(RadioCheckButtonIcon_1.RadioCheckButtonIcon, null)));
|
|
79
87
|
}
|
|
80
88
|
return (React.createElement(Wrapper, { "data-component-name": "Feedback/Mood", className: className },
|
|
81
|
-
React.createElement(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
React.createElement(StyledForm, null,
|
|
90
|
+
React.createElement(StyledFormMandatoryFields, null,
|
|
91
|
+
React.createElement(Label, { "data-translation-key": "theme.feedback.settings.label" }, translate('theme.feedback.settings.label', label || 'Was this page helpful?')),
|
|
92
|
+
React.createElement(StyledMandatoryFieldContainer, null,
|
|
93
|
+
React.createElement(React.Fragment, null,
|
|
94
|
+
React.createElement(Vote, { className: `${score === MOOD_STATES.DISSATISFIED ? 'active' : ''}`, onClick: () => {
|
|
95
|
+
setScore(MOOD_STATES.DISSATISFIED);
|
|
96
|
+
} },
|
|
97
|
+
React.createElement(Emotions_1.Dissatisfied, null)),
|
|
98
|
+
React.createElement(Vote, { className: `${score === MOOD_STATES.NEUTRAL ? 'active' : ''}`, onClick: () => {
|
|
99
|
+
setScore(MOOD_STATES.NEUTRAL);
|
|
100
|
+
} },
|
|
101
|
+
React.createElement(Emotions_1.Neutral, null)),
|
|
102
|
+
React.createElement(Vote, { className: `${score === MOOD_STATES.SATISFIED ? 'active' : ''}`, onClick: () => {
|
|
103
|
+
setScore(MOOD_STATES.SATISFIED);
|
|
104
|
+
} },
|
|
105
|
+
React.createElement(Emotions_1.Satisfied, null))))),
|
|
106
|
+
React.createElement(StyledFormOptionalFields, null,
|
|
107
|
+
displayReasons && (React.createElement(Feedback_1.Reasons, { settings: {
|
|
108
|
+
label: reasonsSettings === null || reasonsSettings === void 0 ? void 0 : reasonsSettings.label,
|
|
109
|
+
items: (reasonsSettings === null || reasonsSettings === void 0 ? void 0 : reasonsSettings.items) || [],
|
|
110
|
+
multi: reasonsSettings === null || reasonsSettings === void 0 ? void 0 : reasonsSettings.multi,
|
|
111
|
+
}, onChange: setReasons })),
|
|
112
|
+
displayComment && (React.createElement(Feedback_1.Comment, { standAlone: false, onSubmit: ({ comment }) => setComment(comment), settings: { label: renderCommentLabel(score) } }))),
|
|
113
|
+
displaySubmitBnt && (React.createElement(ButtonsContainer, null,
|
|
114
|
+
React.createElement(SubmitButton, { onClick: onSubmitMoodForm }, "Submit"))))));
|
|
94
115
|
};
|
|
95
116
|
exports.Mood = Mood;
|
|
117
|
+
const remapScore = (score) => {
|
|
118
|
+
switch (score) {
|
|
119
|
+
case MOOD_STATES.SATISFIED:
|
|
120
|
+
return 1;
|
|
121
|
+
case MOOD_STATES.NEUTRAL:
|
|
122
|
+
return 0;
|
|
123
|
+
case MOOD_STATES.DISSATISFIED:
|
|
124
|
+
return -1;
|
|
125
|
+
default:
|
|
126
|
+
return 0;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
96
129
|
const Wrapper = styled_components_1.default.div `
|
|
97
130
|
font-family: var(--font-family-base);
|
|
98
131
|
display: flex;
|
|
132
|
+
justify-content: space-between;
|
|
99
133
|
align-items: center;
|
|
134
|
+
padding: 16px 24px;
|
|
135
|
+
width: 424px;
|
|
136
|
+
border-radius: 8px;
|
|
137
|
+
background: var(--bg-raised);
|
|
138
|
+
|
|
139
|
+
@media screen and (max-width: ${media_css_1.breakpoints.small}) {
|
|
140
|
+
width: 100%;
|
|
141
|
+
}
|
|
100
142
|
`;
|
|
101
143
|
const Label = styled_components_1.default.h3 `
|
|
102
|
-
font-family: var(--h3-font-family);
|
|
103
|
-
font-weight: var(--h3-font-weight);
|
|
104
|
-
font-size: var(--h3-font-size);
|
|
105
|
-
line-height: var(--h3-line-height);
|
|
106
|
-
color: var(--h3-text-color);
|
|
107
144
|
margin-right: 15px;
|
|
145
|
+
font-family: var(--h4-font-family);
|
|
146
|
+
font-weight: var(--h4-font-weight);
|
|
147
|
+
font-size: var(--h4-font-size);
|
|
148
|
+
line-height: var(--h4-line-height);
|
|
149
|
+
color: var(--h3-text-color);
|
|
108
150
|
`;
|
|
109
151
|
const Vote = styled_components_1.default.div `
|
|
110
152
|
cursor: pointer;
|
|
111
153
|
margin: 0 10px;
|
|
154
|
+
color: var(--text-description);
|
|
155
|
+
&.active {
|
|
156
|
+
color: var(--text-primary);
|
|
157
|
+
}
|
|
158
|
+
&:hover {
|
|
159
|
+
color: var(--text-primary);
|
|
160
|
+
svg {
|
|
161
|
+
> g {
|
|
162
|
+
fill: var(--text-primary);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
`;
|
|
167
|
+
const SubmitButton = (0, styled_components_1.default)(components_1.Button).attrs(() => ({
|
|
168
|
+
color: 'primary',
|
|
169
|
+
})) `
|
|
170
|
+
width: 100px;
|
|
171
|
+
margin-left: 0;
|
|
172
|
+
margin-right: 0;
|
|
173
|
+
`;
|
|
174
|
+
const ButtonsContainer = styled_components_1.default.div `
|
|
175
|
+
display: flex;
|
|
176
|
+
justify-content: end;
|
|
177
|
+
`;
|
|
178
|
+
const StyledForm = styled_components_1.default.form `
|
|
179
|
+
width: 100%;
|
|
180
|
+
`;
|
|
181
|
+
const StyledFormOptionalFields = styled_components_1.default.div `
|
|
182
|
+
display: flex;
|
|
183
|
+
flex-flow: column;
|
|
184
|
+
`;
|
|
185
|
+
const StyledFormMandatoryFields = styled_components_1.default.div `
|
|
186
|
+
display: flex;
|
|
187
|
+
justify-content: space-between;
|
|
188
|
+
`;
|
|
189
|
+
const StyledMandatoryFieldContainer = styled_components_1.default.div `
|
|
190
|
+
display: flex;
|
|
191
|
+
align-items: center;
|
|
112
192
|
`;
|
|
113
193
|
//# sourceMappingURL=Mood.js.map
|
|
@@ -26,69 +26,108 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.Rating = void 0;
|
|
29
|
+
exports.Rating = exports.FEEDBACK_MAX_RATING = void 0;
|
|
30
30
|
const React = __importStar(require("react"));
|
|
31
31
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
|
+
const react_1 = require("react");
|
|
32
33
|
const Feedback_1 = require("../../components/Feedback");
|
|
34
|
+
const components_1 = require("../../components");
|
|
33
35
|
const hooks_1 = require("../../mocks/hooks");
|
|
36
|
+
const RadioCheckButtonIcon_1 = require("../../icons/RadioCheckButtonIcon");
|
|
37
|
+
const media_css_1 = require("../../mocks/media-css");
|
|
38
|
+
const Stars_1 = require("./Stars");
|
|
39
|
+
exports.FEEDBACK_MAX_RATING = 5;
|
|
34
40
|
const Rating = ({ settings, onSubmit, className }) => {
|
|
35
|
-
const { label,
|
|
41
|
+
const { label, submitText, comment: commentSettings, reasons: reasonsSettings } = settings || {};
|
|
36
42
|
const [isSubmitted, setIsSubmitted] = React.useState(false);
|
|
37
43
|
const [score, setScore] = React.useState(0);
|
|
38
|
-
const [comment, setComment] = React.useState('');
|
|
39
44
|
const [reasons, setReasons] = React.useState([]);
|
|
45
|
+
const [comment, setComment] = React.useState('');
|
|
40
46
|
const { translate } = (0, hooks_1.useTranslate)();
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
max: maxRating,
|
|
57
|
-
});
|
|
58
|
-
setIsSubmitted(true);
|
|
47
|
+
const onSubmitRatingForm = () => {
|
|
48
|
+
onSubmit({
|
|
49
|
+
score,
|
|
50
|
+
comment,
|
|
51
|
+
reasons,
|
|
52
|
+
max: exports.FEEDBACK_MAX_RATING,
|
|
53
|
+
});
|
|
54
|
+
setIsSubmitted(true);
|
|
55
|
+
};
|
|
56
|
+
const displayReasons = !!score && (reasonsSettings === null || reasonsSettings === void 0 ? void 0 : reasonsSettings.enable);
|
|
57
|
+
const displayComment = !!score && (commentSettings === null || commentSettings === void 0 ? void 0 : commentSettings.enable);
|
|
58
|
+
const displaySubmitBnt = !!score && (displayReasons || displayComment);
|
|
59
|
+
(0, react_1.useEffect)(() => {
|
|
60
|
+
if (score && !displayComment && !displayReasons) {
|
|
61
|
+
onSubmitRatingForm();
|
|
59
62
|
}
|
|
63
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
64
|
+
}, [score, displayComment, displayReasons]);
|
|
65
|
+
if (isSubmitted) {
|
|
60
66
|
return (React.createElement(Wrapper, null,
|
|
61
|
-
React.createElement(Label, { "data-translation-key": "theme.feedback.settings.submitText" }, translate('theme.feedback.settings.submitText', submitText || 'Thank you for helping improve our documentation!'))
|
|
67
|
+
React.createElement(Label, { "data-translation-key": "theme.feedback.settings.submitText" }, translate('theme.feedback.settings.submitText', submitText || 'Thank you for helping improve our documentation!')),
|
|
68
|
+
React.createElement(RadioCheckButtonIcon_1.RadioCheckButtonIcon, null)));
|
|
62
69
|
}
|
|
63
70
|
return (React.createElement(Wrapper, { "data-component-name": "Feedback/Rating", className: className },
|
|
64
|
-
React.createElement(
|
|
65
|
-
|
|
71
|
+
React.createElement(StyledForm, null,
|
|
72
|
+
React.createElement(StyledFormMandatoryFields, null,
|
|
73
|
+
React.createElement(Label, { "data-translation-key": "theme.feedback.settings.label" }, translate('theme.feedback.settings.label', label || 'How helpful was this page?')),
|
|
74
|
+
React.createElement(StyledMandatoryFieldContainer, null,
|
|
75
|
+
React.createElement(Stars_1.Stars, { max: exports.FEEDBACK_MAX_RATING, onChange: setScore, value: score }))),
|
|
76
|
+
React.createElement(StyledFormOptionalFields, null,
|
|
77
|
+
displayReasons && (React.createElement(Feedback_1.Reasons, { settings: {
|
|
78
|
+
label: reasonsSettings === null || reasonsSettings === void 0 ? void 0 : reasonsSettings.label,
|
|
79
|
+
items: (reasonsSettings === null || reasonsSettings === void 0 ? void 0 : reasonsSettings.items) || [],
|
|
80
|
+
multi: reasonsSettings === null || reasonsSettings === void 0 ? void 0 : reasonsSettings.multi,
|
|
81
|
+
}, onChange: setReasons })),
|
|
82
|
+
displayComment && (React.createElement(Feedback_1.Comment, { standAlone: false, onSubmit: ({ comment }) => setComment(comment), settings: { label: commentSettings.label } }))),
|
|
83
|
+
displaySubmitBnt && (React.createElement(ButtonsContainer, null,
|
|
84
|
+
React.createElement(SubmitButton, { onClick: onSubmitRatingForm }, "Submit"))))));
|
|
66
85
|
};
|
|
67
86
|
exports.Rating = Rating;
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
87
|
+
const StyledForm = styled_components_1.default.form `
|
|
88
|
+
width: 100%;
|
|
89
|
+
`;
|
|
90
|
+
const StyledFormOptionalFields = styled_components_1.default.div `
|
|
91
|
+
display: flex;
|
|
92
|
+
flex-flow: column;
|
|
93
|
+
`;
|
|
94
|
+
const StyledFormMandatoryFields = styled_components_1.default.div `
|
|
95
|
+
display: flex;
|
|
96
|
+
justify-content: space-between;
|
|
97
|
+
`;
|
|
98
|
+
const StyledMandatoryFieldContainer = styled_components_1.default.div `
|
|
99
|
+
display: flex;
|
|
100
|
+
`;
|
|
79
101
|
const Wrapper = styled_components_1.default.div `
|
|
80
102
|
display: flex;
|
|
103
|
+
justify-content: space-between;
|
|
81
104
|
align-items: center;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
105
|
+
padding: 16px 24px;
|
|
106
|
+
width: 424px;
|
|
107
|
+
border-radius: 8px;
|
|
108
|
+
background: var(--bg-raised);
|
|
109
|
+
|
|
110
|
+
@media screen and (max-width: ${media_css_1.breakpoints.small}) {
|
|
111
|
+
width: 100%;
|
|
112
|
+
}
|
|
85
113
|
`;
|
|
86
114
|
const Label = styled_components_1.default.h3 `
|
|
87
115
|
margin-right: 15px;
|
|
88
|
-
font-family: var(--
|
|
89
|
-
font-weight: var(--
|
|
90
|
-
font-size: var(--
|
|
91
|
-
line-height: var(--
|
|
116
|
+
font-family: var(--h4-font-family);
|
|
117
|
+
font-weight: var(--h4-font-weight);
|
|
118
|
+
font-size: var(--h4-font-size);
|
|
119
|
+
line-height: var(--h4-line-height);
|
|
92
120
|
color: var(--h3-text-color);
|
|
93
121
|
`;
|
|
122
|
+
const SubmitButton = (0, styled_components_1.default)(components_1.Button).attrs(() => ({
|
|
123
|
+
color: 'primary',
|
|
124
|
+
})) `
|
|
125
|
+
width: 100px;
|
|
126
|
+
margin-left: 0;
|
|
127
|
+
margin-right: 0;
|
|
128
|
+
`;
|
|
129
|
+
const ButtonsContainer = styled_components_1.default.div `
|
|
130
|
+
display: flex;
|
|
131
|
+
justify-content: end;
|
|
132
|
+
`;
|
|
94
133
|
//# sourceMappingURL=Rating.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ReasonsProps } from '../../components/Feedback';
|
|
3
|
-
export declare const Reasons: ({ settings,
|
|
3
|
+
export declare const Reasons: ({ settings, onChange, className }: ReasonsProps) => JSX.Element;
|
|
@@ -29,10 +29,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.Reasons = void 0;
|
|
30
30
|
const React = __importStar(require("react"));
|
|
31
31
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
|
-
const Button_1 = require("../../components/Button/Button");
|
|
33
32
|
const hooks_1 = require("../../mocks/hooks");
|
|
34
|
-
const Reasons = ({ settings,
|
|
35
|
-
const { label, multi,
|
|
33
|
+
const Reasons = ({ settings, onChange, className }) => {
|
|
34
|
+
const { label, multi, items = [] } = settings;
|
|
36
35
|
const [checkedState, setCheckedState] = React.useState(new Array(items.length).fill(false));
|
|
37
36
|
const { translate } = (0, hooks_1.useTranslate)();
|
|
38
37
|
if (!items.length) {
|
|
@@ -44,16 +43,13 @@ const Reasons = ({ settings, onSubmit, className }) => {
|
|
|
44
43
|
? checkedState.map((item, index) => (index === position ? !item : item))
|
|
45
44
|
: items.map((_, idx) => position === idx);
|
|
46
45
|
setCheckedState(updatedCheckedState);
|
|
47
|
-
|
|
48
|
-
const submitForm = () => {
|
|
49
|
-
onSubmit({ reasons: items.filter((_, index) => !!checkedState[index]) });
|
|
46
|
+
onChange(items.filter((_, index) => !!updatedCheckedState[index]));
|
|
50
47
|
};
|
|
51
48
|
return (React.createElement(Wrapper, { "data-component-name": "Feedback/Reasons", "data-translation-key": "theme.feedback.settings.reasons.label", className: className },
|
|
52
49
|
React.createElement(Label, null, translate('theme.feedback.settings.reasons.label', label || 'Which statement describes your thoughts about this page?')),
|
|
53
50
|
items.map((reason, idx) => (React.createElement(OptionWrapper, { key: reason },
|
|
54
51
|
React.createElement("input", { type: input_type, value: reason, checked: checkedState[idx], name: "reasons", onChange: () => handleOptionChange(idx) }),
|
|
55
|
-
React.createElement("label", { "data-translation-key": `theme.feedback.settings.reasons.items.${idx + 1}`, id: reason, onClick: () => handleOptionChange(idx) }, translate(`theme.feedback.settings.reasons.items.${idx + 1}`, reason)))))
|
|
56
|
-
React.createElement(SendButton, { "data-translation-key": "theme.feedback.settings.reasons.send", onClick: submitForm }, translate('theme.feedback.settings.reasons.send', buttonText || 'Send'))));
|
|
52
|
+
React.createElement("label", { "data-translation-key": `theme.feedback.settings.reasons.items.${idx + 1}`, id: reason, onClick: () => handleOptionChange(idx) }, translate(`theme.feedback.settings.reasons.items.${idx + 1}`, reason)))))));
|
|
57
53
|
};
|
|
58
54
|
exports.Reasons = Reasons;
|
|
59
55
|
const Wrapper = styled_components_1.default.div `
|
|
@@ -69,14 +65,6 @@ const Label = styled_components_1.default.h3 `
|
|
|
69
65
|
color: var(--h3-text-color);
|
|
70
66
|
margin-right: 15px;
|
|
71
67
|
`;
|
|
72
|
-
const SendButton = (0, styled_components_1.default)(Button_1.Button).attrs(() => ({
|
|
73
|
-
color: 'primary',
|
|
74
|
-
})) `
|
|
75
|
-
width: 100px;
|
|
76
|
-
margin-left: 0;
|
|
77
|
-
margin-right: 0;
|
|
78
|
-
margin-top: 15px;
|
|
79
|
-
`;
|
|
80
68
|
const OptionWrapper = styled_components_1.default.div `
|
|
81
69
|
margin: 5px 0;
|
|
82
70
|
display: flex;
|