From 5aa7ce0e76c8092448a455abf0de0179075d2c75 Mon Sep 17 00:00:00 2001 From: Adil Rehman Date: Wed, 5 Oct 2022 19:51:33 +0500 Subject: [PATCH] Added Transition --- src/components/QuestionSubmissionForm.tsx | 14 +++++ src/pages/questions/transition.module.css | 62 ++++++++++++++++++++++ src/styles/globals.css | 64 +++++++++++++++++++++++ 3 files changed, 140 insertions(+) create mode 100644 src/pages/questions/transition.module.css diff --git a/src/components/QuestionSubmissionForm.tsx b/src/components/QuestionSubmissionForm.tsx index 08a709a..e8b202c 100644 --- a/src/components/QuestionSubmissionForm.tsx +++ b/src/components/QuestionSubmissionForm.tsx @@ -1,5 +1,8 @@ +// import { useState } from 'react'; +import '../pages/questions/transition.module.css'; import { type SubmitHandler, useForm, FieldValues } from 'react-hook-form'; import type { PageProps } from '../lib/types'; +import { useState } from 'react'; interface QuestionSubmissionFormInputs { company: string; @@ -15,6 +18,7 @@ export function QuestionSubmissionForm({ session }: PageProps) { // reference: https://react-hook-form.com/get-started#Quickstart const { register, handleSubmit, reset, formState } = useForm(); + const [loading, setLoading] = useState(false); const onSubmit: SubmitHandler = async data => { console.log(data); @@ -36,6 +40,10 @@ export function QuestionSubmissionForm({ session }: PageProps) { } catch (err) { console.log(err); } + setLoading(true); + setTimeout(() => { + setLoading(false); + }, 5000); console.log(result); @@ -176,6 +184,12 @@ export function QuestionSubmissionForm({ session }: PageProps) { + {loading && ( +
+
+
+ )} + {/* {submitMessage &&
Submit another Question
} */} ); } diff --git a/src/pages/questions/transition.module.css b/src/pages/questions/transition.module.css new file mode 100644 index 0000000..6252931 --- /dev/null +++ b/src/pages/questions/transition.module.css @@ -0,0 +1,62 @@ +.spinner-wrapper { + height: 100vh; + width: 100vw; + display: flex; + justify-content: center; + align-items: center; + position: fixed; + top: 0; + left: 0; + background-color: rgb(255, 255, 255); + z-index: 9999; +} +.spinner { + position: absolute; + left: 50%; + top: 50%; + height: 60px; + width: 60px; + margin: 0px auto; + -webkit-animation: rotation 0.6s infinite linear; + -moz-animation: rotation 0.6s infinite linear; + -o-animation: rotation 0.6s infinite linear; + animation: rotation 0.6s infinite linear; + border-left: 6px solid rgba(0, 174, 239, 0.15); + border-right: 6px solid rgba(0, 174, 239, 0.15); + border-bottom: 6px solid rgba(0, 174, 239, 0.15); + border-top: 6px solid rgba(0, 174, 239, 0.8); + border-radius: 100%; +} + +@-webkit-keyframes rotation { + from { + -webkit-transform: rotate(0deg); + } + to { + -webkit-transform: rotate(359deg); + } +} +@-moz-keyframes rotation { + from { + -moz-transform: rotate(0deg); + } + to { + -moz-transform: rotate(359deg); + } +} +@-o-keyframes rotation { + from { + -o-transform: rotate(0deg); + } + to { + -o-transform: rotate(359deg); + } +} +@keyframes rotation { + from { + transform: rotate(0deg); + } + to { + transform: rotate(359deg); + } +} diff --git a/src/styles/globals.css b/src/styles/globals.css index 3f2011e..03e739e 100644 --- a/src/styles/globals.css +++ b/src/styles/globals.css @@ -16,3 +16,67 @@ #__next { min-height: 100%; } +@layer components { + .spinner-wrapper { + height: 100vh; + width: 100vw; + display: flex; + justify-content: center; + align-items: center; + position: fixed; + top: 0; + left: 0; + background-color: rgb(255, 255, 255); + z-index: 9999; + } + .spinner { + position: absolute; + left: 50%; + top: 50%; + height: 60px; + width: 60px; + margin: 0px auto; + -webkit-animation: rotation 0.6s infinite linear; + -moz-animation: rotation 0.6s infinite linear; + -o-animation: rotation 0.6s infinite linear; + animation: rotation 0.6s infinite linear; + border-left: 6px solid rgba(0, 174, 239, 0.15); + border-right: 6px solid rgba(0, 174, 239, 0.15); + border-bottom: 6px solid rgba(0, 174, 239, 0.15); + border-top: 6px solid rgba(0, 174, 239, 0.8); + border-radius: 100%; + } + + @-webkit-keyframes rotation { + from { + -webkit-transform: rotate(0deg); + } + to { + -webkit-transform: rotate(359deg); + } + } + @-moz-keyframes rotation { + from { + -moz-transform: rotate(0deg); + } + to { + -moz-transform: rotate(359deg); + } + } + @-o-keyframes rotation { + from { + -o-transform: rotate(0deg); + } + to { + -o-transform: rotate(359deg); + } + } + @keyframes rotation { + from { + transform: rotate(0deg); + } + to { + transform: rotate(359deg); + } + } +}