Skip to content

Commit

Permalink
refactor: hero circle lines animation with gsap
Browse files Browse the repository at this point in the history
  • Loading branch information
devshinthant committed Jul 4, 2024
1 parent 230f607 commit 89c695d
Show file tree
Hide file tree
Showing 14 changed files with 522 additions and 160 deletions.
File renamed without changes.
37 changes: 1 addition & 36 deletions app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -147,45 +147,10 @@
transition: transform 0.25s ease-out;
}

.nav_btn {
@apply relative inline-block h-[34px] w-[100px] overflow-hidden border-[0.01px] border-gray-800;
transition: 0.5s;
}

.nav_btn:hover {
border: 0;
background-color: hsl(var(--accent-color));
box-shadow:
0 0 5px hsl(var(--accent-color)),
0 0 25px hsl(var(--accent-color)),
0 0 50px hsl(var(--accent-color)),
0 0 200px hsl(var(--accent-color));
.webkit-reflect {
-webkit-box-reflect: below 1px linear-gradient(transparent, #0005);
}

.nav_btn_line_1 {
@apply absolute left-0 top-0 h-[1px] w-full animate-animate-nav-btn-line-1;
background: linear-gradient(90deg, transparent, hsl(var(--accent-color)));
}

.nav_btn_line_2 {
@apply absolute right-0 top-[-100%] h-full w-[1px] animate-animate-nav-btn-line-2;
animation-delay: 0.5s;
background: linear-gradient(180deg, transparent, hsl(var(--accent-color)));
}

.nav_btn_line_3 {
@apply absolute bottom-0 right-[-100%] h-[1px] w-full animate-animate-nav-btn-line-3;
animation-delay: 1s;
background: linear-gradient(270deg, transparent, hsl(var(--accent-color)));
}

.nav_btn_line_4 {
@apply absolute bottom-[-100%] left-0 h-full w-[1px] animate-animate-nav-btn-line-4;
animation-delay: 1.5s;
background: linear-gradient(360deg, transparent, hsl(var(--accent-color)));
}

.contact_me_btn {
background-image: radial-gradient(
circle at 50% 85.69%,
Expand Down
27 changes: 27 additions & 0 deletions components/LazyLottie.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Suspense, lazy } from "react"
import { type LottieComponentProps } from "lottie-react"
import { Skeleton } from "./ui/skeleton"

const LazyLottieComponent = lazy(() => import("lottie-react"))

interface LottieProps<T extends Record<string, unknown>> {
getAnimationData: () => Promise<T>
id: string
}

export function LazyLottie<T extends Record<string, unknown>>({
getAnimationData,
id,
ref,
...props
}: LottieProps<T> & Omit<LottieComponentProps, "animationData">) {
const data = getAnimationData()

if (!data) return <Skeleton />

return (
<Suspense fallback={<Skeleton />}>
<LazyLottieComponent animationData={data} {...props} />
</Suspense>
)
}
89 changes: 89 additions & 0 deletions components/ResumeBtn.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
"use client"

import { useEffect, useRef } from "react"
import { gsap } from "gsap"

export default function ResumeBtn() {
const topTween = useRef(null)
const rightTween = useRef(null)
const bottomTween = useRef(null)
const leftTween = useRef(null)

useEffect(() => {
if (topTween && rightTween && bottomTween && leftTween) {
gsap.fromTo(
topTween.current,
{
left: "-100%",
},
{
left: "100%",
repeat: -1,
duration: 2,
}
)
gsap.fromTo(
rightTween.current,
{
top: "-100%",
},
{
top: "100%",
delay: 0.5,
repeat: -1,
duration: 2,
}
)

gsap.fromTo(
bottomTween.current,
{
right: "-100%",
},
{
right: "100%",
delay: 1,
repeat: -1,
duration: 2,
}
)

gsap.fromTo(
leftTween.current,
{
bottom: "-100%",
},
{
bottom: "100%",
delay: 1.5,
repeat: -1,
duration: 2,
}
)
}
}, [])

return (
<button className="group hidden duration-150 md:block relative h-[34px] w-[100px] overflow-hidden border-[.01px] border-gray-800 hover:border-none hover:bg-accentColor hover:shadow-resume_btn_shadow hover:webkit-reflect">
<div
ref={topTween}
className="absolute left-[-100px] top-0 h-[1px] w-full bg-[linear-gradient(90deg,transparent,hsl(var(--accent-color)))]"
/>
<span
ref={rightTween}
className="absolute right-0 top-[-100%] h-full w-[1px] bg-[linear-gradient(180deg,transparent,hsl(var(--accent-color)))]"
/>
<span
ref={bottomTween}
className="absolute bottom-0 right-[-100%] h-[1px] w-full bg-[linear-gradient(270deg,transparent,hsl(var(--accent-color)))]"
/>
<span
ref={leftTween}
className="absolute bottom-[-100%] left-0 h-full w-[1px] bg-[linear-gradient(360deg,transparent,hsl(var(--accent-color)))]"
/>
<div className="text-xs group-hover:text-white text-accentColor dark:text-gray-300">
Resume
</div>
</button>
)
}
61 changes: 45 additions & 16 deletions components/SocialLinks.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,52 @@
import { ArrowDownIcon, ArrowRightIcon } from "@radix-ui/react-icons"
import { ArrowDown2, Mouse } from "iconsax-react"
import Link from "next/link"

export default function SocialLinks() {
return (
<>
<div className="flex flex-col gap-6 items-center">
{socialLinks.map((link) => (
<Link
key={link.id}
title={link.title}
href={link.link}
className="scale-110 rounded link-outline"
>
{link.svg}
</Link>
))}
<div className="absolute right-4 bottom-[20%]">
<div className="flex flex-col gap-6 items-center">
{socialLinks.map((link) => (
<Link
key={link.id}
title={link.title}
href={link.link}
className="scale-110 rounded link-outline"
>
{link.svg}
</Link>
))}
</div>
</div>

<div className="absolute bottom-4 left-4">
<div
style={{
writingMode: "vertical-lr",
}}
className="flex items-center gap-2 dark:text-gray-400"
>
<span className="text-sm tracking-widest">About</span>
<ArrowDownIcon />
</div>
</div>

<div className="absolute bottom-4 right-4">
<Link
href="#project"
className="flex items-center gap-2 dark:text-gray-400"
>
<span className="text-sm tracking-widest">View Project</span>
<ArrowRightIcon />
</Link>
</div>

<div className="absolute animate-bounce text-white hover:text-accentColor cursor-pointer bottom-4 left-[50%] translate-x-[-50%,-50%]">
<div className="flex flex-col gap-1 items-center">
<Mouse />
<ArrowDown2 size={12} />
</div>
</div>
</>
)
Expand All @@ -31,11 +64,7 @@ const socialLinks = [
height="24"
className="dark:fill-gray-400 hover:fill-accentColor dark:hover:fill-accentColor"
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M12.026 2c-5.509 0-9.974 4.465-9.974 9.974 0 4.406 2.857 8.145 6.821 9.465.499.09.679-.217.679-.481 0-.237-.008-.865-.011-1.696-2.775.602-3.361-1.338-3.361-1.338-.452-1.152-1.107-1.459-1.107-1.459-.905-.619.069-.605.069-.605 1.002.07 1.527 1.028 1.527 1.028.89 1.524 2.336 1.084 2.902.829.091-.645.351-1.085.635-1.334-2.214-.251-4.542-1.107-4.542-4.93 0-1.087.389-1.979 1.024-2.675-.101-.253-.446-1.268.099-2.64 0 0 .837-.269 2.742 1.021a9.582 9.582 0 0 1 2.496-.336 9.554 9.554 0 0 1 2.496.336c1.906-1.291 2.742-1.021 2.742-1.021.545 1.372.203 2.387.099 2.64.64.696 1.024 1.587 1.024 2.675 0 3.833-2.33 4.675-4.552 4.922.355.308.675.916.675 1.846 0 1.334-.012 2.41-.012 2.737 0 .267.178.577.687.479C19.146 20.115 22 16.379 22 11.974 22 6.465 17.535 2 12.026 2z"
></path>
<path d="M12.026 2c-5.509 0-9.974 4.465-9.974 9.974 0 4.406 2.857 8.145 6.821 9.465.499.09.679-.217.679-.481 0-.237-.008-.865-.011-1.696-2.775.602-3.361-1.338-3.361-1.338-.452-1.152-1.107-1.459-1.107-1.459-.905-.619.069-.605.069-.605 1.002.07 1.527 1.028 1.527 1.028.89 1.524 2.336 1.084 2.902.829.091-.645.351-1.085.635-1.334-2.214-.251-4.542-1.107-4.542-4.93 0-1.087.389-1.979 1.024-2.675-.101-.253-.446-1.268.099-2.64 0 0 .837-.269 2.742 1.021a9.582 9.582 0 0 1 2.496-.336 9.554 9.554 0 0 1 2.496.336c1.906-1.291 2.742-1.021 2.742-1.021.545 1.372.203 2.387.099 2.64.64.696 1.024 1.587 1.024 2.675 0 3.833-2.33 4.675-4.552 4.922.355.308.675.916.675 1.846 0 1.334-.012 2.41-.012 2.737 0 .267.178.577.687.479C19.146 20.115 22 16.379 22 11.974 22 6.465 17.535 2 12.026 2z"></path>
</svg>
),
},
Expand Down
11 changes: 2 additions & 9 deletions components/layouts/header.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import navlinks from "@/lib/navConfig"
import Link from "next/link"
import ResumeBtn from "../ResumeBtn"
import ThemeSwitch from "../ThemeSwitch"

export default function Header() {
Expand All @@ -25,15 +26,7 @@ export default function Header() {
</div>
</div>
<div className="col-span-4 flex justify-end gap-10">
<button className="nav_btn group hidden md:block">
<span className="nav_btn_line_1" />
<span className="nav_btn_line_2" />
<span className="nav_btn_line_3" />
<span className="nav_btn_line_4" />
<div className="text-xs group-hover:text-white text-accentColor dark:text-gray-300">
Resume
</div>
</button>
<ResumeBtn />
<ThemeSwitch />
</div>
</div>
Expand Down
41 changes: 41 additions & 0 deletions components/sections/HeroContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { ArrowRightIcon } from "@radix-ui/react-icons"
import { Button } from "../ui/button"

export default function HeroContent() {
return (
<div className="relative max-w-[55rem] mt-[11rem] m-auto w-full flex flex-col gap-4 justify-center items-center">
<div className="bg-[linear-gradient(#fff,rgba(255,255,255,.6))] inline-block text-transparent bg-clip-text leading-none text-6xl font-semibold">
It&apos;s Shinn Thant
</div>
<div className="text-4xl font-semibold">
<span className="bg-[linear-gradient(#fff,rgba(255,255,255,.6))] inline-block text-transparent bg-clip-text">
A
</span>{" "}
<span className="text-accentColor">Front-End</span>{" "}
<span className="bg-[linear-gradient(#fff,rgba(255,255,255,.6))] inline-block text-transparent bg-clip-text">
Developer
</span>
</div>
<div className="w-[370px] text-sm bg-[linear-gradient(#fff,rgba(255,255,255,.6))] inline-block text-transparent bg-clip-text">
Passionate and detail-oriented frontend developer with a knack for
creating visually appealing and user-friendly web interfaces
</div>

<div className="bg-[linear-gradient(#fff,rgba(255,255,255,.6))] inline-block text-transparent bg-clip-text text-lg">
Where creativity meets functionality.
</div>

<Button className="contact_me_btn shadow-md mt-3 group flex items-center gap-2">
<div className="dark:text-black relative z-[3]">Contact Me</div>
<div className="contact_me_btn_overlay group-hover:opacity-100" />

<div className="relative group overflow-hidden w-4 z-[3]">
<div className="flex group-hover:animate-animate-frame-contact-me-btn-icon translate-x-[-100%]">
<ArrowRightIcon className="text-black flex-none relative z-[3]" />
<ArrowRightIcon className="text-black flex-none relative z-[3]" />
</div>
</div>
</Button>
</div>
)
}
13 changes: 13 additions & 0 deletions components/sections/HeroLottie.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { LazyLottie } from "../LazyLottie"

export default function HeroLottie() {
return (
<div className="absolute hidden md:block left-[-50px] top-[-14px] rotate-270">
<LazyLottie
getAnimationData={() => import("@/app/assets/lottie/hero-lottie.json")}
loop
id="hero-lottie"
/>
</div>
)
}
Loading

0 comments on commit 89c695d

Please sign in to comment.