-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6bcc904
commit b9c6681
Showing
7 changed files
with
146 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { ErrorMessage, Formik } from "formik"; | ||
import * as Yup from "yup"; | ||
import { | ||
Field, | ||
Form, | ||
FormContainer, | ||
FormHeader, | ||
FormText, | ||
FormTitle, | ||
SendButton, | ||
} from "./FeedbackForm.styled"; | ||
|
||
const RentCarsSchema = Yup.object().shape({ | ||
name: Yup.string() | ||
.min(2, "Too Short!") | ||
.max(50, "Too Long!") | ||
.required("Required"), | ||
email: Yup.string().email("Invalid email").required("Required"), | ||
comment: Yup.string() | ||
.min(2, "Too Short!") | ||
.max(60, "Too Long!") | ||
.required("Required"), | ||
}); | ||
|
||
export const FeedbackForm = () => { | ||
return ( | ||
<FormContainer> | ||
<FormHeader> | ||
<FormTitle>Book your campervan now</FormTitle> | ||
<FormText>Stay connected! We are always ready to help you.</FormText> | ||
</FormHeader> | ||
<Formik | ||
initialValues={{ | ||
name: "", | ||
email: "", | ||
comment: "", | ||
}} | ||
validationSchema={RentCarsSchema} | ||
onSubmit={async (values, actions) => { | ||
actions.resetForm(); | ||
console.log(values); | ||
}} | ||
> | ||
<Form> | ||
<label> | ||
<Field name="name" placeholder="Jane" /> | ||
<ErrorMessage component={"span"} name="name" /> | ||
</label> | ||
|
||
<label> | ||
<Field type="email" name="email" placeholder="example@mail.com" /> | ||
<ErrorMessage component={"span"} name="email" /> | ||
</label> | ||
|
||
<label> | ||
<Field | ||
className="textarea" | ||
component="textarea" | ||
name="comment" | ||
placeholder="Comment" | ||
/> | ||
<ErrorMessage component={"span"} name="comment" /> | ||
</label> | ||
|
||
<SendButton type="submit">Send</SendButton> | ||
</Form> | ||
</Formik> | ||
</FormContainer> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import styled from "styled-components"; | ||
import { Field as StyledField, Form as StyledForm } from "formik"; | ||
|
||
export const FormContainer = styled.div` | ||
border: 1px solid ${(p) => p.theme.colors.borderColor}; | ||
border-radius: ${(p) => p.theme.radius.sm}; | ||
padding: 24px; | ||
height: 500px; | ||
`; | ||
|
||
export const FormHeader = styled.div` | ||
margin-bottom: 24px; | ||
`; | ||
|
||
export const FormTitle = styled.h3` | ||
margin-bottom: 8px; | ||
font-size: ${(p) => p.theme.fonts.mdSize}; | ||
`; | ||
|
||
export const FormText = styled.p` | ||
color: ${(p) => p.theme.colors.grey}; | ||
`; | ||
|
||
export const Form = styled(StyledForm)` | ||
display: flex; | ||
flex-direction: column; | ||
gap: 14px; | ||
`; | ||
|
||
export const Field = styled(StyledField)` | ||
border: none; | ||
background-color: ${(p) => p.theme.colors.white}; | ||
outline: none; | ||
border-radius: ${(p) => p.theme.radius.sm}; | ||
padding: 18px; | ||
width: 400px; | ||
height: 56px; | ||
&.textarea { | ||
height: 114px; | ||
resize: none; | ||
} | ||
`; | ||
|
||
export const SendButton = styled.button` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 160px; | ||
height: 56px; | ||
margin-top: 10px; | ||
padding: 16px 60px; | ||
border: none; | ||
border-radius: ${(p) => p.theme.radius.xlg}; | ||
background-color: ${(p) => p.theme.colors.red}; | ||
color: ${(p) => p.theme.colors.buttonText}; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters