diff --git a/src/components/index.js b/src/components/index.js index 2f7e2b4..a2a0d91 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -12,6 +12,7 @@ export { default as Heading } from "./heading"; export { default as Icon } from "./icon"; export { default as IconWithContent } from "./icon-with-content"; export { default as InputText } from "./input-text"; +export { default as Interrupt } from "./interrupt"; export { default as Label } from "./label"; export { default as Link } from "./link"; export { default as Map } from "./map"; diff --git a/src/components/interrupt.js b/src/components/interrupt.js new file mode 100644 index 0000000..c46b443 --- /dev/null +++ b/src/components/interrupt.js @@ -0,0 +1,129 @@ +import React from "react"; +import styled from "@emotion/styled"; +import { keyframes } from "@emotion/react"; + +const Keyframes = keyframes` + 0% { + transform: rotate(0deg); + } + 100% { + transform: rotate(360deg); + } +`; + +const Container = styled.div` + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + z-index: 10; + display: flex; + justify-content: center; + align-items: center; + background-color: rgba(255, 255, 255, 0.75); +`; + +const Spinner = styled.div` + display: inline-block; + position: relative; + width: 80px; + height: 80px; +`; + +const Ball = styled.div` + animation: ${Keyframes} 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite; + transform-origin: 40px 40px; + + &:after { + content: ""; + display: block; + position: absolute; + width: 7px; + height: 7px; + border-radius: 50%; + background: var(--color-dark); + margin: -4px 0 0 -4px; + } +`; + +const BallA = styled(Ball)` + animation-delay: -0.036s; + &:after { + top: 63px; + left: 63px; + } +`; + +const BallB = styled(Ball)` + animation-delay: -0.072s; + &:after { + top: 68px; + left: 56px; + } +`; + +const BallC = styled(Ball)` + animation-delay: -0.108s; + &:after { + top: 71px; + left: 48px; + } +`; + +const BallD = styled(Ball)` + animation-delay: -0.144s; + &:after { + top: 72px; + left: 40px; + } +`; + +const BallE = styled(Ball)` + animation-delay: -0.18s; + &:after { + top: 71px; + left: 32px; + } +`; + +const BallF = styled(Ball)` + animation-delay: -0.216s; + &:after { + top: 68px; + left: 24px; + } +`; + +const BallG = styled(Ball)` + animation-delay: -0.252s; + &:after { + top: 63px; + left: 17px; + } +`; + +const BallH = styled(Ball)` + animation-delay: -0.288s; + &:after { + top: 56px; + left: 12px; + } +`; + +export default function Interrupt() { + return ( + + + + + + + + + + + + + ); +} diff --git a/src/components/text.js b/src/components/text.js index 933bd84..c4527c1 100644 --- a/src/components/text.js +++ b/src/components/text.js @@ -24,12 +24,13 @@ const StyledText = styled.p` css` color: var(--color-${props.color}); `} + ${props => + props.weight && + css` + font-weight: ${props.weight}; + `} `; export default function Text({ children, ...props }) { - return ( - - {children} - - ); + return {children}; } diff --git a/src/pages/contact.js b/src/pages/contact.js index afee060..207abf5 100644 --- a/src/pages/contact.js +++ b/src/pages/contact.js @@ -11,6 +11,7 @@ import { Icon, IconWithContent, InputText, + Interrupt, Label, Link, Map, @@ -32,7 +33,7 @@ const encode = data => { }; export default function Index({ data }) { - const [submitted, setSubmitted] = useState(); + const [formState, setFormState] = useState(); const [uploadFiles, setUploadFiles] = useState(); const [files, setFiles] = useState({}); @@ -43,6 +44,7 @@ export default function Index({ data }) { const handleSubmit = e => { e.preventDefault(); + setFormState("submitting"); const body = encode({ "form-name": "contact", name: e.target.name.value, @@ -55,16 +57,15 @@ export default function Index({ data }) { message: e.target.message.value, files }); - fetch("/contact", { method: "POST", body }) .then(res => { if (res.status !== 200) { - console.log("error", res); + setFormState("error"); } else { - setSubmitted(true); + setFormState("success"); } }) - .catch(error => console.log(error)); + .catch(() => setFormState("error")); }; return ( @@ -151,8 +152,8 @@ export default function Index({ data }) { -
- {submitted ? ( +
+ {formState === "success" && ( @@ -166,8 +167,10 @@ export default function Index({ data }) { - ) : ( + )} + {formState !== "success" && ( <> + {formState === "submitting" && } @@ -176,11 +179,26 @@ export default function Index({ data }) { Contact us + {formState === "error" && ( + <> + + There was an error submitting the form, please try again + later. + + + Alternatively, please feel free to email us at{" "} + + quotations@abcprojectdesign.com + + . + + + )}
handleSubmit(e, scroll)} data-netlify="true" data-netlify-honeypot="bot-field" > @@ -261,7 +279,9 @@ export default function Index({ data }) {