-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathContact.js
187 lines (174 loc) · 6.24 KB
/
Contact.js
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
import React, { useState } from 'react';
import '../styles/Contact.css';
import { Container, Row, Col, Form, Button } from 'react-bootstrap';
import { ImTwitter, ImMail, ImGithub } from 'react-icons/im';
import { FaGitter } from 'react-icons/fa';
function Contact() {
let formIsValid = false;
const [email, setEmailAttr] = useState({
value: '',
focused: false,
});
const [subject, setSubjectAttr] = useState({
value: '',
focused: false,
});
const [message, setMessageAttr] = useState({
value: '',
focused: false,
});
const setEmailVal = (e) => setEmailAttr((prev) => ({ ...prev, value: e.target.value }));
const setSubjectVal = (e) => setSubjectAttr((prev) => ({ ...prev, value: e.target.value }));
const setMsgVal = (e) => setMessageAttr((prev) => ({ ...prev, value: e.target.value }));
const setEmailFocus = () => setEmailAttr((prev) => ({ ...prev, focused: true }));
const setSubjectFocus = () => setSubjectAttr((prev) => ({ ...prev, focused: true }));
const setMsgFocus = () => setMessageAttr((prev) => ({ ...prev, focused: true }));
const emailIsValid = !!email.value;
const subjectIsValid = !!subject.value;
const messageIsValid = !!message.value;
const emailIsInvalid = email.focused && !emailIsValid;
const subjectIsInvalid = subject.focused && !subjectIsValid;
const messageIsInvalid = message.focused && !messageIsValid;
formIsValid = emailIsValid && subjectIsValid && messageIsValid;
const formSubmitHandler = (e) => {
e.preventDefault();
if (!formIsValid) {
// console.log('INVALID FORM');
return;
}
// console.log('PERFORM NETWORK REQUEST HERE');
setEmailAttr({ value: '', focused: false });
setSubjectAttr({ value: '', focused: false });
setMessageAttr({ value: '', focused: false });
};
return (
<Container>
<h1 className='mt-4'>Contact Us</h1>
<p className='mt-p'>
Ideas? Comments? Critiques? Want to help out? Here’s how to get in contact:
</p>
<Row className='contact-card-one'>
<Col md={6}>
<div className='contact-card' style={{ color: '#E74D3C' }}>
<a
href='mailto:[email protected]'
style={{ textDecoration: 'none', color: 'inherit' }}
>
<ImMail size={150} />
<p style={{ color: '#0D6EFD' }}>[email protected]</p>
</a>
</div>
</Col>
<Col md={6}>
<div className='contact-card' style={{ color: '#4C4C4D' }}>
<a
href='https://github.com/codeisscience'
target='_blank'
rel='noreferrer'
style={{ textDecoration: 'none', color: 'inherit' }}
>
<ImGithub size={150} />
<p style={{ color: '#0D6EFD' }}>GitHub</p>
</a>
</div>
</Col>
</Row>
<Row className='contact-card-two'>
<Col md={6}>
<div className='contact-card' style={{ color: '#3D9DD9' }}>
<a
href='https://twitter.com/codeisscience'
target='_blank'
rel='noreferrer'
style={{ textDecoration: 'none', color: 'inherit' }}
>
<ImTwitter size={150} />
<p style={{ color: '#0D6EFD' }}>@codeisscience</p>
</a>
</div>
</Col>
<Col md={6}>
<div className='contact-card' style={{ color: '#4C4C4D' }}>
<FaGitter size={150} />
<a
href='https://gitter.im/codeisscience/Lobby'
target='_blank'
rel='noreferrer'
style={{ textDecoration: 'none', color: 'inherit' }}
>
<p style={{ color: '#0D6EFD' }}>Gitter</p>
</a>
</div>
</Col>
</Row>
<hr />
<Row>
<Col md={6} className='contact-form'>
<Form onSubmit={formSubmitHandler}>
<Form.Group as={Row} controlId='formHorizontalEmail'>
<Form.Label column sm={2}>
Email
</Form.Label>
<Col sm={10}>
<Form.Control
type='email'
value={email.value}
onChange={setEmailVal}
onBlur={setEmailFocus}
placeholder='[email protected]'
/>
{emailIsInvalid && <p className='invalidInput'>Email cannot be empty.</p>}
</Col>
</Form.Group>
<br />
<Form.Group as={Row} controlId='formHorizontalSubject'>
<Form.Label column sm={2}>
Subject
</Form.Label>
<Col sm={10}>
<Form.Control
type='text'
value={subject.value}
onChange={setSubjectVal}
onBlur={setSubjectFocus}
placeholder='Code is Science'
/>
{subjectIsInvalid && <p className='invalidInput'>Subject cannot be empty.</p>}
</Col>
</Form.Group>
<br />
<Form.Group as={Row} controlId='formHorizontalMessage'>
<Form.Label column sm={2}>
Message
</Form.Label>
<Col sm={10}>
<Form.Control
as='textarea'
value={message.value}
rows={3}
onChange={setMsgVal}
onBlur={setMsgFocus}
placeholder='Enter your message here...'
/>
{messageIsInvalid && <p className='invalidInput'>Message cannot be empty.</p>}
</Col>
</Form.Group>
<Form.Group as={Row} controlId='formHorizontalCheck' className='mt-3'>
<Col sm={{ span: 10, offset: 2 }}>
<Form.Check label='Remember me' />
</Col>
</Form.Group>
<Form.Group as={Row} className='mt-3'>
<Col sm={{ span: 10, offset: 2 }}>
<Button type='submit' disabled={!formIsValid}>
Send
</Button>
</Col>
</Form.Group>
</Form>
</Col>
</Row>
</Container>
);
}
export default Contact;