@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
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
|
|
5
|
+
import type { ScaleProps, ReasonsProps } from '@theme/components/';
|
|
6
|
+
import { useTranslate } from '@portal/hooks';
|
|
7
|
+
import { breakpoints } from '@portal/media-css';
|
|
8
|
+
import { Comment, Reasons } from '@theme/components/Feedback';
|
|
9
|
+
import { RadioCheckButtonIcon } from '@theme/icons/RadioCheckButtonIcon';
|
|
10
|
+
import { Button } from '@theme/components';
|
|
11
|
+
|
|
12
|
+
export const MAX_SCALE = 10;
|
|
13
|
+
|
|
14
|
+
export const Scale = ({ settings, onSubmit, className }: ScaleProps): JSX.Element => {
|
|
15
|
+
const {
|
|
16
|
+
label,
|
|
17
|
+
submitText,
|
|
18
|
+
leftScaleLabel,
|
|
19
|
+
rightScaleLabel,
|
|
20
|
+
comment: commentSettings,
|
|
21
|
+
reasons: reasonsSettings,
|
|
22
|
+
} = settings || {};
|
|
23
|
+
const [score, setScore] = React.useState(0);
|
|
24
|
+
const [isSubmitted, setIsSubmitted] = React.useState(false);
|
|
25
|
+
const [comment, setComment] = React.useState('');
|
|
26
|
+
const [reasons, setReasons] = React.useState([] as ReasonsProps['settings']['items']);
|
|
27
|
+
const { translate } = useTranslate();
|
|
28
|
+
|
|
29
|
+
const scaleOptions = [];
|
|
30
|
+
|
|
31
|
+
for (let i = 1; i <= MAX_SCALE; i++) {
|
|
32
|
+
scaleOptions.push(
|
|
33
|
+
<ScaleOption
|
|
34
|
+
id={`scale-option-${i}`}
|
|
35
|
+
key={`scale-option-${i}`}
|
|
36
|
+
onClick={() => setScore(i)}
|
|
37
|
+
className={`${score === i ? 'active' : ''}`}
|
|
38
|
+
>
|
|
39
|
+
{i}
|
|
40
|
+
</ScaleOption>,
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const displayReasons = !!score && reasonsSettings?.enable;
|
|
45
|
+
const displayComment = !!score && commentSettings?.enable;
|
|
46
|
+
const displaySubmitBnt = !!score && (displayReasons || displayComment);
|
|
47
|
+
|
|
48
|
+
const onSubmitScaleForm = () => {
|
|
49
|
+
onSubmit({
|
|
50
|
+
score,
|
|
51
|
+
comment,
|
|
52
|
+
reasons,
|
|
53
|
+
max: MAX_SCALE,
|
|
54
|
+
});
|
|
55
|
+
setIsSubmitted(true);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (score && !displayComment && !displayReasons) {
|
|
60
|
+
onSubmitScaleForm();
|
|
61
|
+
}
|
|
62
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
63
|
+
}, [score, displayComment, displayReasons]);
|
|
64
|
+
|
|
65
|
+
if (isSubmitted) {
|
|
66
|
+
return (
|
|
67
|
+
<Wrapper>
|
|
68
|
+
<Label data-translation-key="theme.feedback.settings.submitText">
|
|
69
|
+
{translate(
|
|
70
|
+
'theme.feedback.settings.submitText',
|
|
71
|
+
submitText || 'Thank you for helping improve our documentation!',
|
|
72
|
+
)}
|
|
73
|
+
</Label>
|
|
74
|
+
<RadioCheckButtonIcon />
|
|
75
|
+
</Wrapper>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<Wrapper data-component-name="Feedback/Scale" className={className}>
|
|
81
|
+
<StyledForm>
|
|
82
|
+
<StyledFormMandatoryFields>
|
|
83
|
+
<Label data-translation-key="theme.feedback.settings.label">
|
|
84
|
+
{translate('theme.feedback.settings.label', label || 'How helpful was this page?')}
|
|
85
|
+
</Label>
|
|
86
|
+
|
|
87
|
+
<ScaleWrapper>{scaleOptions}</ScaleWrapper>
|
|
88
|
+
|
|
89
|
+
<SubLabelContainer>
|
|
90
|
+
<SubLabel data-translation-key="theme.feedback.settings.leftScaleLabel">
|
|
91
|
+
{translate(
|
|
92
|
+
'theme.feedback.settings.leftScaleLabel',
|
|
93
|
+
leftScaleLabel || 'Not helpful at all',
|
|
94
|
+
)}
|
|
95
|
+
</SubLabel>
|
|
96
|
+
<SubLabel data-translation-key="theme.feedback.settings.rightScaleLabel">
|
|
97
|
+
{translate(
|
|
98
|
+
'theme.feedback.settings.rightScaleLabel',
|
|
99
|
+
rightScaleLabel || 'Extremely helpful',
|
|
100
|
+
)}
|
|
101
|
+
</SubLabel>
|
|
102
|
+
</SubLabelContainer>
|
|
103
|
+
</StyledFormMandatoryFields>
|
|
104
|
+
<StyledFormOptionalFields>
|
|
105
|
+
{displayReasons && (
|
|
106
|
+
<Reasons
|
|
107
|
+
settings={{
|
|
108
|
+
label: reasonsSettings?.label,
|
|
109
|
+
items: reasonsSettings?.items || [],
|
|
110
|
+
multi: reasonsSettings?.multi,
|
|
111
|
+
}}
|
|
112
|
+
onChange={setReasons}
|
|
113
|
+
/>
|
|
114
|
+
)}
|
|
115
|
+
|
|
116
|
+
{displayComment && (
|
|
117
|
+
<Comment
|
|
118
|
+
standAlone={false}
|
|
119
|
+
onSubmit={({ comment }) => setComment(comment)}
|
|
120
|
+
settings={{ label: commentSettings.label }}
|
|
121
|
+
/>
|
|
122
|
+
)}
|
|
123
|
+
</StyledFormOptionalFields>
|
|
124
|
+
{displaySubmitBnt && (
|
|
125
|
+
<ButtonsContainer>
|
|
126
|
+
<SubmitButton onClick={onSubmitScaleForm}>Submit</SubmitButton>
|
|
127
|
+
</ButtonsContainer>
|
|
128
|
+
)}
|
|
129
|
+
</StyledForm>
|
|
130
|
+
</Wrapper>
|
|
131
|
+
);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const Wrapper = styled.div`
|
|
135
|
+
font-family: var(--font-family-base);
|
|
136
|
+
display: flex;
|
|
137
|
+
justify-content: space-between;
|
|
138
|
+
align-items: center;
|
|
139
|
+
padding: 16px 24px;
|
|
140
|
+
width: 502px;
|
|
141
|
+
border-radius: 8px;
|
|
142
|
+
background: var(--bg-raised);
|
|
143
|
+
|
|
144
|
+
@media screen and (max-width: ${breakpoints.small}) {
|
|
145
|
+
width: 100%;
|
|
146
|
+
}
|
|
147
|
+
`;
|
|
148
|
+
|
|
149
|
+
const Label = styled.h3`
|
|
150
|
+
margin-right: 15px;
|
|
151
|
+
font-family: var(--h4-font-family);
|
|
152
|
+
font-weight: var(--h4-font-weight);
|
|
153
|
+
font-size: var(--h4-font-size);
|
|
154
|
+
line-height: var(--h4-line-height);
|
|
155
|
+
color: var(--h3-text-color);
|
|
156
|
+
`;
|
|
157
|
+
|
|
158
|
+
const SubLabelContainer = styled.div`
|
|
159
|
+
display: flex;
|
|
160
|
+
justify-content: space-between;
|
|
161
|
+
width: 100%;
|
|
162
|
+
flex-direction: row;
|
|
163
|
+
`;
|
|
164
|
+
|
|
165
|
+
const SubLabel = styled.h3`
|
|
166
|
+
font-family: var(--h4-font-family);
|
|
167
|
+
font-weight: var(--h4-font-weight);
|
|
168
|
+
font-size: var(--h4-font-size);
|
|
169
|
+
line-height: var(--h4-line-height);
|
|
170
|
+
color: var(--text-description);
|
|
171
|
+
`;
|
|
172
|
+
|
|
173
|
+
const StyledForm = styled.form`
|
|
174
|
+
width: 100%;
|
|
175
|
+
`;
|
|
176
|
+
|
|
177
|
+
const SubmitButton = styled(Button).attrs(() => ({
|
|
178
|
+
color: 'primary',
|
|
179
|
+
}))`
|
|
180
|
+
width: 100px;
|
|
181
|
+
margin-left: 0;
|
|
182
|
+
margin-right: 0;
|
|
183
|
+
`;
|
|
184
|
+
|
|
185
|
+
const ButtonsContainer = styled.div`
|
|
186
|
+
display: flex;
|
|
187
|
+
justify-content: end;
|
|
188
|
+
`;
|
|
189
|
+
|
|
190
|
+
const StyledFormOptionalFields = styled.div`
|
|
191
|
+
display: flex;
|
|
192
|
+
flex-flow: column;
|
|
193
|
+
`;
|
|
194
|
+
|
|
195
|
+
const StyledFormMandatoryFields = styled.div`
|
|
196
|
+
display: flex;
|
|
197
|
+
flex-direction: column;
|
|
198
|
+
align-items: center;
|
|
199
|
+
`;
|
|
200
|
+
|
|
201
|
+
const ScaleOption = styled.div`
|
|
202
|
+
cursor: pointer;
|
|
203
|
+
border-radius: 6px;
|
|
204
|
+
background: var(--bg-overlay);
|
|
205
|
+
display: flex;
|
|
206
|
+
padding: 8px 16px;
|
|
207
|
+
flex-direction: column;
|
|
208
|
+
justify-content: center;
|
|
209
|
+
align-items: center;
|
|
210
|
+
&.active {
|
|
211
|
+
border: 1px solid var(--text-primary);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
@media screen and (max-width: ${breakpoints.small}) {
|
|
215
|
+
padding: 4px 8px;
|
|
216
|
+
}
|
|
217
|
+
`;
|
|
218
|
+
|
|
219
|
+
const ScaleWrapper = styled.div`
|
|
220
|
+
display: flex;
|
|
221
|
+
justify-content: space-between;
|
|
222
|
+
flex-direction: row;
|
|
223
|
+
gap: 4px;
|
|
224
|
+
width: 100%;
|
|
225
|
+
|
|
226
|
+
@media screen and (max-width: ${breakpoints.small}) {
|
|
227
|
+
gap: 1px;
|
|
228
|
+
}
|
|
229
|
+
`;
|
|
@@ -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 { SentimentProps, ReasonsProps } from '@theme/components/Feedback';
|
|
5
6
|
import { Comment, Reasons } from '@theme/components/Feedback';
|
|
6
7
|
import { ThumbUp, ThumbDown } from '@theme/components/Feedback/Thumbs';
|
|
7
8
|
import { useTranslate } from '@portal/hooks';
|
|
9
|
+
import { Button } from '@theme/components';
|
|
10
|
+
import { RadioCheckButtonIcon } from '@theme/icons/RadioCheckButtonIcon';
|
|
11
|
+
import { breakpoints } from '@portal/media-css';
|
|
8
12
|
|
|
9
13
|
export const Sentiment = ({ settings, onSubmit, className }: SentimentProps): JSX.Element => {
|
|
10
14
|
const { label, submitText, comment: commentSettings, reasons: reasonsSettings } = settings || {};
|
|
@@ -14,42 +18,38 @@ export const Sentiment = ({ settings, onSubmit, className }: SentimentProps): JS
|
|
|
14
18
|
const [reasons, setReasons] = React.useState([] as ReasonsProps['settings']['items']);
|
|
15
19
|
const { translate } = useTranslate();
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<Reasons
|
|
22
|
-
onSubmit={({ reasons }) => setReasons(reasons)}
|
|
23
|
-
settings={{ label: reasonsLabel, items, multi, buttonText }}
|
|
24
|
-
/>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
21
|
+
const displayReasons = !!score && reasonsSettings?.enable;
|
|
22
|
+
const displayComment = !!score && commentSettings?.enable;
|
|
23
|
+
const displaySubmitBnt = !!score && (displayReasons || displayComment);
|
|
27
24
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
25
|
+
const commentLabel =
|
|
26
|
+
score === 1
|
|
27
|
+
? translate(
|
|
28
|
+
'theme.feedback.settings.comment.likeLabel',
|
|
29
|
+
(commentSettings && commentSettings.likeLabel) || 'What was most helpful?',
|
|
30
|
+
)
|
|
31
|
+
: translate(
|
|
32
|
+
'theme.feedback.settings.comment.dislikeLabel',
|
|
33
|
+
(commentSettings && commentSettings.dislikeLabel) || 'What can we improve?',
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const onSubmitSentimentForm = () => {
|
|
37
|
+
onSubmit({
|
|
38
|
+
score,
|
|
39
|
+
comment,
|
|
40
|
+
reasons,
|
|
41
|
+
});
|
|
42
|
+
setIsSubmitted(true);
|
|
43
|
+
};
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
if (!
|
|
46
|
-
|
|
47
|
-
score,
|
|
48
|
-
comment,
|
|
49
|
-
reasons,
|
|
50
|
-
});
|
|
51
|
-
setIsSubmitted(true);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (score && !displayComment && !displayReasons) {
|
|
47
|
+
onSubmitSentimentForm();
|
|
52
48
|
}
|
|
49
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
50
|
+
}, [score, displayComment, displayReasons]);
|
|
51
|
+
|
|
52
|
+
if (isSubmitted) {
|
|
53
53
|
return (
|
|
54
54
|
<Wrapper>
|
|
55
55
|
<Label data-translation-key="theme.feedback.settings.submitText">
|
|
@@ -58,29 +58,66 @@ export const Sentiment = ({ settings, onSubmit, className }: SentimentProps): JS
|
|
|
58
58
|
submitText || 'Thank you for helping improve our documentation!',
|
|
59
59
|
)}
|
|
60
60
|
</Label>
|
|
61
|
+
<RadioCheckButtonIcon />
|
|
61
62
|
</Wrapper>
|
|
62
63
|
);
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
return (
|
|
66
67
|
<Wrapper data-component-name="Feedback/Sentiment" className={className}>
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
68
|
+
<StyledForm>
|
|
69
|
+
<StyledFormMandatoryFields>
|
|
70
|
+
<Label data-translation-key="theme.feedback.settings.label">
|
|
71
|
+
{translate('theme.feedback.settings.label', label || 'Was this page helpful?')}
|
|
72
|
+
</Label>
|
|
73
|
+
|
|
74
|
+
<StyledMandatoryFieldContainer>
|
|
75
|
+
<>
|
|
76
|
+
<Vote
|
|
77
|
+
className={`${score === 1 ? 'active' : ''}`}
|
|
78
|
+
onClick={() => {
|
|
79
|
+
setScore(1);
|
|
80
|
+
}}
|
|
81
|
+
>
|
|
82
|
+
<ThumbUp />
|
|
83
|
+
</Vote>
|
|
84
|
+
<Vote
|
|
85
|
+
className={`${score === -1 ? 'active' : ''}`}
|
|
86
|
+
onClick={() => {
|
|
87
|
+
setScore(-1);
|
|
88
|
+
}}
|
|
89
|
+
>
|
|
90
|
+
<ThumbDown />
|
|
91
|
+
</Vote>
|
|
92
|
+
</>
|
|
93
|
+
</StyledMandatoryFieldContainer>
|
|
94
|
+
</StyledFormMandatoryFields>
|
|
95
|
+
<StyledFormOptionalFields>
|
|
96
|
+
{displayReasons && (
|
|
97
|
+
<Reasons
|
|
98
|
+
settings={{
|
|
99
|
+
label: reasonsSettings?.label,
|
|
100
|
+
items: reasonsSettings?.items || [],
|
|
101
|
+
multi: reasonsSettings?.multi,
|
|
102
|
+
}}
|
|
103
|
+
onChange={setReasons}
|
|
104
|
+
/>
|
|
105
|
+
)}
|
|
106
|
+
|
|
107
|
+
{displayComment && (
|
|
108
|
+
<Comment
|
|
109
|
+
standAlone={false}
|
|
110
|
+
onSubmit={({ comment }) => setComment(comment)}
|
|
111
|
+
settings={{ label: commentLabel }}
|
|
112
|
+
/>
|
|
113
|
+
)}
|
|
114
|
+
</StyledFormOptionalFields>
|
|
115
|
+
{displaySubmitBnt && (
|
|
116
|
+
<ButtonsContainer>
|
|
117
|
+
<SubmitButton onClick={onSubmitSentimentForm}>Submit</SubmitButton>
|
|
118
|
+
</ButtonsContainer>
|
|
119
|
+
)}
|
|
120
|
+
</StyledForm>
|
|
84
121
|
</Wrapper>
|
|
85
122
|
);
|
|
86
123
|
};
|
|
@@ -88,19 +125,76 @@ export const Sentiment = ({ settings, onSubmit, className }: SentimentProps): JS
|
|
|
88
125
|
const Wrapper = styled.div`
|
|
89
126
|
font-family: var(--font-family-base);
|
|
90
127
|
display: flex;
|
|
128
|
+
justify-content: space-between;
|
|
91
129
|
align-items: center;
|
|
130
|
+
padding: 16px 24px;
|
|
131
|
+
width: 424px;
|
|
132
|
+
border-radius: 8px;
|
|
133
|
+
background: var(--bg-raised);
|
|
134
|
+
|
|
135
|
+
@media screen and (max-width: ${breakpoints.small}) {
|
|
136
|
+
width: 100%;
|
|
137
|
+
}
|
|
92
138
|
`;
|
|
93
139
|
|
|
94
140
|
const Label = styled.h3`
|
|
95
|
-
font-family: var(--h3-font-family);
|
|
96
|
-
font-weight: var(--h3-font-weight);
|
|
97
|
-
font-size: var(--h3-font-size);
|
|
98
|
-
line-height: var(--h3-line-height);
|
|
99
|
-
color: var(--h3-text-color);
|
|
100
141
|
margin-right: 15px;
|
|
142
|
+
font-family: var(--h4-font-family);
|
|
143
|
+
font-weight: var(--h4-font-weight);
|
|
144
|
+
font-size: var(--h4-font-size);
|
|
145
|
+
line-height: var(--h4-line-height);
|
|
146
|
+
color: var(--h3-text-color);
|
|
101
147
|
`;
|
|
102
148
|
|
|
103
149
|
const Vote = styled.div`
|
|
150
|
+
height: 32px;
|
|
151
|
+
width: 32px;
|
|
104
152
|
cursor: pointer;
|
|
105
|
-
|
|
153
|
+
display: flex;
|
|
154
|
+
align-items: center;
|
|
155
|
+
flex-flow: row-reverse;
|
|
156
|
+
color: var(--text-description);
|
|
157
|
+
&.active {
|
|
158
|
+
color: var(--text-primary);
|
|
159
|
+
}
|
|
160
|
+
&:hover {
|
|
161
|
+
color: var(--text-primary);
|
|
162
|
+
svg {
|
|
163
|
+
> g {
|
|
164
|
+
fill: var(--text-primary);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
`;
|
|
169
|
+
|
|
170
|
+
const StyledForm = styled.form`
|
|
171
|
+
width: 100%;
|
|
172
|
+
`;
|
|
173
|
+
|
|
174
|
+
const StyledFormOptionalFields = styled.div`
|
|
175
|
+
display: flex;
|
|
176
|
+
flex-flow: column;
|
|
177
|
+
`;
|
|
178
|
+
|
|
179
|
+
const StyledFormMandatoryFields = styled.div`
|
|
180
|
+
display: flex;
|
|
181
|
+
justify-content: space-between;
|
|
182
|
+
`;
|
|
183
|
+
|
|
184
|
+
const StyledMandatoryFieldContainer = styled.div`
|
|
185
|
+
display: flex;
|
|
186
|
+
align-items: center;
|
|
187
|
+
`;
|
|
188
|
+
|
|
189
|
+
const SubmitButton = styled(Button).attrs(() => ({
|
|
190
|
+
color: 'primary',
|
|
191
|
+
}))`
|
|
192
|
+
width: 100px;
|
|
193
|
+
margin-left: 0;
|
|
194
|
+
margin-right: 0;
|
|
195
|
+
`;
|
|
196
|
+
|
|
197
|
+
const ButtonsContainer = styled.div`
|
|
198
|
+
display: flex;
|
|
199
|
+
justify-content: end;
|
|
106
200
|
`;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
export type StarsProps = {
|
|
5
|
+
max?: number;
|
|
6
|
+
name?: string;
|
|
7
|
+
value?: number;
|
|
8
|
+
onChange: (value: number) => void;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const Stars = ({ max = 5, onChange, value }: StarsProps): JSX.Element => {
|
|
12
|
+
const [hovered, setHovered] = React.useState(value || 0);
|
|
13
|
+
const stars: JSX.Element[] = [];
|
|
14
|
+
|
|
15
|
+
for (let index = 1; index <= max; index++) {
|
|
16
|
+
stars.push(
|
|
17
|
+
<Star
|
|
18
|
+
key={index}
|
|
19
|
+
onClick={() => onChange(index)}
|
|
20
|
+
onMouseOver={() => setHovered(index)}
|
|
21
|
+
onMouseLeave={() => !value && setHovered(0)}
|
|
22
|
+
>
|
|
23
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
|
|
24
|
+
{hovered < index ? (
|
|
25
|
+
<g fill="#e8c002">
|
|
26
|
+
<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" />
|
|
27
|
+
</g>
|
|
28
|
+
) : (
|
|
29
|
+
<g fill="#e8c002">
|
|
30
|
+
<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" />
|
|
31
|
+
</g>
|
|
32
|
+
)}
|
|
33
|
+
</svg>
|
|
34
|
+
</Star>,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return <StarsWrapper>{stars}</StarsWrapper>;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const StarsWrapper = styled.div`
|
|
42
|
+
display: flex;
|
|
43
|
+
gap: 8px;
|
|
44
|
+
flex-direction: row;
|
|
45
|
+
align-items: center;
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
const Star = styled.span`
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
gap: 8px;
|
|
51
|
+
`;
|
|
@@ -1,99 +1,21 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { ThumbDownIcon } from '@theme/icons/ThumbDownIcon';
|
|
5
|
+
import { ThumbUpIcon } from '@theme/icons/ThumbUpIcon';
|
|
5
6
|
|
|
6
|
-
export const ThumbUp = (
|
|
7
|
-
const { translate } = useTranslate();
|
|
7
|
+
export const ThumbUp = () => {
|
|
8
8
|
return (
|
|
9
|
-
<Wrapper
|
|
10
|
-
<
|
|
11
|
-
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 512 512">
|
|
12
|
-
<g>
|
|
13
|
-
<g>
|
|
14
|
-
<g>
|
|
15
|
-
<path
|
|
16
|
-
d="M495.736,290.773C509.397,282.317,512,269.397,512,260.796c0-22.4-18.253-47.462-42.667-47.462H349.918
|
|
17
|
-
c-4.284-0.051-25.651-1.51-25.651-25.6c0-4.71-3.814-8.533-8.533-8.533s-8.533,3.823-8.533,8.533
|
|
18
|
-
c0,33.749,27.913,42.667,42.667,42.667h119.467c14.182,0,25.6,16.631,25.6,30.396c0,4.437,0,17.946-26.53,20.855
|
|
19
|
-
c-4.506,0.495-7.834,4.42-7.586,8.951c0.239,4.523,3.985,8.064,8.516,8.064c14.114,0,25.6,11.486,25.6,25.6
|
|
20
|
-
s-11.486,25.6-25.6,25.6h-17.067c-4.719,0-8.533,3.823-8.533,8.533s3.814,8.533,8.533,8.533c14.114,0,25.6,11.486,25.6,25.6
|
|
21
|
-
s-11.486,25.6-25.6,25.6h-25.6c-4.719,0-8.533,3.823-8.533,8.533s3.814,8.533,8.533,8.533c8.934,0,17.067,8.132,17.067,17.067
|
|
22
|
-
c0,8.61-8.448,17.067-17.067,17.067h-128c-35.627,0-48.444-7.074-63.292-15.258c-12.553-6.921-26.786-14.763-54.963-18.79
|
|
23
|
-
c-4.668-0.674-8.994,2.577-9.66,7.236c-0.666,4.668,2.569,8.994,7.236,9.66c25.105,3.584,37.325,10.325,49.152,16.845
|
|
24
|
-
c15.497,8.542,31.505,17.374,71.526,17.374h128c17.869,0,34.133-16.273,34.133-34.133c0-6.229-1.775-12.134-4.83-17.229
|
|
25
|
-
c21.794-1.877,38.963-20.224,38.963-42.505c0-10.829-4.062-20.736-10.735-28.271C500.42,358.212,512,342.571,512,324.267
|
|
26
|
-
C512,310.699,505.634,298.59,495.736,290.773z"
|
|
27
|
-
/>
|
|
28
|
-
<path
|
|
29
|
-
d="M76.8,443.733c9.412,0,17.067-7.654,17.067-17.067S86.212,409.6,76.8,409.6c-9.412,0-17.067,7.654-17.067,17.067
|
|
30
|
-
S67.388,443.733,76.8,443.733z"
|
|
31
|
-
/>
|
|
32
|
-
<path
|
|
33
|
-
d="M179.2,247.467c25.353,0,57.429-28.297,74.3-45.167c36.634-36.634,36.634-82.167,36.634-151.1
|
|
34
|
-
c0-5.342,3.191-8.533,8.533-8.533c29.508,0,42.667,13.158,42.667,42.667v102.4c0,4.71,3.814,8.533,8.533,8.533
|
|
35
|
-
s8.533-3.823,8.533-8.533v-102.4c0-39.083-20.659-59.733-59.733-59.733c-14.831,0-25.6,10.769-25.6,25.6
|
|
36
|
-
c0,66.978,0,107.401-31.633,139.034C216.661,215.006,192.811,230.4,179.2,230.4c-4.719,0-8.533,3.823-8.533,8.533
|
|
37
|
-
S174.481,247.467,179.2,247.467z"
|
|
38
|
-
/>
|
|
39
|
-
<path
|
|
40
|
-
d="M145.067,213.333H8.533c-4.719,0-8.533,3.823-8.533,8.533v256c0,4.71,3.814,8.533,8.533,8.533h136.533
|
|
41
|
-
c4.719,0,8.533-3.823,8.533-8.533v-256C153.6,217.156,149.786,213.333,145.067,213.333z M136.533,469.333H17.067V230.4h119.467
|
|
42
|
-
V469.333z"
|
|
43
|
-
/>
|
|
44
|
-
</g>
|
|
45
|
-
</g>
|
|
46
|
-
</g>
|
|
47
|
-
</svg>
|
|
48
|
-
</Icon>
|
|
49
|
-
<span>{translate('theme.feedback.sentiment.thumbUp', text || 'Yes')}</span>
|
|
9
|
+
<Wrapper>
|
|
10
|
+
<ThumbUpIcon />
|
|
50
11
|
</Wrapper>
|
|
51
12
|
);
|
|
52
13
|
};
|
|
53
14
|
|
|
54
|
-
export const ThumbDown = (
|
|
55
|
-
const { translate } = useTranslate();
|
|
15
|
+
export const ThumbDown = () => {
|
|
56
16
|
return (
|
|
57
|
-
<Wrapper
|
|
58
|
-
<
|
|
59
|
-
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 512 512">
|
|
60
|
-
<g>
|
|
61
|
-
<g>
|
|
62
|
-
<g>
|
|
63
|
-
<path
|
|
64
|
-
d="M76.8,247.467c9.412,0,17.067-7.654,17.067-17.067c0-9.412-7.654-17.067-17.067-17.067
|
|
65
|
-
c-9.412,0-17.067,7.654-17.067,17.067C59.733,239.812,67.388,247.467,76.8,247.467z"
|
|
66
|
-
/>
|
|
67
|
-
<path
|
|
68
|
-
d="M495.736,221.227C505.634,213.41,512,201.301,512,187.733c0-18.295-11.58-33.946-27.802-39.996
|
|
69
|
-
c6.673-7.535,10.735-17.434,10.735-28.271c0-22.281-17.169-40.627-38.963-42.505c3.055-5.094,4.83-10.999,4.83-17.229
|
|
70
|
-
c0-17.86-16.265-34.133-34.133-34.133h-128c-40.021,0-56.03,8.832-71.526,17.374c-11.827,6.519-24.047,13.261-49.152,16.845
|
|
71
|
-
c-4.668,0.666-7.902,4.992-7.236,9.66c0.666,4.659,4.949,7.885,9.66,7.236c28.177-4.028,42.411-11.87,54.963-18.79
|
|
72
|
-
c14.848-8.183,27.665-15.258,63.292-15.258h128c8.619,0,17.067,8.456,17.067,17.067c0,8.934-8.132,17.067-17.067,17.067
|
|
73
|
-
c-4.719,0-8.533,3.823-8.533,8.533s3.814,8.533,8.533,8.533h25.6c14.114,0,25.6,11.486,25.6,25.6s-11.486,25.6-25.6,25.6
|
|
74
|
-
c-4.719,0-8.533,3.823-8.533,8.533c0,4.71,3.814,8.533,8.533,8.533h17.067c14.114,0,25.6,11.486,25.6,25.6
|
|
75
|
-
s-11.486,25.6-25.6,25.6c-4.531,0-8.277,3.541-8.516,8.064c-0.247,4.531,3.081,8.457,7.586,8.951
|
|
76
|
-
c26.53,2.91,26.53,16.418,26.53,20.847c0,13.773-11.418,30.404-25.6,30.404H349.867c-14.763,0-42.667,8.917-42.667,42.667
|
|
77
|
-
c0,4.71,3.814,8.533,8.533,8.533s8.533-3.823,8.533-8.533c0-24.09,21.367-25.549,25.6-25.6h119.467
|
|
78
|
-
c24.414,0,42.667-25.054,42.667-47.471C512,242.603,509.397,229.683,495.736,221.227z"
|
|
79
|
-
/>
|
|
80
|
-
<path
|
|
81
|
-
d="M349.867,315.733c-4.719,0-8.533,3.823-8.533,8.533v102.4c0,29.508-13.158,42.667-42.667,42.667
|
|
82
|
-
c-5.342,0-8.533-3.192-8.533-8.533c0-68.932,0-114.466-36.634-151.1c-16.87-16.87-48.947-45.167-74.3-45.167
|
|
83
|
-
c-4.719,0-8.533,3.823-8.533,8.533s3.814,8.533,8.533,8.533c13.611,0,37.461,15.394,62.234,40.166
|
|
84
|
-
c31.633,31.633,31.633,72.055,31.633,139.034c0,14.831,10.769,25.6,25.6,25.6c39.074,0,59.733-20.651,59.733-59.733v-102.4
|
|
85
|
-
C358.4,319.556,354.586,315.733,349.867,315.733z"
|
|
86
|
-
/>
|
|
87
|
-
<path
|
|
88
|
-
d="M145.067,25.6H8.533C3.814,25.6,0,29.423,0,34.133v256c0,4.71,3.814,8.533,8.533,8.533h136.533
|
|
89
|
-
c4.719,0,8.533-3.823,8.533-8.533v-256C153.6,29.423,149.786,25.6,145.067,25.6z M136.533,281.6H17.067V42.667h119.467V281.6z"
|
|
90
|
-
/>
|
|
91
|
-
</g>
|
|
92
|
-
</g>
|
|
93
|
-
</g>
|
|
94
|
-
</svg>
|
|
95
|
-
</Icon>
|
|
96
|
-
<span>{translate('theme.feedback.sentiment.thumbDown', text || 'No')}</span>
|
|
17
|
+
<Wrapper>
|
|
18
|
+
<ThumbDownIcon />
|
|
97
19
|
</Wrapper>
|
|
98
20
|
);
|
|
99
21
|
};
|
|
@@ -101,24 +23,5 @@ export const ThumbDown = ({ text }: { text?: string }) => {
|
|
|
101
23
|
const Wrapper = styled.div`
|
|
102
24
|
font-family: var(--font-family-base);
|
|
103
25
|
display: flex;
|
|
104
|
-
|
|
105
|
-
&:hover {
|
|
106
|
-
color: var(--color-info-text-active);
|
|
107
|
-
svg {
|
|
108
|
-
> g {
|
|
109
|
-
fill: var(--color-info-text-active);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
`;
|
|
114
|
-
|
|
115
|
-
const Icon = styled.div`
|
|
116
|
-
width: 18px;
|
|
117
|
-
height: 18px;
|
|
118
|
-
margin-right: 5px;
|
|
119
|
-
> svg {
|
|
120
|
-
> g {
|
|
121
|
-
fill: var(--color-info-text);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
26
|
+
align-items: center;
|
|
124
27
|
`;
|
|
@@ -2,6 +2,7 @@ export { Feedback } from '@theme/components/Feedback/Feedback';
|
|
|
2
2
|
export { Rating } from '@theme/components/Feedback/Rating';
|
|
3
3
|
export { Sentiment } from '@theme/components/Feedback/Sentiment';
|
|
4
4
|
export { Mood } from '@theme/components/Feedback/Mood';
|
|
5
|
+
export { Scale } from '@theme/components/Feedback/Scale';
|
|
5
6
|
export { Comment } from '@theme/components/Feedback/Comment';
|
|
6
7
|
export { Reasons } from '@theme/components/Feedback/Reasons';
|
|
7
8
|
export { ReportDialog } from '@theme/components/Feedback/ReportDialog';
|