|
@ -1,6 +1,6 @@ |
|
|
import React, { useState, useEffect, useRef, useLayoutEffect } from "react"; |
|
|
import React, { useState, useEffect, useRef, useLayoutEffect } from "react"; |
|
|
import { css, cx } from "@emotion/css"; |
|
|
import { css, cx } from "@emotion/css"; |
|
|
import { useNavigate } from "react-router-dom"; |
|
|
import useLocation from "wouter/use-location"; |
|
|
|
|
|
|
|
|
import { ReactComponent as Logo } from "../assets/logo.svg"; |
|
|
import { ReactComponent as Logo } from "../assets/logo.svg"; |
|
|
import { ReactComponent as Right } from "../assets/arrow-right.svg"; |
|
|
import { ReactComponent as Right } from "../assets/arrow-right.svg"; |
|
@ -11,20 +11,24 @@ import useMediaQuery from "../util/useMediaQuery"; |
|
|
const [timer, clear] = getTimeout(); |
|
|
const [timer, clear] = getTimeout(); |
|
|
|
|
|
|
|
|
const Container: React.FC<{ |
|
|
const Container: React.FC<{ |
|
|
children: (string | React.DetailedReactHTMLElement<any, HTMLElement> | React.ReactElement)[]; |
|
|
children: ( |
|
|
|
|
|
| string |
|
|
|
|
|
| React.DetailedReactHTMLElement<any, HTMLElement> |
|
|
|
|
|
| React.ReactElement |
|
|
|
|
|
)[]; |
|
|
hideNav?: boolean; |
|
|
hideNav?: boolean; |
|
|
arrowReversed?: boolean; |
|
|
end?: boolean; |
|
|
next?: string; |
|
|
next?: string; |
|
|
className?: string; |
|
|
className?: string; |
|
|
}> = ({ |
|
|
}> = ({ |
|
|
children: _children, |
|
|
children: _children, |
|
|
hideNav = false, |
|
|
hideNav = false, |
|
|
arrowReversed = false, |
|
|
end = false, |
|
|
next, |
|
|
next, |
|
|
className, |
|
|
className, |
|
|
...props |
|
|
...props |
|
|
}) => { |
|
|
}) => { |
|
|
const navigate = useNavigate(); |
|
|
const [, navigate] = useLocation(); |
|
|
|
|
|
|
|
|
const mobile = useMediaQuery("(max-width: 50rem)"); |
|
|
const mobile = useMediaQuery("(max-width: 50rem)"); |
|
|
|
|
|
|
|
@ -37,11 +41,20 @@ const Container: React.FC<{ |
|
|
|
|
|
|
|
|
const children = React.Children.map( |
|
|
const children = React.Children.map( |
|
|
_children, |
|
|
_children, |
|
|
(child: string | React.DetailedReactHTMLElement<any, HTMLElement> | React.ReactElement) => |
|
|
( |
|
|
|
|
|
child: |
|
|
|
|
|
| string |
|
|
|
|
|
| React.DetailedReactHTMLElement<any, HTMLElement> |
|
|
|
|
|
| React.ReactElement, |
|
|
|
|
|
) => |
|
|
!child || typeof child === "string" |
|
|
!child || typeof child === "string" |
|
|
? child |
|
|
? child |
|
|
: React.cloneElement(child, { |
|
|
: React.cloneElement(child, { |
|
|
style: { opacity: 0, transform: "translateY(3rem)", transition: "all 300ms" }, |
|
|
style: { |
|
|
|
|
|
opacity: 0, |
|
|
|
|
|
transform: "translateY(3rem)", |
|
|
|
|
|
transition: "all 300ms", |
|
|
|
|
|
}, |
|
|
}), |
|
|
}), |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
@ -52,14 +65,19 @@ const Container: React.FC<{ |
|
|
if (highlightCircle.current) { |
|
|
if (highlightCircle.current) { |
|
|
highlightCircle.current.classList.add("highlight"); |
|
|
highlightCircle.current.classList.add("highlight"); |
|
|
timer( |
|
|
timer( |
|
|
() => highlightCircle.current && highlightCircle.current.classList.remove("highlight"), |
|
|
() => |
|
|
|
|
|
highlightCircle.current && |
|
|
|
|
|
highlightCircle.current.classList.remove("highlight"), |
|
|
1500, |
|
|
1500, |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (nextBtn.current) { |
|
|
if (nextBtn.current) { |
|
|
nextBtn.current.style.width = "4rem"; |
|
|
nextBtn.current.style.width = "4rem"; |
|
|
timer(() => nextBtn.current && (nextBtn.current.style.right = "10vw"), 300); |
|
|
timer( |
|
|
|
|
|
() => nextBtn.current && (nextBtn.current.style.right = "10vw"), |
|
|
|
|
|
300, |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (containerChild.current) { |
|
|
if (containerChild.current) { |
|
@ -86,7 +104,9 @@ const Container: React.FC<{ |
|
|
|
|
|
|
|
|
const handleResize = () => { |
|
|
const handleResize = () => { |
|
|
if (containerChild.current && logoContainer.current) |
|
|
if (containerChild.current && logoContainer.current) |
|
|
logoContainer.current.style.left = `${containerChild.current.getBoundingClientRect().x}px`; |
|
|
logoContainer.current.style.left = `${ |
|
|
|
|
|
containerChild.current.getBoundingClientRect().x |
|
|
|
|
|
}px`;
|
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
@ -101,7 +121,9 @@ const Container: React.FC<{ |
|
|
|
|
|
|
|
|
const handleNext: React.MouseEventHandler<HTMLButtonElement> = e => { |
|
|
const handleNext: React.MouseEventHandler<HTMLButtonElement> = e => { |
|
|
if (containerChild.current) { |
|
|
if (containerChild.current) { |
|
|
([...containerChild.current.children] as (HTMLElement | SVGElement)[]).forEach(child => { |
|
|
( |
|
|
|
|
|
[...containerChild.current.children] as (HTMLElement | SVGElement)[] |
|
|
|
|
|
).forEach(child => { |
|
|
child.style.marginBottom = "2rem"; |
|
|
child.style.marginBottom = "2rem"; |
|
|
child.style.opacity = "0"; |
|
|
child.style.opacity = "0"; |
|
|
}); |
|
|
}); |
|
@ -201,6 +223,7 @@ const Container: React.FC<{ |
|
|
<button |
|
|
<button |
|
|
onClick={handleNext} |
|
|
onClick={handleNext} |
|
|
ref={nextBtn} |
|
|
ref={nextBtn} |
|
|
|
|
|
title={end ? "Back to start" : "Next page"} |
|
|
className={css` |
|
|
className={css` |
|
|
position: fixed; |
|
|
position: fixed; |
|
|
right: 14vw; |
|
|
right: 14vw; |
|
@ -217,7 +240,7 @@ const Container: React.FC<{ |
|
|
transition: all 300ms; |
|
|
transition: all 300ms; |
|
|
overflow: hidden; |
|
|
overflow: hidden; |
|
|
|
|
|
|
|
|
${arrowReversed ? "rotate: 180deg;" : ""} |
|
|
${end ? "rotate: 180deg;" : ""} |
|
|
|
|
|
|
|
|
&:hover * { |
|
|
&:hover * { |
|
|
fill: var(--primary-colour); |
|
|
fill: var(--primary-colour); |
|
|