Skip to content

Commit 59951a6

Browse files
Merge pull request #2127 from hpe-dev-incubator/Color_change_feedback_widget
Color change feedback widget
2 parents 6b683c0 + e49b432 commit 59951a6

File tree

2 files changed

+35
-26
lines changed

2 files changed

+35
-26
lines changed

src/components/Feedback/FeedbackBody/FeedbackBody.js

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ const defaultBodyStyles = {
99
fontSize: '14px',
1010
display: 'block !important',
1111
};
12-
1312
const defaultMessageStyles = {
1413
boxSizing: 'border-box',
1514
padding: '10px 10px 10px 10px',
1615
overflow: 'hidden',
1716
// width: '300px',
1817
fontFamily: 'arial',
1918
};
20-
2119
const FeedbackBody = ({
2220
bodyText,
2321
feedbackFromik,
@@ -28,6 +26,13 @@ const FeedbackBody = ({
2826
isSubmissionSuccess,
2927
}) => {
3028
const [emailDis, setEmailDis] = useState(false);
29+
const [ishovered,setIshovered]=useState(null);
30+
const handleMouseEnter=(button)=>{
31+
setIshovered(button);
32+
};
33+
const handleMouseLeave=()=>{
34+
setIshovered(null);
35+
};
3136
const backHandler = () => {
3237
if (emailDis) {
3338
setEmailDis(false);
@@ -48,8 +53,12 @@ const FeedbackBody = ({
4853
</Box>
4954
<Button
5055
alignSelf="center"
51-
secondary
52-
style={{ marginTop: 10, padding: 0, paddingInline: 10 }}
56+
onMouseEnter={()=>handleMouseEnter(1)}
57+
onMouseLeave={handleMouseLeave}
58+
style={{ marginTop: 10, padding: 0, paddingInline: 10,
59+
border: ishovered===1?'3px solid #01A982':'2px solid #01A982',
60+
backgroundColor:'white',
61+
}}
5362
onClick={() => changeQuestion(0)}
5463
>
5564
{() => (
@@ -69,11 +78,14 @@ const FeedbackBody = ({
6978
</Box>
7079
)}
7180
</Button>
72-
7381
<Button
7482
alignSelf="center"
75-
secondary
76-
style={{ marginTop: 10, padding: 0, paddingInline: 10 }}
83+
onMouseEnter={()=>handleMouseEnter(2)}
84+
onMouseLeave={handleMouseLeave}
85+
style={{ marginTop: 10, padding: 0, paddingInline: 10,
86+
border: ishovered===2 ? '3px solid #01A982' : '2px solid #01A982',
87+
backgroundColor:'white',
88+
}}
7789
onClick={() => changeQuestion(1)}
7890
>
7991
{() => (
@@ -95,8 +107,12 @@ const FeedbackBody = ({
95107
</Button>
96108
<Button
97109
alignSelf="center"
98-
secondary
99-
style={{ marginTop: 10, padding: 0, paddingInline: 10 }}
110+
onMouseEnter={()=>handleMouseEnter(3)}
111+
onMouseLeave={handleMouseLeave}
112+
style={{ marginTop: 10, padding: 0, paddingInline: 10,
113+
border: ishovered===3 ? '3px solid #01A982' : '2px solid #01A982',
114+
backgroundColor:'white',
115+
}}
100116
onClick={() => changeQuestion(2)}
101117
>
102118
{() => (
@@ -148,7 +164,6 @@ const FeedbackBody = ({
148164
We value your feedback and we will use it to improve our
149165
websites and services.
150166
</Text>
151-
152167
<Button
153168
label="Close"
154169
style={{ marginTop: 30,backgroundColor:'#01A982' }}
@@ -177,7 +192,6 @@ const FeedbackBody = ({
177192
)}
178193
</Box>
179194
))}
180-
181195
{selQuestion && (
182196
<Box style={{ marginInline: 20, marginTop: 20, marginBottom: 20 }}>
183197
<Box style={{ marginBottom: 20 }} onClick={() => backHandler()}>
@@ -207,7 +221,7 @@ const FeedbackBody = ({
207221
)}
208222
<Button
209223
label="Next"
210-
style={ feedbackFromik.errors.value || feedbackFromik.values.value==='' || feedbackFromik.values.value===' '?
224+
style={ feedbackFromik.errors.value || feedbackFromik.values.value.trim().length===0?
211225
{ marginTop: 20,backgroundColor:'white' }:
212226
{ marginTop: 20,backgroundColor:'#01A982' }}
213227
icon={<FormNextLink />}
@@ -216,8 +230,7 @@ const FeedbackBody = ({
216230
reverse
217231
primary
218232
disabled={
219-
feedbackFromik.values.value === '' ||
220-
feedbackFromik.errors.value || feedbackFromik.values.value===' '}
233+
!!feedbackFromik.errors.value || feedbackFromik.values.value.trim().length===0}
221234
/>
222235
</>
223236
) : (
@@ -232,8 +245,7 @@ const FeedbackBody = ({
232245
value={feedbackFromik.values.email}
233246
style={{ marginTop: 10 }}
234247
placeholder="Enter Your Email"
235-
onChange={(val)=>{feedbackFromik.handleChange(val);
236-
}}
248+
onChange={feedbackFromik.handleChange}
237249
onBlur={feedbackFromik.handleBlur}
238250
/>
239251
{feedbackFromik.errors.email && (
@@ -243,15 +255,15 @@ const FeedbackBody = ({
243255
)}
244256
<Button
245257
label="Send Feedback"
246-
style={ feedbackFromik.errors.email || feedbackFromik.values.email==='' ?
258+
style={ feedbackFromik.errors.email ?
247259
{ marginTop: 20,backgroundColor:'#fffa' }:
248260
{ marginTop: 20,backgroundColor:'#01A982' }}
249261
onClick={() => {
250262
feedbackFromik.submitForm();
251263
}}
252264
alignSelf="end"
253265
primary
254-
disabled={!!feedbackFromik.errors.email || feedbackFromik.values.email===''}
266+
disabled={!!feedbackFromik.errors.email}
255267
/>
256268
</>
257269
)}
@@ -260,7 +272,6 @@ const FeedbackBody = ({
260272
</Box>
261273
);
262274
};
263-
264275
FeedbackBody.defaultProps = {
265276
bodyText:
266277
"Need help? Have feedback? I'm a human so please be nice and I'll fix it!",
@@ -270,5 +281,4 @@ FeedbackBody.defaultProps = {
270281
showNameInput: true,
271282
numberOfStars: 5,
272283
};
273-
274284
export default FeedbackBody;

src/components/Feedback/index.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,16 @@ const Feedback = (props) => {
7373
}, [isSubmissionSuccess]);
7474

7575
const submithandler = (values) => {
76-
if (isEmpty(values.value) || isEmpty(values.email)) {
77-
alert('Fields are missing!');
78-
} else {
79-
handleSubmit({
76+
if (isEmpty(values.value)) {
77+
alert('Please provide the feeback');
78+
}
79+
else{handleSubmit({
8080
message: values.value,
8181
email: values.email,
8282
proxy: 'hackshack',
8383
});
84-
}
84+
};
8585
};
86-
8786
const successClose = () => {
8887
handleClose();
8988
setShowForm(false);

0 commit comments

Comments
 (0)