diff --git a/components/common/NavBar.tsx b/components/common/NavBar.tsx index 89f6f4f..97f2906 100644 --- a/components/common/NavBar.tsx +++ b/components/common/NavBar.tsx @@ -8,63 +8,21 @@ interface NavProps { options: NavTemplate[]; } -// nav bar animation, fades in and then animates the children -const containerAnimation: Variants = { - initial: { - opacity: 1, - }, - animate: { - opacity: 1, - transition: { - duration: 2, - delayChildren: 0.5, - staggerChildren: 0.25, - }, - }, -}; - -// default animation for nav bar items -const itemAnimation: Variants = { - initial: { - opacity: 0, - x: 100, - }, - animate: { - opacity: 1, - x: 0, - }, -}; - function NavBar({ options }: NavProps) { const [navList, setNavList] = useState(options); const [isActive, setActive] = useState(false); return ( - + InvestBot -

+

{ + setActive(!isActive); + }} + > InvestBot

@@ -118,7 +81,7 @@ function NavBar({ options }: NavProps) { {navList.map((nav, index) => ( {nav.content} @@ -126,7 +89,7 @@ function NavBar({ options }: NavProps) {

Login WIP @@ -139,21 +102,20 @@ function NavBar({ options }: NavProps) { // hiddden by default, when active is true, animate in className="pointer-events-auto z-10 flex w-screen flex-col items-center overflow-hidden bg-zinc-800 bg-opacity-70 pt-5 backdrop-blur lg:hidden" // have it take up the entire screen, animate in by expanding from the bottom of the nav bar to the bottom of the screen - // TODO: struggled with getting children staggers/delays to work - initial={{ height: 0 }} - animate={{ height: "100vh" }} - exit={{ height: 0 }} - transition={{ duration: 0.5 }} + variants={mobileContainerVariants} + initial="initial" + animate="animate" + exit="exit" > {navList.map((nav, index) => ( { setActive(false); }} @@ -168,4 +130,85 @@ function NavBar({ options }: NavProps) { ); } +// nav bar animation, fades in and then animates the children +const containerVariants: Variants = { + initial: { + opacity: 1, + }, + animate: { + opacity: 1, + transition: { + duration: 2, + delayChildren: 0.5, + staggerChildren: 0.25, + }, + }, +}; + +// default animation for nav bar items +const itemVariants: Variants = { + initial: { + opacity: 0, + x: 100, + }, + animate: { + opacity: 1, + x: 0, + }, +}; + +// logo animation +const logoContainerVariants: Variants = { + initial: { + scale: 1, + rotate: 0, + }, + animate: { + scale: 1, + rotate: 360, + transition: { + duration: 4, + type: "spring", + stiffness: 20, + }, + }, +}; + +// mobile nav bar container animation +const mobileContainerVariants: Variants = { + initial: { + height: 0, + }, + animate: { + height: "100vh", + transition: { + duration: 0.5, + staggerChildren: 0.15, + }, + }, + exit: { + height: 0, + transition: { + duration: 0.3, + }, + }, +}; + +// mobile nav bar item animation +const mobileItemVariants: Variants = { + initial: { + opacity: 0, + y: -150, + }, + animate: { + opacity: 1, + y: 0, + transition: { + duration: 0.7, + type: "spring", + bounce: 0.3, + }, + }, +}; + export default NavBar; diff --git a/layouts/HomeLayout.tsx b/layouts/HomeLayout.tsx index 8d87cff..8273c0f 100644 --- a/layouts/HomeLayout.tsx +++ b/layouts/HomeLayout.tsx @@ -1,6 +1,12 @@ // Layout/container used for the main mostly empty landing page, can be used for related pages (credits, about, etc.) -import { AnimatePresence, domAnimation, LazyMotion, m } from "framer-motion"; +import { + AnimatePresence, + domAnimation, + LazyMotion, + m, + Variants, +} from "framer-motion"; import Head from "next/head"; import { useRouter } from "next/router"; import NavBar from "../components/common/NavBar"; @@ -44,9 +50,10 @@ function HomeLayout(props: HomeLayoutProps) { {props.children} @@ -56,4 +63,10 @@ function HomeLayout(props: HomeLayoutProps) { ); } +const containerVariants: Variants = { + initial: { opacity: 0 }, + animate: { opacity: 1 }, + exit: { opacity: 0 }, +}; + export default HomeLayout; diff --git a/layouts/NavTemplates.tsx b/layouts/NavTemplates.tsx index 612c26c..c15c51e 100644 --- a/layouts/NavTemplates.tsx +++ b/layouts/NavTemplates.tsx @@ -12,21 +12,10 @@ const DefaultNavOption = ({ return (

{label} @@ -36,6 +25,24 @@ const DefaultNavOption = ({ ); }; +const defaultNavVariants = { + initial: { + scale: 1, + }, + whileHover: { + scale: 1.05, + transition: { + duration: 0.2, + }, + }, + whileTap: { + scale: 0.95, + transition: { + duration: 0.2, + }, + }, +}; + interface NavTemplate { content: ReactComponentElement | ReactElement; } diff --git a/pages/index.tsx b/pages/index.tsx index c90faec..b0866bc 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -84,46 +84,34 @@ const Home: NextPageWithLayout = () => {

- Buy high - Sell low +

Buy high

+
+ +

Sell low

...or something like that
{slideShow} @@ -133,6 +121,60 @@ const Home: NextPageWithLayout = () => { ); }; +const sloganContainerVariants = { + initial: { + opacity: 0, + y: -100, + }, + animate: { + opacity: 1, + y: 0, + transition: { + delay: 0.5, + duration: 2.5, + type: "spring", + bounce: 0.5, + stiffness: 150, + delayChildren: 0.5, + staggerChildren: 1.0, + }, + }, +}; + +const sloganHeaderVariants = { + initial: { + opacity: 0, + }, + animate: { + opacity: 1, + }, +}; + +const sloganSecondaryVariants = { + initial: { + opacity: 0, + }, + animate: { + opacity: 1, + transition: { + delay: 3.5, + }, + }, +}; + +const slideShowVariants = { + initial: { + opacity: 0, + }, + animate: { + opacity: 1, + transition: { + delay: 2.0, + duration: 1.0, + }, + }, +}; + // set the layout for the page, this is used to wrap the page in a layout Home.getLayout = function getLayout(page: ReactElement) { return {page}; diff --git a/pages/team.tsx b/pages/team.tsx index d65c784..17b023f 100644 --- a/pages/team.tsx +++ b/pages/team.tsx @@ -14,29 +14,13 @@ function Team() {
people @@ -104,6 +88,9 @@ const containerVariants: Variants = { duration: 2, delayChildren: 0.5, staggerChildren: 0.25, + type: "spring", + bounce: 0.5, + stiffness: 80, }, }, }; @@ -130,6 +117,24 @@ const rightCardVariants: Variants = { }, }; +const headerVariants: Variants = { + initial: { + opacity: 0, + y: 100, + }, + animate: { + opacity: 1, + y: 0, + transition: { + delay: 0.5, + duration: 1.0, + type: "spring", + bounce: 0.5, + stiffness: 80, + }, + }, +}; + Team.getLayout = function getLayout(page: ReactElement) { return {page}; };