@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,10 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { useEffect } from 'react';
|
|
2
3
|
import styled from 'styled-components';
|
|
3
4
|
|
|
4
5
|
import type { MoodProps, ReasonsProps } from '@theme/components/';
|
|
5
6
|
import { useTranslate } from '@portal/hooks';
|
|
6
7
|
import { Dissatisfied, Neutral, Satisfied } from '@theme/components/Feedback/Emotions';
|
|
7
8
|
import { Comment, Reasons } from '@theme/components/Feedback';
|
|
9
|
+
import { RadioCheckButtonIcon } from '@theme/icons/RadioCheckButtonIcon';
|
|
10
|
+
import { Button } from '@theme/components/';
|
|
11
|
+
import { breakpoints } from '@portal/media-css';
|
|
8
12
|
|
|
9
13
|
export enum MOOD_STATES {
|
|
10
14
|
SATISFIED = 'satisfied',
|
|
@@ -20,119 +24,212 @@ export const Mood = ({ settings, onSubmit, className }: MoodProps): JSX.Element
|
|
|
20
24
|
const [reasons, setReasons] = React.useState([] as ReasonsProps['settings']['items']);
|
|
21
25
|
const { translate } = useTranslate();
|
|
22
26
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const buttonText = commentSettings?.enable ? 'Next' : 'Send';
|
|
26
|
-
return (
|
|
27
|
-
<Reasons
|
|
28
|
-
onSubmit={({ reasons }) => setReasons(reasons)}
|
|
29
|
-
settings={{ label: reasonsLabel, items, multi, buttonText }}
|
|
30
|
-
/>
|
|
31
|
-
);
|
|
32
|
-
}
|
|
27
|
+
const renderCommentLabel = (score: string) => {
|
|
28
|
+
if (!commentSettings?.enable) return '';
|
|
33
29
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
'theme.feedback.settings.comment.satisfiedLabel',
|
|
55
|
-
'What can we improve?',
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
return (
|
|
60
|
-
<Comment
|
|
61
|
-
onSubmit={({ comment }) => setComment(comment)}
|
|
62
|
-
settings={{ label: renderCommentLabel(score) }}
|
|
63
|
-
/>
|
|
64
|
-
);
|
|
65
|
-
}
|
|
30
|
+
switch (score) {
|
|
31
|
+
case MOOD_STATES.SATISFIED:
|
|
32
|
+
return translate(
|
|
33
|
+
'theme.feedback.settings.comment.satisfiedLabel',
|
|
34
|
+
commentSettings.satisfiedLabel || 'What was most helpful?',
|
|
35
|
+
);
|
|
36
|
+
case MOOD_STATES.NEUTRAL:
|
|
37
|
+
return translate(
|
|
38
|
+
'theme.feedback.settings.comment.neutralLabel',
|
|
39
|
+
commentSettings.neutralLabel || 'What can we improve?',
|
|
40
|
+
);
|
|
41
|
+
case MOOD_STATES.DISSATISFIED:
|
|
42
|
+
return translate(
|
|
43
|
+
'theme.feedback.settings.comment.dissatisfiedLabel',
|
|
44
|
+
commentSettings.dissatisfiedLabel || 'What can we improve?',
|
|
45
|
+
);
|
|
46
|
+
default:
|
|
47
|
+
return translate('theme.feedback.settings.comment.satisfiedLabel', 'What can we improve?');
|
|
48
|
+
}
|
|
49
|
+
};
|
|
66
50
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
score,
|
|
71
|
-
comment,
|
|
72
|
-
reasons,
|
|
73
|
-
});
|
|
51
|
+
const displayReasons = !!score && reasonsSettings?.enable;
|
|
52
|
+
const displayComment = !!score && commentSettings?.enable;
|
|
53
|
+
const displaySubmitBnt = !!score && (displayReasons || displayComment);
|
|
74
54
|
|
|
75
|
-
|
|
55
|
+
const onSubmitMoodForm = () => {
|
|
56
|
+
onSubmit({
|
|
57
|
+
score: remapScore(score),
|
|
58
|
+
comment,
|
|
59
|
+
reasons,
|
|
60
|
+
});
|
|
61
|
+
setIsSubmitted(true);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (score && !displayComment && !displayReasons) {
|
|
66
|
+
onSubmitMoodForm();
|
|
76
67
|
}
|
|
68
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
69
|
+
}, [score, displayComment, displayReasons]);
|
|
77
70
|
|
|
71
|
+
if (isSubmitted) {
|
|
78
72
|
return (
|
|
79
73
|
<Wrapper>
|
|
80
74
|
<Label data-translation-key="theme.feedback.settings.submitText">
|
|
81
75
|
{translate(
|
|
82
76
|
'theme.feedback.settings.submitText',
|
|
83
|
-
submitText || 'Thank you for
|
|
77
|
+
submitText || 'Thank you for helping improve our documentation!',
|
|
84
78
|
)}
|
|
85
79
|
</Label>
|
|
80
|
+
<RadioCheckButtonIcon />
|
|
86
81
|
</Wrapper>
|
|
87
82
|
);
|
|
88
83
|
}
|
|
89
84
|
|
|
90
85
|
return (
|
|
91
86
|
<Wrapper data-component-name="Feedback/Mood" className={className}>
|
|
92
|
-
<
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
87
|
+
<StyledForm>
|
|
88
|
+
<StyledFormMandatoryFields>
|
|
89
|
+
<Label data-translation-key="theme.feedback.settings.label">
|
|
90
|
+
{translate('theme.feedback.settings.label', label || 'Was this page helpful?')}
|
|
91
|
+
</Label>
|
|
92
|
+
<StyledMandatoryFieldContainer>
|
|
93
|
+
<>
|
|
94
|
+
<Vote
|
|
95
|
+
className={`${score === MOOD_STATES.DISSATISFIED ? 'active' : ''}`}
|
|
96
|
+
onClick={() => {
|
|
97
|
+
setScore(MOOD_STATES.DISSATISFIED);
|
|
98
|
+
}}
|
|
99
|
+
>
|
|
100
|
+
<Dissatisfied />
|
|
101
|
+
</Vote>
|
|
102
|
+
<Vote
|
|
103
|
+
className={`${score === MOOD_STATES.NEUTRAL ? 'active' : ''}`}
|
|
104
|
+
onClick={() => {
|
|
105
|
+
setScore(MOOD_STATES.NEUTRAL);
|
|
106
|
+
}}
|
|
107
|
+
>
|
|
108
|
+
<Neutral />
|
|
109
|
+
</Vote>
|
|
110
|
+
<Vote
|
|
111
|
+
className={`${score === MOOD_STATES.SATISFIED ? 'active' : ''}`}
|
|
112
|
+
onClick={() => {
|
|
113
|
+
setScore(MOOD_STATES.SATISFIED);
|
|
114
|
+
}}
|
|
115
|
+
>
|
|
116
|
+
<Satisfied />
|
|
117
|
+
</Vote>
|
|
118
|
+
</>
|
|
119
|
+
</StyledMandatoryFieldContainer>
|
|
120
|
+
</StyledFormMandatoryFields>
|
|
121
|
+
<StyledFormOptionalFields>
|
|
122
|
+
{displayReasons && (
|
|
123
|
+
<Reasons
|
|
124
|
+
settings={{
|
|
125
|
+
label: reasonsSettings?.label,
|
|
126
|
+
items: reasonsSettings?.items || [],
|
|
127
|
+
multi: reasonsSettings?.multi,
|
|
128
|
+
}}
|
|
129
|
+
onChange={setReasons}
|
|
130
|
+
/>
|
|
131
|
+
)}
|
|
132
|
+
|
|
133
|
+
{displayComment && (
|
|
134
|
+
<Comment
|
|
135
|
+
standAlone={false}
|
|
136
|
+
onSubmit={({ comment }) => setComment(comment)}
|
|
137
|
+
settings={{ label: renderCommentLabel(score) }}
|
|
138
|
+
/>
|
|
139
|
+
)}
|
|
140
|
+
</StyledFormOptionalFields>
|
|
141
|
+
{displaySubmitBnt && (
|
|
142
|
+
<ButtonsContainer>
|
|
143
|
+
<SubmitButton onClick={onSubmitMoodForm}>Submit</SubmitButton>
|
|
144
|
+
</ButtonsContainer>
|
|
145
|
+
)}
|
|
146
|
+
</StyledForm>
|
|
116
147
|
</Wrapper>
|
|
117
148
|
);
|
|
118
149
|
};
|
|
119
150
|
|
|
151
|
+
const remapScore = (score: string): number => {
|
|
152
|
+
switch (score) {
|
|
153
|
+
case MOOD_STATES.SATISFIED:
|
|
154
|
+
return 1;
|
|
155
|
+
case MOOD_STATES.NEUTRAL:
|
|
156
|
+
return 0;
|
|
157
|
+
case MOOD_STATES.DISSATISFIED:
|
|
158
|
+
return -1;
|
|
159
|
+
default:
|
|
160
|
+
return 0;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
|
|
120
164
|
const Wrapper = styled.div`
|
|
121
165
|
font-family: var(--font-family-base);
|
|
122
166
|
display: flex;
|
|
167
|
+
justify-content: space-between;
|
|
123
168
|
align-items: center;
|
|
169
|
+
padding: 16px 24px;
|
|
170
|
+
width: 424px;
|
|
171
|
+
border-radius: 8px;
|
|
172
|
+
background: var(--bg-raised);
|
|
173
|
+
|
|
174
|
+
@media screen and (max-width: ${breakpoints.small}) {
|
|
175
|
+
width: 100%;
|
|
176
|
+
}
|
|
124
177
|
`;
|
|
125
178
|
|
|
126
179
|
const Label = styled.h3`
|
|
127
|
-
font-family: var(--h3-font-family);
|
|
128
|
-
font-weight: var(--h3-font-weight);
|
|
129
|
-
font-size: var(--h3-font-size);
|
|
130
|
-
line-height: var(--h3-line-height);
|
|
131
|
-
color: var(--h3-text-color);
|
|
132
180
|
margin-right: 15px;
|
|
181
|
+
font-family: var(--h4-font-family);
|
|
182
|
+
font-weight: var(--h4-font-weight);
|
|
183
|
+
font-size: var(--h4-font-size);
|
|
184
|
+
line-height: var(--h4-line-height);
|
|
185
|
+
color: var(--h3-text-color);
|
|
133
186
|
`;
|
|
134
187
|
|
|
135
188
|
const Vote = styled.div`
|
|
136
189
|
cursor: pointer;
|
|
137
190
|
margin: 0 10px;
|
|
191
|
+
color: var(--text-description);
|
|
192
|
+
&.active {
|
|
193
|
+
color: var(--text-primary);
|
|
194
|
+
}
|
|
195
|
+
&:hover {
|
|
196
|
+
color: var(--text-primary);
|
|
197
|
+
svg {
|
|
198
|
+
> g {
|
|
199
|
+
fill: var(--text-primary);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
`;
|
|
204
|
+
|
|
205
|
+
const SubmitButton = styled(Button).attrs(() => ({
|
|
206
|
+
color: 'primary',
|
|
207
|
+
}))`
|
|
208
|
+
width: 100px;
|
|
209
|
+
margin-left: 0;
|
|
210
|
+
margin-right: 0;
|
|
211
|
+
`;
|
|
212
|
+
|
|
213
|
+
const ButtonsContainer = styled.div`
|
|
214
|
+
display: flex;
|
|
215
|
+
justify-content: end;
|
|
216
|
+
`;
|
|
217
|
+
|
|
218
|
+
const StyledForm = styled.form`
|
|
219
|
+
width: 100%;
|
|
220
|
+
`;
|
|
221
|
+
|
|
222
|
+
const StyledFormOptionalFields = styled.div`
|
|
223
|
+
display: flex;
|
|
224
|
+
flex-flow: column;
|
|
225
|
+
`;
|
|
226
|
+
|
|
227
|
+
const StyledFormMandatoryFields = styled.div`
|
|
228
|
+
display: flex;
|
|
229
|
+
justify-content: space-between;
|
|
230
|
+
`;
|
|
231
|
+
|
|
232
|
+
const StyledMandatoryFieldContainer = styled.div`
|
|
233
|
+
display: flex;
|
|
234
|
+
align-items: center;
|
|
138
235
|
`;
|
|
@@ -1,61 +1,48 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
+
import { useEffect } from 'react';
|
|
3
4
|
|
|
4
5
|
import type { RatingProps, ReasonsProps } from '@theme/components/Feedback';
|
|
5
6
|
import { Comment, Reasons } from '@theme/components/Feedback';
|
|
7
|
+
import { Button } from '@theme/components';
|
|
6
8
|
import { useTranslate } from '@portal/hooks';
|
|
9
|
+
import { RadioCheckButtonIcon } from '@theme/icons/RadioCheckButtonIcon';
|
|
10
|
+
import { breakpoints } from '@portal/media-css';
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
+
import { Stars } from './Stars';
|
|
13
|
+
|
|
14
|
+
export const FEEDBACK_MAX_RATING = 5;
|
|
12
15
|
|
|
13
16
|
export const Rating = ({ settings, onSubmit, className }: RatingProps): JSX.Element => {
|
|
14
|
-
const {
|
|
15
|
-
label,
|
|
16
|
-
max,
|
|
17
|
-
submitText,
|
|
18
|
-
comment: commentSettings,
|
|
19
|
-
reasons: reasonsSettings,
|
|
20
|
-
} = settings || {};
|
|
17
|
+
const { label, submitText, comment: commentSettings, reasons: reasonsSettings } = settings || {};
|
|
21
18
|
const [isSubmitted, setIsSubmitted] = React.useState(false);
|
|
22
19
|
const [score, setScore] = React.useState(0);
|
|
23
|
-
const [comment, setComment] = React.useState('');
|
|
24
20
|
const [reasons, setReasons] = React.useState([] as ReasonsProps['settings']['items']);
|
|
21
|
+
const [comment, setComment] = React.useState('');
|
|
25
22
|
const { translate } = useTranslate();
|
|
26
|
-
const maxRating = max || 5;
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
24
|
+
const onSubmitRatingForm = () => {
|
|
25
|
+
onSubmit({
|
|
26
|
+
score,
|
|
27
|
+
comment,
|
|
28
|
+
reasons,
|
|
29
|
+
max: FEEDBACK_MAX_RATING,
|
|
30
|
+
});
|
|
31
|
+
setIsSubmitted(true);
|
|
32
|
+
};
|
|
38
33
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
onSubmit={({ comment }) => setComment(comment)}
|
|
43
|
-
settings={{ label: commentSettings.label }}
|
|
44
|
-
/>
|
|
45
|
-
);
|
|
46
|
-
}
|
|
34
|
+
const displayReasons = !!score && reasonsSettings?.enable;
|
|
35
|
+
const displayComment = !!score && commentSettings?.enable;
|
|
36
|
+
const displaySubmitBnt = !!score && (displayReasons || displayComment);
|
|
47
37
|
|
|
48
|
-
|
|
49
|
-
if (!
|
|
50
|
-
|
|
51
|
-
score,
|
|
52
|
-
comment,
|
|
53
|
-
reasons,
|
|
54
|
-
max: maxRating,
|
|
55
|
-
});
|
|
56
|
-
setIsSubmitted(true);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (score && !displayComment && !displayReasons) {
|
|
40
|
+
onSubmitRatingForm();
|
|
57
41
|
}
|
|
42
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
43
|
+
}, [score, displayComment, displayReasons]);
|
|
58
44
|
|
|
45
|
+
if (isSubmitted) {
|
|
59
46
|
return (
|
|
60
47
|
<Wrapper>
|
|
61
48
|
<Label data-translation-key="theme.feedback.settings.submitText">
|
|
@@ -64,64 +51,104 @@ export const Rating = ({ settings, onSubmit, className }: RatingProps): JSX.Elem
|
|
|
64
51
|
submitText || 'Thank you for helping improve our documentation!',
|
|
65
52
|
)}
|
|
66
53
|
</Label>
|
|
54
|
+
<RadioCheckButtonIcon />
|
|
67
55
|
</Wrapper>
|
|
68
56
|
);
|
|
69
57
|
}
|
|
70
58
|
|
|
71
59
|
return (
|
|
72
60
|
<Wrapper data-component-name="Feedback/Rating" className={className}>
|
|
73
|
-
<
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
61
|
+
<StyledForm>
|
|
62
|
+
<StyledFormMandatoryFields>
|
|
63
|
+
<Label data-translation-key="theme.feedback.settings.label">
|
|
64
|
+
{translate('theme.feedback.settings.label', label || 'How helpful was this page?')}
|
|
65
|
+
</Label>
|
|
66
|
+
|
|
67
|
+
<StyledMandatoryFieldContainer>
|
|
68
|
+
<Stars max={FEEDBACK_MAX_RATING} onChange={setScore} value={score} />
|
|
69
|
+
</StyledMandatoryFieldContainer>
|
|
70
|
+
</StyledFormMandatoryFields>
|
|
71
|
+
|
|
72
|
+
<StyledFormOptionalFields>
|
|
73
|
+
{displayReasons && (
|
|
74
|
+
<Reasons
|
|
75
|
+
settings={{
|
|
76
|
+
label: reasonsSettings?.label,
|
|
77
|
+
items: reasonsSettings?.items || [],
|
|
78
|
+
multi: reasonsSettings?.multi,
|
|
79
|
+
}}
|
|
80
|
+
onChange={setReasons}
|
|
81
|
+
/>
|
|
82
|
+
)}
|
|
83
|
+
|
|
84
|
+
{displayComment && (
|
|
85
|
+
<Comment
|
|
86
|
+
standAlone={false}
|
|
87
|
+
onSubmit={({ comment }) => setComment(comment)}
|
|
88
|
+
settings={{ label: commentSettings.label }}
|
|
89
|
+
/>
|
|
90
|
+
)}
|
|
91
|
+
</StyledFormOptionalFields>
|
|
92
|
+
{displaySubmitBnt && (
|
|
93
|
+
<ButtonsContainer>
|
|
94
|
+
<SubmitButton onClick={onSubmitRatingForm}>Submit</SubmitButton>
|
|
95
|
+
</ButtonsContainer>
|
|
96
|
+
)}
|
|
97
|
+
</StyledForm>
|
|
77
98
|
</Wrapper>
|
|
78
99
|
);
|
|
79
100
|
};
|
|
80
101
|
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
for (let index = 1; index <= max; index++) {
|
|
86
|
-
stars.push(
|
|
87
|
-
<Star
|
|
88
|
-
key={index}
|
|
89
|
-
onClick={() => onSubmit(index)}
|
|
90
|
-
onMouseOver={() => setHovered(index)}
|
|
91
|
-
onMouseLeave={() => setHovered(0)}
|
|
92
|
-
>
|
|
93
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
|
|
94
|
-
{hovered < index ? (
|
|
95
|
-
<g fill="#e8c002">
|
|
96
|
-
<path d="M20 7h-7L10 .5 7 7H0l5.46 5.47-1.64 7 6.18-3.7 6.18 3.73-1.63-7zm-10 6.9-3.76 2.27 1-4.28L3.5 8.5h4.61L10 4.6l1.9 3.9h4.6l-3.73 3.4 1 4.28z" />
|
|
97
|
-
</g>
|
|
98
|
-
) : (
|
|
99
|
-
<g fill="#e8c002">
|
|
100
|
-
<path d="M20 7h-7L10 .5 7 7H0l5.46 5.47-1.64 7 6.18-3.7 6.18 3.73-1.63-7z" />
|
|
101
|
-
</g>
|
|
102
|
-
)}
|
|
103
|
-
</svg>
|
|
104
|
-
</Star>,
|
|
105
|
-
);
|
|
106
|
-
}
|
|
102
|
+
const StyledForm = styled.form`
|
|
103
|
+
width: 100%;
|
|
104
|
+
`;
|
|
107
105
|
|
|
108
|
-
|
|
109
|
-
|
|
106
|
+
const StyledFormOptionalFields = styled.div`
|
|
107
|
+
display: flex;
|
|
108
|
+
flex-flow: column;
|
|
109
|
+
`;
|
|
110
|
+
|
|
111
|
+
const StyledFormMandatoryFields = styled.div`
|
|
112
|
+
display: flex;
|
|
113
|
+
justify-content: space-between;
|
|
114
|
+
`;
|
|
115
|
+
|
|
116
|
+
const StyledMandatoryFieldContainer = styled.div`
|
|
117
|
+
display: flex;
|
|
118
|
+
`;
|
|
110
119
|
|
|
111
120
|
const Wrapper = styled.div`
|
|
112
121
|
display: flex;
|
|
122
|
+
justify-content: space-between;
|
|
113
123
|
align-items: center;
|
|
114
|
-
|
|
124
|
+
padding: 16px 24px;
|
|
125
|
+
width: 424px;
|
|
126
|
+
border-radius: 8px;
|
|
127
|
+
background: var(--bg-raised);
|
|
115
128
|
|
|
116
|
-
|
|
117
|
-
|
|
129
|
+
@media screen and (max-width: ${breakpoints.small}) {
|
|
130
|
+
width: 100%;
|
|
131
|
+
}
|
|
118
132
|
`;
|
|
119
133
|
|
|
120
134
|
const Label = styled.h3`
|
|
121
135
|
margin-right: 15px;
|
|
122
|
-
font-family: var(--
|
|
123
|
-
font-weight: var(--
|
|
124
|
-
font-size: var(--
|
|
125
|
-
line-height: var(--
|
|
136
|
+
font-family: var(--h4-font-family);
|
|
137
|
+
font-weight: var(--h4-font-weight);
|
|
138
|
+
font-size: var(--h4-font-size);
|
|
139
|
+
line-height: var(--h4-line-height);
|
|
126
140
|
color: var(--h3-text-color);
|
|
127
141
|
`;
|
|
142
|
+
|
|
143
|
+
const SubmitButton = styled(Button).attrs(() => ({
|
|
144
|
+
color: 'primary',
|
|
145
|
+
}))`
|
|
146
|
+
width: 100px;
|
|
147
|
+
margin-left: 0;
|
|
148
|
+
margin-right: 0;
|
|
149
|
+
`;
|
|
150
|
+
|
|
151
|
+
const ButtonsContainer = styled.div`
|
|
152
|
+
display: flex;
|
|
153
|
+
justify-content: end;
|
|
154
|
+
`;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
|
|
4
|
-
import { Button } from '@theme/components/Button/Button';
|
|
5
4
|
import type { ReasonsProps } from '@theme/components/Feedback';
|
|
6
5
|
import { useTranslate } from '@portal/hooks';
|
|
7
6
|
|
|
8
|
-
export const Reasons = ({ settings,
|
|
9
|
-
const { label, multi,
|
|
7
|
+
export const Reasons = ({ settings, onChange, className }: ReasonsProps): JSX.Element => {
|
|
8
|
+
const { label, multi, items = [] } = settings;
|
|
10
9
|
const [checkedState, setCheckedState] = React.useState(new Array(items.length).fill(false));
|
|
11
10
|
const { translate } = useTranslate();
|
|
12
11
|
|
|
@@ -20,12 +19,9 @@ export const Reasons = ({ settings, onSubmit, className }: ReasonsProps): JSX.El
|
|
|
20
19
|
const updatedCheckedState = multi
|
|
21
20
|
? checkedState.map((item, index) => (index === position ? !item : item))
|
|
22
21
|
: items.map((_, idx) => position === idx);
|
|
23
|
-
|
|
24
22
|
setCheckedState(updatedCheckedState);
|
|
25
|
-
};
|
|
26
23
|
|
|
27
|
-
|
|
28
|
-
onSubmit({ reasons: items.filter((_, index) => !!checkedState[index]) });
|
|
24
|
+
onChange(items.filter((_, index) => !!updatedCheckedState[index]));
|
|
29
25
|
};
|
|
30
26
|
|
|
31
27
|
return (
|
|
@@ -58,9 +54,6 @@ export const Reasons = ({ settings, onSubmit, className }: ReasonsProps): JSX.El
|
|
|
58
54
|
</label>
|
|
59
55
|
</OptionWrapper>
|
|
60
56
|
))}
|
|
61
|
-
<SendButton data-translation-key="theme.feedback.settings.reasons.send" onClick={submitForm}>
|
|
62
|
-
{translate('theme.feedback.settings.reasons.send', buttonText || 'Send')}
|
|
63
|
-
</SendButton>
|
|
64
57
|
</Wrapper>
|
|
65
58
|
);
|
|
66
59
|
};
|
|
@@ -80,15 +73,6 @@ const Label = styled.h3`
|
|
|
80
73
|
margin-right: 15px;
|
|
81
74
|
`;
|
|
82
75
|
|
|
83
|
-
const SendButton = styled(Button).attrs(() => ({
|
|
84
|
-
color: 'primary',
|
|
85
|
-
}))`
|
|
86
|
-
width: 100px;
|
|
87
|
-
margin-left: 0;
|
|
88
|
-
margin-right: 0;
|
|
89
|
-
margin-top: 15px;
|
|
90
|
-
`;
|
|
91
|
-
|
|
92
76
|
const OptionWrapper = styled.div`
|
|
93
77
|
margin: 5px 0;
|
|
94
78
|
display: flex;
|