Skip to content

Commit

Permalink
add form
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolaus-B committed Mar 24, 2024
1 parent 6bcc904 commit b9c6681
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/components/FeaturesPopUp/FeaturesPopUp.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Detail } from "../Details/Detail";
import { Details } from "../Details/Details";
import { FeedbackForm } from "../FeedbackForm/FeedbackForm";
import {
DetailsContainer,
FeaturedHead,
Expand Down Expand Up @@ -49,6 +50,7 @@ export const FeaturesPopUp = ({ car }) => {
</InfoWrapper>
</InfoContainer>
</FeaturesWrapper>
<FeedbackForm />
</FeaturesContainer>
);
};
5 changes: 4 additions & 1 deletion src/components/FeaturesPopUp/FeaturesPopUp.styled.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import styled from "styled-components";

export const FeaturesContainer = styled.div``;
export const FeaturesContainer = styled.div`
display: flex;
gap: 24px;
`;

export const FeaturesWrapper = styled.div`
width: 430px;
Expand Down
70 changes: 70 additions & 0 deletions src/components/FeedbackForm/FeedbackForm.jsx
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="[email protected]" />
<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>
);
};
59 changes: 59 additions & 0 deletions src/components/FeedbackForm/FeedbackForm.styled.js
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};
`;
7 changes: 5 additions & 2 deletions src/components/ReviewsPopUp/ReviewsPopUp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import {
ReviewImageLetter,
ReviewList,
ReviewerName,
ReviewsContainer,
StarsContainer,
} from "./ReviewsPopUp.styled";
import { Icon } from "../Icon/Icon";
import { FeedbackForm } from "../FeedbackForm/FeedbackForm";

export const ReviewsPopUp = ({ reviews }) => {
const renderStars = (rating) => {
Expand All @@ -30,7 +32,7 @@ export const ReviewsPopUp = ({ reviews }) => {
return stars;
};
return (
<div>
<ReviewsContainer>
<ReviewList>
{reviews.map((review) => {
return (
Expand All @@ -55,6 +57,7 @@ export const ReviewsPopUp = ({ reviews }) => {
);
})}
</ReviewList>
</div>
<FeedbackForm />
</ReviewsContainer>
);
};
5 changes: 5 additions & 0 deletions src/components/ReviewsPopUp/ReviewsPopUp.styled.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import styled from "styled-components";

export const ReviewsContainer = styled.div`
display: flex;
gap: 24px;
`;

export const ReviewList = styled.ul`
display: flex;
flex-direction: column;
Expand Down
2 changes: 1 addition & 1 deletion src/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const theme = {
},
};

// ${p => p.theme.colors.red}
// ${p => p.theme.colors.borderColor}
// ${p => p.theme.radius.sm}
// ${p => p.theme.fonts.bigSize}
// ${p => p.theme.transition.transitionDurAndFunc}

0 comments on commit b9c6681

Please sign in to comment.