Skip to content

Commit ad04678

Browse files
feat: pop animations
1 parent 8a03185 commit ad04678

File tree

6 files changed

+110
-40
lines changed

6 files changed

+110
-40
lines changed

src/components/animation/pop.tsx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React, { FC, ReactNode, useRef } from "react";
2+
import { motion, useInView } from "framer-motion";
3+
4+
const PopAnimation: FC<{
5+
className?: string;
6+
children: ReactNode;
7+
}> = ({ className, children }) => {
8+
const ref = useRef<HTMLDivElement>(null);
9+
const isInView = useInView(ref, { once: true });
10+
11+
return (
12+
<motion.div
13+
ref={ref}
14+
className={className}
15+
initial="hidden"
16+
animate={isInView ? "visible" : "hidden"}
17+
variants={{
18+
visible: {
19+
opacity: 1,
20+
scale: 1,
21+
transition: {
22+
type: "spring",
23+
damping: 12,
24+
stiffness: 100,
25+
},
26+
},
27+
hidden: {
28+
opacity: 0,
29+
scale: 0,
30+
transition: {
31+
type: "spring",
32+
damping: 12,
33+
stiffness: 100,
34+
},
35+
},
36+
}}
37+
>
38+
{children}
39+
</motion.div>
40+
);
41+
};
42+
43+
export default PopAnimation;

src/components/animation/typing.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,7 @@ export default function Typing() {
44
return (
55
<TypeAnimation
66
cursor={true}
7-
sequence={[
8-
"Jab We Meet",
9-
3000,
10-
"जब हम मिले",
11-
3000,
12-
"ジャブ・ウィー・メット",
13-
3000,
14-
]}
7+
sequence={["Jab We Meet", 3000, "जब हम मिले", 3000, "ಜಬ್ ವಿ ಮೆಟ್", 3000]}
158
wrapper="h2"
169
className="animated-text text-3xl font-semibold sm:text-3xl lg:text-3xl xl:text-5xl 2xl:text-6xl"
1710
repeat={Infinity}

src/components/features/index.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const Features = () => {
2+
return (
3+
<section >
4+
5+
6+
7+
</section>
8+
);
9+
};
10+
11+
export default Features;

src/components/join/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useRouter } from "next/router";
22
import { useState } from "react";
33
import { BsKeyboard } from "react-icons/bs";
4+
import CharacterAnimation from "../animation/character";
45

56
const JoinRoom = () => {
67
const [roomName, setRoomName] = useState<string>("");
@@ -28,7 +29,7 @@ const JoinRoom = () => {
2829
}`}
2930
onClick={() => router.push(`/rooms/${roomName}`)}
3031
>
31-
Join
32+
<CharacterAnimation text="Join" textStyle="text-sm"/>
3233
</button>
3334
</div>
3435
);

src/components/navbar/index.tsx

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { useState } from "react";
77
import { signIn, signOut } from "next-auth/react";
88
import { Session } from "next-auth";
99
import { FcGoogle } from "react-icons/fc";
10+
import PopAnimation from "../animation/pop";
1011

1112
const Navbar = ({
1213
status,
@@ -41,8 +42,19 @@ const Navbar = ({
4142
<div className="mx-auto max-w-5xl px-4">
4243
<div className="flex h-16 items-center justify-between">
4344
<Link href="/" className="flex items-center space-x-2">
44-
<Image src="/logo.png" alt="Logo" width={40} height={40} priority />
45-
<span className={`text-xl font-bold text-white`}>Jab We Meet</span>
45+
<PopAnimation>
46+
<Image
47+
src="/logo.png"
48+
alt="Logo"
49+
width={40}
50+
height={40}
51+
priority
52+
/>
53+
</PopAnimation>
54+
<CharacterAnimation
55+
text="Jab We Meet"
56+
textStyle="text-xl font-bold text-white"
57+
/>
4658
</Link>
4759

4860
<div className="hidden space-x-6 text-white lg:flex lg:items-center">
@@ -58,28 +70,32 @@ const Navbar = ({
5870
/>
5971
</Link>
6072
))}
61-
<button
62-
className="lk-button"
63-
onClick={() => {
64-
if (status === "authenticated") {
65-
signOut();
66-
} else {
67-
signIn("google");
68-
}
69-
}}
70-
>
71-
{status === "authenticated" ? (
72-
"Sign Out"
73-
) : (
74-
<div className="flex items-center space-x-2">
75-
<FcGoogle />
76-
<div>Sign In</div>
77-
</div>
78-
)}
79-
</button>
80-
<select className="lk-button">
81-
<option value="en">English</option>
82-
</select>
73+
<PopAnimation>
74+
<button
75+
className="lk-button"
76+
onClick={() => {
77+
if (status === "authenticated") {
78+
signOut();
79+
} else {
80+
signIn("google");
81+
}
82+
}}
83+
>
84+
{status === "authenticated" ? (
85+
"Sign Out"
86+
) : (
87+
<div className="flex items-center space-x-2">
88+
<FcGoogle />
89+
<div>Sign In</div>
90+
</div>
91+
)}
92+
</button>
93+
</PopAnimation>
94+
<PopAnimation>
95+
<select className="lk-button">
96+
<option value="en">English</option>
97+
</select>
98+
</PopAnimation>
8399
</div>
84100

85101
<div className="flex items-center space-x-4 lg:hidden">

src/pages/index.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { api } from "~/utils/api";
88
import { AiOutlineVideoCameraAdd } from "react-icons/ai";
99
import JoinRoom from "~/components/join";
1010
import Image from "next/image";
11+
import Features from "~/components/features";
12+
import CharacterAnimation from "~/components/animation/character";
1113

1214
function ConnectionTab() {
1315
const { data: session, status } = useSession();
@@ -25,7 +27,7 @@ function ConnectionTab() {
2527
<>
2628
<Navbar status={status} session={session} />
2729
<div className="isolate flex h-screen w-screen flex-col items-center justify-center space-y-4 p-5 text-center md:flex-row">
28-
<div className="absolute inset-x-0 top-[-10rem] -z-10 transform-gpu overflow-hidden blur-3xl sm:top-[-20rem] opacity-60">
30+
<div className="absolute inset-x-0 top-[-10rem] -z-10 transform-gpu overflow-hidden opacity-60 blur-3xl sm:top-[-20rem]">
2931
<svg
3032
className="relative left-[calc(50%-11rem)] -z-10 h-[21.1875rem] max-w-none -translate-x-1/2 rotate-[30deg] sm:left-[calc(50%-30rem)] sm:h-[42.375rem]"
3133
viewBox="0 0 1155 678"
@@ -52,22 +54,26 @@ function ConnectionTab() {
5254
</defs>
5355
</svg>
5456
</div>
55-
57+
5658
<div className="w-full max-w-md space-y-4">
5759
<Typing />
5860

59-
<p className="text-sm text-gray-400">
60-
Multilingual Video Conferencing App
61-
</p>
61+
<CharacterAnimation
62+
className="flex justify-center"
63+
textStyle="text-sm text-gray-400"
64+
text="Multilingual Video Conferencing App"
65+
/>
6266

6367
<div className="flex flex-col items-center space-y-4 lg:flex-row lg:space-y-0 lg:space-x-4">
6468
<button onClick={createRoomHandler} className="lk-button h-fit">
6569
<AiOutlineVideoCameraAdd />
66-
Create Room
70+
<CharacterAnimation text="Create Room" textStyle="text-sm" />
6771
</button>
6872

6973
<JoinRoom />
7074
</div>
75+
76+
<Features />
7177
</div>
7278

7379
<div className="flex w-full max-w-md items-center justify-center">
@@ -79,7 +85,7 @@ function ConnectionTab() {
7985
priority
8086
/>
8187
</div>
82-
<div className="absolute inset-x-0 top-[calc(100%-13rem)] -z-10 transform-gpu overflow-hidden blur-3xl sm:top-[calc(100%-30rem)] opacity-60">
88+
<div className="absolute inset-x-0 top-[calc(100%-13rem)] -z-10 transform-gpu overflow-hidden opacity-60 blur-3xl sm:top-[calc(100%-30rem)]">
8389
<svg
8490
className="relative left-[calc(50%+3rem)] h-[21.1875rem] max-w-none -translate-x-1/2 sm:left-[calc(50%+36rem)] sm:h-[42.375rem]"
8591
viewBox="0 0 1155 678"

0 commit comments

Comments
 (0)