diff --git a/src/slices/Hero/index.tsx b/src/slices/Hero/index.tsx index 46e9f22..4953931 100644 --- a/src/slices/Hero/index.tsx +++ b/src/slices/Hero/index.tsx @@ -1,11 +1,10 @@ "use client"; import { useEffect, useRef } from "react"; - import { Content, KeyTextField } from "@prismicio/client"; import { SliceComponentProps } from "@prismicio/react"; -import { gsap } from "gsap"; +import { Shapes } from "@/slices/Hero/Shapes"; import Bounded from "@/components/Bounded"; -import { Shapes } from "./Shapes"; +import gsap from "gsap"; /** * Props for `Hero`. @@ -16,56 +15,52 @@ export type HeroProps = SliceComponentProps; * Component for "Hero" Slices. */ const Hero = ({ slice }: HeroProps): JSX.Element => { - const components = useRef(null); + const component = useRef(null); useEffect(() => { let ctx = gsap.context(() => { - const tl = gsap.timeline(); - tl.fromTo( - ".name-animation", - { - x: -100, - opacity: 0, - rotate: -10, - }, - { - x: 0, - opacity: 1, - rotate: 0, - ease: "elastic.out(1,0.3)", - duration: 1, - transformOrigin: "left top", - delay: 0.5, - stagger: { - each: 0.1, - from: "random", + // create as many GSAP animations and/or ScrollTriggers here as you want... + gsap + .timeline() + .fromTo( + ".name-animation", + { x: -100, opacity: 0, rotate: -10 }, + { + x: 0, + opacity: 1, + rotate: 0, + + ease: "elastic.out(1,0.3)", + duration: 1, + transformOrigin: "left top", + stagger: { each: 0.1, from: "random" }, + }, + ) + .fromTo( + ".job-title", + { + y: 20, + opacity: 0, + scale: 1.2, + }, + { + opacity: 1, + y: 0, + duration: 1, + scale: 1, + ease: "elastic.out(1,0.3)", }, - } - ); - tl.fromTo( - ".job-title", - { - opacity: 0, - scale: 1.2, - }, - { - opacity: 1, - y: 0, - duration: 1, - scale: 1, - ease: "elastic.out(1,0.3)", - } - ); - }, components); - return () => ctx.revert(); + ); + }, component); + return () => ctx.revert(); // cleanup! }, []); const renderLetters = (name: KeyTextField, key: string) => { if (!name) return; return name.split("").map((letter, index) => ( {letter} @@ -76,25 +71,25 @@ const Hero = ({ slice }: HeroProps): JSX.Element => { -
+
-
+

- + {renderLetters(slice.primary.first_name, "first")} - + {renderLetters(slice.primary.last_name, "last")}

- + {slice.primary.tag_line}