-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSocialInput.jsx
69 lines (65 loc) · 1.76 KB
/
SocialInput.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import React from 'react';
import { socialIcon } from '../../../layout/element/socialIcons';
import { Input } from '../Input';
import { handleIconFocus } from '../../../../utils/handleIconFocus';
import { handleIconSaveFlip } from '../../../../utils/handleIconSaveFlip';
export const SocialInput = ({
divHeight,
inputId,
inputType,
inputAutocomplete,
inputDisplay,
inputBorderRadius,
inputPadding,
inputPlaceholder,
socials,
setSocials,
}) => {
const handleChange = ({ currentTarget: input }) => {
setSocials({
...socials,
[input.name]: { username: input.value },
});
};
return (
<div className={`flex flex-wrap justify-between items-center ${divHeight}`}>
{socialIcon.map((icon, idx) => (
<div key={icon.name} id={icon.name} className="flex">
<button
type="button"
id={idx}
name={icon.name}
className="flex basis-1/6 justify-center items-center"
onClick={handleIconFocus}
>
{icon.component}
</button>
<Input
key={icon.name}
id={idx}
name={icon.name}
type={inputType}
dataValue={inputId}
value={
socials[icon.name]?.username ? socials[icon.name].username : ``
}
autoComplete={inputAutocomplete}
display={inputDisplay}
borderRadius={inputBorderRadius}
padding={inputPadding}
placeholder={inputPlaceholder}
onChange={handleChange}
/>
</div>
))}
<button
id="icon-save-button"
type="button"
className="hidden"
onClick={handleIconSaveFlip}
>
Save
</button>
</div>
);
};