@@ -3,9 +3,9 @@ import { useRef } from 'react';
3
3
import MailchimpSubscribe from 'react-mailchimp-subscribe' ;
4
4
import ReCAPTCHA from 'react-google-recaptcha' ;
5
5
import Container from '@/components/containers/Container/Container' ;
6
- import contactUsFormStyles from '@/styles/Contact.module.scss' ;
7
6
import RevealContentContainer from '@/components/containers/RevealContentContainer/RevealContentContainer' ;
8
7
import SubmitButton from '@/components/buttons/SubmitButton/SubmitButton' ;
8
+ import S from './styles' ;
9
9
10
10
export const ContactUsFormSubscribe = ( { setMsg } ) => {
11
11
return (
@@ -20,11 +20,9 @@ export const ContactUsFormSubscribe = ({ setMsg }) => {
20
20
setResponseMessage = { setMsg }
21
21
/>
22
22
{ status === 'error' && (
23
- < div
24
- className = { contactUsFormStyles . contact__respseonErrorMessage }
25
- >
23
+ < S . ResponseOnErrorMsg >
26
24
{ `Newsletter subscription error: ${ message } ` }
27
- </ div >
25
+ </ S . ResponseOnErrorMsg >
28
26
) }
29
27
</ >
30
28
) ;
@@ -93,11 +91,8 @@ function ContactUsForm({ subscribe, setResponseMessage }) {
93
91
return (
94
92
< RevealContentContainer >
95
93
< Container >
96
- < form
97
- onSubmit = { handleSubmit ( onSubmit ) }
98
- className = { contactUsFormStyles . contact__form }
99
- >
100
- < input
94
+ < S . Form onSubmit = { handleSubmit ( onSubmit ) } >
95
+ < S . Input
101
96
type = 'text'
102
97
placeholder = 'name'
103
98
{ ...register ( 'Name' , {
@@ -107,83 +102,82 @@ function ContactUsForm({ subscribe, setResponseMessage }) {
107
102
//no white space pattern
108
103
pattern : / [ ^ \s - ] / i,
109
104
} ) }
110
- className = { ` ${ contactUsFormStyles . contact__input } ${ contactUsFormStyles . contact__name } ` }
105
+ $inputType = 'name'
111
106
/>
112
- < p className = { contactUsFormStyles . contact__errorMessage } >
107
+ < S . ErrorMsg >
113
108
{ errors . Name ?. type === 'required'
114
109
? 'Name is required'
115
110
: errors . Name ?. type === 'pattern'
116
111
? 'No whitespace'
117
112
: errors . Name ?. type === 'minLength'
118
113
? 'Must be more than 1 character'
119
114
: undefined }
120
- </ p >
121
- < input
115
+ </ S . ErrorMsg >
116
+ < S . Input
122
117
type = 'email'
123
118
placeholder = 'email'
124
119
{ ...register ( 'Email' , {
125
120
required : true ,
126
121
pattern : / ^ \S + @ \S + $ / i,
127
122
} ) }
128
- className = { ` ${ contactUsFormStyles . contact__input } ${ contactUsFormStyles . contact__email } ` }
123
+ $inputType = 'email'
129
124
/>
130
- < p className = { contactUsFormStyles . contact__errorMessage } >
125
+ < S . ErrorMsg >
131
126
{ errors . Email ?. type === 'required' && 'Email is required' }
132
- </ p >
133
- < input
127
+ </ S . ErrorMsg >
128
+ < S . Input
134
129
type = 'text'
135
130
placeholder = 'subject'
136
131
{ ...register ( 'Subject' , {
137
132
required : true ,
138
133
minLength : 2 ,
139
134
pattern : / [ ^ \s - ] / i,
140
135
} ) }
141
- className = { ` ${ contactUsFormStyles . contact__input } ${ contactUsFormStyles . contact__subject } ` }
136
+ $inputType = 'email'
142
137
/>
143
- < p className = { contactUsFormStyles . contact__errorMessage } >
138
+ < S . ErrorMsg >
144
139
{ errors . Subject ?. type === 'required'
145
140
? 'Subject is required'
146
141
: errors . Subject ?. type === 'pattern'
147
142
? 'No whitespace'
148
143
: errors . Subject ?. type === 'minLength'
149
144
? 'Must be more than 1 character'
150
145
: undefined }
151
- </ p >
152
- < textarea
146
+ </ S . ErrorMsg >
147
+ < S . TextArea
153
148
{ ...register ( 'Message' , {
154
149
required : true ,
155
150
minLength : 2 ,
156
151
pattern : / [ ^ \s - ] / i,
157
152
} ) }
158
153
placeholder = 'Write your message here'
159
- className = { ` ${ contactUsFormStyles . contact__input } ${ contactUsFormStyles . contact__message } ` }
154
+ $inputType = 'message'
160
155
/>
161
- < p className = { contactUsFormStyles . contact__errorMessage } >
156
+ < S . ErrorMsg >
162
157
{ errors . Message ?. type === 'required'
163
158
? 'Message is required'
164
159
: errors . Message ?. type === 'pattern'
165
160
? 'No whitespace'
166
161
: errors . Message ?. type === 'minLength'
167
162
? 'Must be more than 1 character'
168
163
: undefined }
169
- </ p >
170
- < div className = { contactUsFormStyles . contact__subscribe } >
171
- < input
172
- className = { contactUsFormStyles . contact__subscribeInput }
164
+ </ S . ErrorMsg >
165
+ < S . SubscribeWrapper >
166
+ < S . SubscribeInput
173
167
type = 'checkbox'
174
168
placeholder = 'Subscribe to our DevNews!'
175
169
{ ...register ( 'Subscribe' , { } ) }
176
170
/>
177
171
Subscribe to our DevNews!
178
- </ div >
172
+ </ S . SubscribeWrapper >
179
173
< SubmitButton label = 'Submit' disabled = { isSubmitting } />
180
174
181
175
< ReCAPTCHA
182
176
ref = { contactReCaptchaRef }
183
177
size = 'invisible'
184
178
sitekey = { process . env . NEXT_PUBLIC_RECAPTCHA_SITE_KEY }
185
179
/>
186
- </ form >
180
+ </ S . Form >
187
181
</ Container >
188
182
</ RevealContentContainer >
189
183
) ;
0 commit comments