Skip to content

Commit

Permalink
Added loading screen and loading spinner; added rounded corners on ca…
Browse files Browse the repository at this point in the history
…rousel indicators; GDPR is now required; adjusted prettier configs
  • Loading branch information
rlebre committed Apr 6, 2022
1 parent e78fe9f commit 30f7232
Show file tree
Hide file tree
Showing 13 changed files with 161 additions and 332 deletions.
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"arrowParens": "always",
"jsxSingleQuote": true,
"printWidth": 120,
"quoteProps": "preserve"
"quoteProps": "preserve",
"trailingComma": "none"
}
2 changes: 1 addition & 1 deletion components/carousel/carousel.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
}

&__button {
@apply bg-white h-1 w-4 md:w-8;
@apply bg-white h-1 w-4 md:w-8 rounded;

&__active {
background: #356287;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const Carousel = ({ children, timeout }: Props) => {

const swipeHandlers = useSwipeable({
onSwipedLeft: () => updateSlide(slide + 1),
onSwipedRight: () => updateSlide(slide - 1),
onSwipedRight: () => updateSlide(slide - 1)
});

return (
Expand Down
20 changes: 16 additions & 4 deletions components/contact-section/ContactSection.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,41 @@
import Image from 'next/image';
import React, { useCallback } from 'react';
import React, { useCallback, useState } from 'react';
import ContactFormInterface from '../../interfaces/ContactFormInterface';
import { sendMessage } from '../../services/contact';
import Contact from '../forms/contact/ContactForm';
import LoadingScreen from '../loading-screen';
import LoadingSpinner from '../loading-spinner';
import { ModalService } from '../modal/service';

const ContactSection = () => {
const [submitting, setSubmitting] = useState(false);
const onFormSubmit = useCallback((data: ContactFormInterface, recaptchaToken: string | undefined) => {
setSubmitting(true);
sendMessage({ ...data, token: recaptchaToken })
.then(() => {
ModalService.success({
title: 'Message sent',
description: 'Your message has been sent. You will receive the reply in your email shortly.',
description: 'Your message has been sent. You will receive the reply in your email shortly.'
});
})
.catch((error) => {
ModalService.error({
title: 'Error',
description: error.response.data.message,
description:
error.response?.data?.message || 'Connection error. Please try again later or email us at [email protected]'
});
});
})
.finally(() => setSubmitting(false));
}, []);

return (
<section className='section'>
{submitting && (
<LoadingScreen>
<LoadingSpinner />
</LoadingScreen>
)}

<h1>
<span>Contact us</span>
</h1>
Expand Down
10 changes: 4 additions & 6 deletions components/forms/contact/ContactForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const ContactForm = ({ onSubmit }: Props) => {
const {
register,
handleSubmit,
formState: { errors },
formState: { errors }
} = useForm<ContactFormInterface>();

const { executeRecaptcha } = useGoogleReCaptcha();
Expand All @@ -32,8 +32,6 @@ const ContactForm = ({ onSubmit }: Props) => {
handleReCaptchaVerify().then((token) => {
onSubmit(data, token);
});
console.log(errors);
console.log(data);
};

return (
Expand All @@ -47,8 +45,8 @@ const ContactForm = ({ onSubmit }: Props) => {
required: true,
pattern: {
value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
message: 'Invalid email address',
},
message: 'Invalid email address'
}
})}
error={errors?.email}
/>
Expand Down Expand Up @@ -77,7 +75,7 @@ const ContactForm = ({ onSubmit }: Props) => {
message.*'
name='Agreement'
type='checkbox'
register={register('gdprAgreed')}
register={register('gdprAgreed', { required: true })}
error={errors?.gdprAgreed}
/>

Expand Down
8 changes: 4 additions & 4 deletions components/forms/download/DownloadForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const DownloadForm = ({ countries, release, onSubmit }: Props) => {
const {
register,
handleSubmit,
formState: { errors },
formState: { errors }
} = useForm<DownloadFormInterface>();

const { executeRecaptcha } = useGoogleReCaptcha();
Expand Down Expand Up @@ -50,8 +50,8 @@ const DownloadForm = ({ countries, release, onSubmit }: Props) => {
required: true,
pattern: {
value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
message: 'Invalid email address',
},
message: 'Invalid email address'
}
})}
error={errors?.email}
/>
Expand Down Expand Up @@ -118,7 +118,7 @@ const DownloadForm = ({ countries, release, onSubmit }: Props) => {
request.*'
name='Agreement'
type='checkbox'
register={register('gdprAgreed')}
register={register('gdprAgreed', { required: true })}
error={errors?.gdprAgreed}
/>

Expand Down
16 changes: 16 additions & 0 deletions components/loading-screen/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import styles from './loading-screen.module.scss';

interface Props {
children: JSX.Element;
}

const LoadingScreen = ({ children }: Props) => {
return (
<div className={styles.loading}>
<div>{children}</div>
</div>
);
};

export default LoadingScreen;
3 changes: 3 additions & 0 deletions components/loading-screen/loading-screen.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.loading {
@apply fixed left-0 top-0 z-50 h-full w-full overflow-auto bg-black bg-opacity-40 flex justify-center items-center;
}
14 changes: 14 additions & 0 deletions components/loading-spinner/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import styles from './loading-spinner.module.scss';

const LoadingSpinner = () => {
return (
<div className={styles.loading__spinner}>
<div className={styles.loading}>
<div></div>
</div>
</div>
);
};

export default LoadingSpinner;
42 changes: 42 additions & 0 deletions components/loading-spinner/loading-spinner.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* generated by https://loading.io/ */

@keyframes loading {
0% {
transform: translate(-50%, -50%) rotate(0deg);
}
100% {
transform: translate(-50%, -50%) rotate(360deg);
}
}

.loading {
width: 100%;
height: 100%;
position: relative;
transform: translateZ(0) scale(1);
backface-visibility: hidden;
transform-origin: 0 0;

div {
position: absolute;
width: 70px;
height: 70px;
border: 25px solid #286090;
border-top-color: transparent;
border-radius: 50%;

animation: loading 1s linear infinite;
top: 103px;
left: 103px;

box-sizing: content-box;
}

&__spinner {
width: 207px;
height: 207px;
display: inline-block;
overflow: hidden;
background: none;
}
}
2 changes: 0 additions & 2 deletions components/tab-view/references.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ interface Props {
}

const ReferenceTabbedView = ({ references }: Props) => {
useEffect(() => console.log(references), [references]);

const journals = useRef([]);
const conferences = useRef([]);
const magazines = useRef([]);
Expand Down
Loading

0 comments on commit 30f7232

Please sign in to comment.