@@ -3,9 +3,9 @@ import { useRef } from 'react';
33import MailchimpSubscribe from 'react-mailchimp-subscribe' ;
44import ReCAPTCHA from 'react-google-recaptcha' ;
55import Container from '@/components/containers/Container' ;
6- import contactUsFormStyles from '@/styles/Contact.module.scss' ;
76import RevealContentContainer from '@/components/containers/RevealContentContainer' ;
8- import SubmitButton from '@/components/buttons/SubmitButton' ;
7+ import { SubmitButton } from '@/components/buttons/SubmitButton' ;
8+ import S from './styles' ;
99
1010export const ContactUsFormSubscribe = ( { setMsg } ) => {
1111 return (
@@ -20,11 +20,9 @@ export const ContactUsFormSubscribe = ({ setMsg }) => {
2020 setResponseMessage = { setMsg }
2121 />
2222 { status === 'error' && (
23- < div
24- className = { contactUsFormStyles . contact__respseonErrorMessage }
25- >
23+ < S . ResponseOnErrorMsg >
2624 { `Newsletter subscription error: ${ message } ` }
27- </ div >
25+ </ S . ResponseOnErrorMsg >
2826 ) }
2927 </ >
3028 ) ;
@@ -93,11 +91,8 @@ function ContactUsForm({ subscribe, setResponseMessage }) {
9391 return (
9492 < RevealContentContainer >
9593 < Container >
96- < form
97- onSubmit = { handleSubmit ( onSubmit ) }
98- className = { contactUsFormStyles . contact__form }
99- >
100- < input
94+ < S . Form onSubmit = { handleSubmit ( onSubmit ) } >
95+ < S . Input
10196 type = 'text'
10297 placeholder = 'name'
10398 { ...register ( 'Name' , {
@@ -107,83 +102,78 @@ function ContactUsForm({ subscribe, setResponseMessage }) {
107102 //no white space pattern
108103 pattern : / [ ^ \s - ] / i,
109104 } ) }
110- className = { `${ contactUsFormStyles . contact__input } ${ contactUsFormStyles . contact__name } ` }
111105 />
112- < p className = { contactUsFormStyles . contact__errorMessage } >
106+ < S . ErrorMsg >
113107 { errors . Name ?. type === 'required'
114108 ? 'Name is required'
115109 : errors . Name ?. type === 'pattern'
116110 ? 'No whitespace'
117111 : errors . Name ?. type === 'minLength'
118112 ? 'Must be more than 1 character'
119113 : undefined }
120- </ p >
121- < input
114+ </ S . ErrorMsg >
115+ < S . Input
122116 type = 'email'
123117 placeholder = 'email'
124118 { ...register ( 'Email' , {
125119 required : true ,
126120 pattern : / ^ \S + @ \S + $ / i,
127121 } ) }
128- className = { `${ contactUsFormStyles . contact__input } ${ contactUsFormStyles . contact__email } ` }
129122 />
130- < p className = { contactUsFormStyles . contact__errorMessage } >
123+ < S . ErrorMsg >
131124 { errors . Email ?. type === 'required' && 'Email is required' }
132- </ p >
133- < input
125+ </ S . ErrorMsg >
126+ < S . Input
134127 type = 'text'
135128 placeholder = 'subject'
136129 { ...register ( 'Subject' , {
137130 required : true ,
138131 minLength : 2 ,
139132 pattern : / [ ^ \s - ] / i,
140133 } ) }
141- className = { `${ contactUsFormStyles . contact__input } ${ contactUsFormStyles . contact__subject } ` }
142134 />
143- < p className = { contactUsFormStyles . contact__errorMessage } >
135+ < S . ErrorMsg >
144136 { errors . Subject ?. type === 'required'
145137 ? 'Subject is required'
146138 : errors . Subject ?. type === 'pattern'
147139 ? 'No whitespace'
148140 : errors . Subject ?. type === 'minLength'
149141 ? 'Must be more than 1 character'
150142 : undefined }
151- </ p >
152- < textarea
143+ </ S . ErrorMsg >
144+ < S . TextArea
153145 { ...register ( 'Message' , {
154146 required : true ,
155147 minLength : 2 ,
156148 pattern : / [ ^ \s - ] / i,
157149 } ) }
158150 placeholder = 'Write your message here'
159- className = { `${ contactUsFormStyles . contact__input } ${ contactUsFormStyles . contact__message } ` }
160151 />
161- < p className = { contactUsFormStyles . contact__errorMessage } >
152+ < S . ErrorMsg >
162153 { errors . Message ?. type === 'required'
163154 ? 'Message is required'
164155 : errors . Message ?. type === 'pattern'
165156 ? 'No whitespace'
166157 : errors . Message ?. type === 'minLength'
167158 ? 'Must be more than 1 character'
168159 : undefined }
169- </ p >
170- < div className = { contactUsFormStyles . contact__subscribe } >
171- < input
172- className = { contactUsFormStyles . contact__subscribeInput }
160+ </ S . ErrorMsg >
161+ < S . SubscribeWrapper >
162+ < S . SubscribeInput
173163 type = 'checkbox'
174164 placeholder = 'Subscribe to our DevNews!'
175165 { ...register ( 'Subscribe' , { } ) }
176166 />
177167 Subscribe to our DevNews!
178- </ div >
168+ </ S . SubscribeWrapper >
179169 < SubmitButton label = 'Submit' disabled = { isSubmitting } />
180170
181171 < ReCAPTCHA
182172 ref = { contactReCaptchaRef }
183173 size = 'invisible'
184174 sitekey = { process . env . NEXT_PUBLIC_RECAPTCHA_SITE_KEY }
185175 />
186- </ form >
176+ </ S . Form >
187177 </ Container >
188178 </ RevealContentContainer >
189179 ) ;
0 commit comments