Skip to content

Commit

Permalink
Merge pull request #802 from ita-social-projects/modalContactUs
Browse files Browse the repository at this point in the history
modalContactUs: add modal to contact us
  • Loading branch information
MementoMorj authored Sep 26, 2023
2 parents 7f53159 + fe55e36 commit 51d805d
Show file tree
Hide file tree
Showing 9 changed files with 295 additions and 212 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Email from '@/models/email/email.model';

const MAX_SYMBOLS = 500;

const ContactForm = () => {
const ContactForm = ({ customClass = "" }) => {
const [formData, setFormData] = useState({ email: '', message: '' });
const [isVerified, setIsVerified] = useState(false);
const messageLength = formData.message.length | 0;
Expand All @@ -25,27 +25,27 @@ const ContactForm = () => {
if (isVerified) {
const newEmail: Email = { from: formData.email, content: formData.message };
EmailApi.send(newEmail)
.then(successMessage)
.catch(errorMessage);
.then(successMessage)
.catch(errorMessage);
}
};

const successMessage = () => {
messageApi.open({
type: 'success',
content: 'Лист успішно надісланий',
type: 'success',
content: 'Лист успішно надісланий',
});
};

const errorMessage = () => {
messageApi.open({
type: 'error',
content: 'Щось пішло не так...',
type: 'error',
content: 'Щось пішло не так...',
});
};

return (
<div className="formContainer">
<div className={`formWrapper ${customClass}`}>
{messageContextHolder}
<div className="formTitleContainer">
<div className="formTitle">Форма зворотного зв’язку</div>
Expand All @@ -62,9 +62,11 @@ const ContactForm = () => {
<Form.Item
className="textareaBlock required-input"
name="message"
rules={[{ required: false,
min: 1,
max: MAX_SYMBOLS }]}
rules={[{
required: false,
min: 1,
max: MAX_SYMBOLS
}]}
>
<Input.TextArea
required={true}
Expand All @@ -76,15 +78,17 @@ const ContactForm = () => {
onChange={handleChange}
/>
<p className="custom-character-counter">
{messageLength}
{messageLength}
/ {MAX_SYMBOLS}
</p>
</Form.Item>
<Form.Item
name="email"
rules={[
{ required: true,
type: 'email' },
{
required: true,
type: 'email'
},
]}
>
<Input
Expand Down
215 changes: 215 additions & 0 deletions src/app/common/components/ContactForm/ContactForm.styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
@use "@sass/_utils.functions.scss" as f;
@use "@sass/mixins/_utils.mixins.scss" as mut;
@use "@assets/sass/variables/_variables.fonts.scss" as ft;
@use "@assets/sass/variables/_variables.colors.scss" as c;

.contactUsContainer {

.ant-input-affix-wrapper,
.ant-input-affix-wrapper-focused {
border: none;
box-shadow: none !important;
}
}

.formWrapper {
width: f.pxToRem(568px);
padding: f.pxToRem(24px);

background-color: #FFFFFF;
box-shadow: 0px 5.57966px 5.57966px rgba(0, 0, 0, 0.25);

@include mut.full-rounded(20px);
text-align: center;

&__modal {
box-shadow: none;
padding: 0%;
}

.formTitleContainer {
@include mut.flexed($direction: column, $gap: 24px);
margin-bottom: 24px;

.formTitle {
@include mut.with-font($font-family: ft.$closer-text-font, $font-weight: 500, $font-size: 20px);
line-height: 26px;
color: #891F16;
}

.formSubTitle {
@include mut.with-font($font-family: ft.$roboto-font, $font-weight: 300, $font-size: 20px);
line-height: 23px;
color: c.$lighter-black-color;
text-align: left;
}
}

.contactForm {
@include mut.flexed($direction: column, $gap: 24px);

.custom-character-counter {
margin-bottom: -12px;
text-align: right;
font-family: "Roboto", "Helvetica Neue", sans-serif !important;
font-size: 16px;
color: #00000073;
}

textarea {
resize: none;
outline: none;
height: f.pxToRem(140px);
}

textarea,
input:focus {
outline: none;
}

textarea,
input {
width: 100%;
padding: f.pxToRem(12px) f.pxToRem(24px);
border: 1px solid #D3CDCA;
@include mut.full-rounded(14px);
@include mut.with-font($font-family: ft.$roboto-font, $font-weight: 300, $font-size: 20px);
line-height: 27px;

overflow: auto !important;
}

.textareaBlock {
position: relative;

.amountSymbols {
position: absolute;
bottom: f.pxToRem(10px);
right: f.pxToRem(10px);
color: #C4C4C4;
}
}

.ant-input:hover,
.ant-input:focus {
border: f.pxToRem(1px) solid #D3CDCA;
box-shadow: none;
}

.ant-form-item {
margin-bottom: 0;
}

.ant-form-item:focus {
outline: none;
}

.ant-input-textarea-show-count::after {
position: absolute;
top: f.pxToRem(134px);
right: f.pxToRem(10px);
}

.ant-btn-primary:not(:disabled):hover {
background-color: #E04031;
}

.ant-form-item .ant-form-item-explain-error {
display: none;
}

button {
@include mut.with-font($font-family: ft.$roboto-font, $font-weight: 500, $font-size: 20px);
line-height: 23px;
color: #FFFFFF;

padding: f.pxToRem(25px) f.pxToRem(56px);
height: 100%;
background-color: c.$accented-red-color;
box-shadow: 0px 4px 4px rgba(219, 52, 36, 0.18);
@include mut.full-rounded(14px);
border: none;
cursor: pointer;

&:hover {
background-color: c.$dark-red-color;
}
}

.required-input {
position: relative;
}

.required-input::before {
content: '*';
position: absolute;
top: 0;
left: f.pxToRem(-8px);
transform: translate(-50%, -50%);
color: red;
font-size: 20px;
}

.captchaBlock {
@include mut.flexed($direction: column, $justify-content: center, $align-items: center);
}
}
}

@media screen and (max-width: 1024px) {
.formWrapper {
width: 100%;

padding: f.pxToRem(16px);
margin-top: f.pxToRem(60px);

&__modal {
margin-top: 0;
}

.formTitleContainer {
@include mut.flexed($direction: column, $gap: 16px);
margin-bottom: f.pxToRem(16px);

.formTitle {
@include mut.with-font($font-family: ft.$closer-text-font, $font-weight: 500, $font-size: 14px);
text-align: left;
line-height: 18px;
}

.formSubTitle {
@include mut.with-font($font-family: ft.$roboto-font, $font-weight: 300, $font-size: 14px);
line-height: 16px;
}
}

.contactForm {
@include mut.flexed($direction: column, $gap: 16px);

button {
width: 100%;
padding: f.pxToRem(15px) 0;
}

textarea,
input {
@include mut.with-font($font-family: ft.$roboto-font, $font-weight: 300, $font-size: 16px);
line-height: 21px;
}

.ant-input-textarea-show-count::after {
top: f.pxToRem(110px);
}

.ant-input-textarea-show-count .ant-input-data-count {
margin-bottom: f.pxToRem(-18px);
}
}
}
}

@media screen and (max-width: 480px) {
.contactUsContainer .formContainer .formTitleContainer .formTitle {
text-align: center;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import ContactForm from '@/app/common/components/ContactForm/ContactForm.component'
import './ContactUsModal.styles.scss'
import { Modal, Typography } from 'antd'
const { Text } = Typography
import { useEffect, useState } from 'react';

interface Props {
text: string;
toggleState: () => void | undefined;
}

export const ContactUsModal = ({ text, toggleState }: Props) => {
const [isActive, setActive] = useState(false);
const handleClick = () => {
setActive(true);
toggleState();
};
return (
<>
<Text onClick={() => handleClick()} className='text-white'>{text}</Text>
<Modal open={isActive} footer={null} onCancel={() => setActive(false)} width={"max-content"}>
<ContactForm customClass={"formWrapper__modal"} />
</Modal>
</>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@use "@sass/variables/_variables.colors.scss" as c;
@use "@sass/mixins/_utils.mixins.scss" as mut;

.headerItem{
background-color: transparent;
border: none;
text-align: left;
color: inherit;
text-decoration: none;
}

.headerItem:hover {
cursor: pointer;
color: c.$dark-red-color;
}

.headerItem:after {
content: '';
background-color: c.$dark-red-color;
color: c.$dark-red-color;

@include mut.sized(100%, 2px);
@include mut.positioned-as(absolute, $bottom: 0, $left: 0);
}
3 changes: 2 additions & 1 deletion src/app/layout/footer/Footer.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import useWindowSize from '@hooks/stateful/useWindowSize.hook';

import JobApi from '@/app/api/job/Job.api';
import FRONTEND_ROUTES from '@/app/common/constants/frontend-routes.constants';
import { ContactUsModal } from '@/app/common/components/modals/ContactUsModal/ContactUsModal.component';
import scrollWithOffset from '@/app/common/utils/window.utility';

const Footer = () => {
Expand Down Expand Up @@ -57,7 +58,7 @@ const Footer = () => {
</ul>
<ul className="usefulLinksColumn supportLinks">
<li><a href={FRONTEND_ROUTES.OTHER_PAGES.PRIVACY_POLICY}>Політика конфіденційності</a></li>
<li><a href={FRONTEND_ROUTES.OTHER_PAGES.CONTACT_US}>Зворотний зв&apos;язок</a></li>
<li><ContactUsModal toggleState={() => { }} text="Зворотний зв&apos;язок" /></li>
<li><a href="https://drive.google.com/drive/folders/11Ef4y_6ZHyqT5eDxD5Cn-aWhr-kThh3A?usp=drive_link" target="_blank" rel="noreferrer">Звітність ГО «Історична Платформа»</a></li>
</ul>
<ul className="socialIconContainer">
Expand Down
6 changes: 6 additions & 0 deletions src/app/layout/footer/Footer.styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@
a{
color: c.$pure-white-color;
}

li{
.ant-typography.text-white{
color: white;
}
}
}

.socialIconContainer {
Expand Down
Loading

0 comments on commit 51d805d

Please sign in to comment.