-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathInput.js
More file actions
66 lines (59 loc) · 1.23 KB
/
Input.js
File metadata and controls
66 lines (59 loc) · 1.23 KB
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
import React, { useState } from "react";
import styled from "styled-components";
const Form = styled.form`
display: flex;
flex-direction: column;
`;
const Field = styled.input`
margin-top: 5px;
width: 30vw;
font-size: 18px;
height: 30px;
padding: 0.5rem;
outline: none;
border: none;
border-radius: 10px;
background: #e1f7fa;
border-bottom: 1px solid #f5feff;
`;
const Button = styled.button`
cursor: pointer;
font-size: 15px;
width: 10vw;
height: 25px;
border-radius: 10px;
background: #e1f7fa;
outline: none;
margin-top: 10px;
`;
function Input(props) {
const [name, setName] = useState("");
const [comment, setComment] = useState("");
return (
<Form
onSubmit={e => {
props.getComment(name, comment);
setName("");
setComment("");
e.preventDefault();
}}
>
<Field
required
placeholder="name"
value={name}
type="text"
onChange={e => setName(e.target.value)}
/>
<Field
placeholder="comment"
required
value={comment}
type="text"
onChange={e => setComment(e.target.value)}
/>
<Button type="submit">Add</Button>
</Form>
);
}
export default Input;