Skip to content

Commit 77ea1c0

Browse files
authored
Merge pull request #19 from apsinghdev/fix/loading
Fix/loading
2 parents f99b39d + d88786c commit 77ea1c0

File tree

4 files changed

+204
-9
lines changed

4 files changed

+204
-9
lines changed

apps/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"@vercel/speed-insights": "^1.1.0",
2424
"class-variance-authority": "^0.7.0",
2525
"clsx": "^2.1.1",
26-
"framer-motion": "^11.11.13",
26+
"framer-motion": "^11.15.0",
2727
"lucide-react": "^0.456.0",
2828
"next": "15.0.2",
2929
"next-themes": "^0.4.3",

apps/web/src/app/(main)/(landing)/page.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { GlowingBtn } from "@/components/ui/GlowingBtn";
55
import { useRouter } from "next/navigation";
66
import { QueryCount } from "@/components/landing-page/QueryCount";
77
import { useEffect } from "react";
8+
import { TypewriterEffect } from "@/components/ui/typewriter-effect";
89

910
export default function Home() {
1011
const router = useRouter();
@@ -22,15 +23,26 @@ export default function Home() {
2223
};
2324

2425
return (
25-
<main className="relative w-full min-h-screen overflow-y-auto overflow-x-hidden scroll-smooth">
26+
<main className="relative w-full min-h-screen overflow-y-auto overflow-x-hidden scroll-">
2627
<section className="min-h-screen w-full flex flex-col justify-center items-center text-center px-4 md:mb-12">
2728
<div className="space-y-8 max-w-2xl">
2829
<h1 className="text-5xl lg:text-7xl font-extrabold font-sans">
2930
Opensox
3031
</h1>
31-
<p className="text-xs lg:text-base lg:font-medium font-medium text-ox-purple">
32-
Find the perfect open-source project to contribute.
33-
</p>
32+
{/* <p className="text-xs lg:text-base lg:font-medium font-medium text-ox-purple"> */}
33+
<TypewriterEffect
34+
words={[
35+
{ text: "Find" },
36+
{ text: "the" },
37+
{ text: "perfect" },
38+
{ text: "open" },
39+
{ text: "source" },
40+
{ text: "projects" },
41+
{ text: "to" },
42+
{ text: "contribute." },
43+
]}
44+
></TypewriterEffect>
45+
{/* </p> */}
3446
<GlowingBtn text="Get started" handleClick={getStartedHandler} />
3547
</div>
3648
</section>
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
"use client";
2+
3+
import { cn } from "@/lib/utils";
4+
import { motion, stagger, useAnimate, useInView } from "framer-motion";
5+
import { useEffect } from "react";
6+
7+
export const TypewriterEffect = ({
8+
words,
9+
className,
10+
}: {
11+
words: {
12+
text: string;
13+
className?: string;
14+
}[];
15+
className?: string;
16+
}) => {
17+
// split text inside of words into array of characters
18+
const wordsArray = words.map((word) => {
19+
return {
20+
...word,
21+
text: word.text.split(""),
22+
};
23+
});
24+
25+
const [scope, animate] = useAnimate();
26+
const isInView = useInView(scope);
27+
useEffect(() => {
28+
if (isInView) {
29+
animate(
30+
"span",
31+
{
32+
display: "inline-block",
33+
opacity: 1,
34+
width: "fit-content",
35+
},
36+
{
37+
duration: 0.3,
38+
delay: stagger(0.1),
39+
ease: "easeInOut",
40+
}
41+
);
42+
}
43+
}, [isInView, animate]);
44+
45+
const renderWords = () => {
46+
return (
47+
<motion.div ref={scope} className="inline">
48+
{wordsArray.map((word, idx) => {
49+
return (
50+
<div key={`word-${idx}`} className="inline-block">
51+
{word.text.map((char, index) => (
52+
<motion.span
53+
initial={{}}
54+
key={`char-${index}`}
55+
className={cn(
56+
`text-ox-purple opacity-0 hidden`,
57+
word.className
58+
)}
59+
>
60+
{char}
61+
</motion.span>
62+
))}
63+
&nbsp;
64+
</div>
65+
);
66+
})}
67+
</motion.div>
68+
);
69+
};
70+
return (
71+
<div
72+
className={cn(
73+
"text-xs lg:text-base lg:font-medium font-medium text-ox-purple text-center",
74+
className
75+
)}
76+
>
77+
{renderWords()}
78+
{/* <motion.span
79+
initial={{
80+
opacity: 0,
81+
}}
82+
animate={{
83+
opacity: 1,
84+
}}
85+
transition={{
86+
duration: 0.8,
87+
repeat: Infinity,
88+
repeatType: "reverse",
89+
}}
90+
className={cn(
91+
"inline-block rounded-sm w-[4px] h-4 md:h-6 lg:h-10 bg-blue-500",
92+
)}
93+
></motion.span> */}
94+
</div>
95+
);
96+
};
97+
98+
export const TypewriterEffectSmooth = ({
99+
words,
100+
className,
101+
}: {
102+
words: {
103+
text: string;
104+
className?: string;
105+
}[];
106+
className?: string;
107+
}) => {
108+
// split text inside of words into array of characters
109+
const wordsArray = words.map((word) => {
110+
return {
111+
...word,
112+
text: word.text.split(""),
113+
};
114+
});
115+
const renderWords = () => {
116+
return (
117+
<div>
118+
{wordsArray.map((word, idx) => {
119+
return (
120+
<div key={`word-${idx}`} className="inline-block">
121+
{word.text.map((char, index) => (
122+
<span
123+
key={`char-${index}`}
124+
className={cn(`text-ox-purple`, word.className)}
125+
>
126+
{char}
127+
</span>
128+
))}
129+
&nbsp;
130+
</div>
131+
);
132+
})}
133+
</div>
134+
);
135+
};
136+
137+
return (
138+
<div className={cn("flex space-x-1 my-6", className)}>
139+
<motion.div
140+
className="overflow-hidden pb-2"
141+
whileInView={{
142+
width: "fit-content",
143+
opacity: 1,
144+
}}
145+
initial={{
146+
width: "0%",
147+
opacity: 0,
148+
}}
149+
transition={{
150+
duration: 2,
151+
ease: "linear",
152+
delay: 1,
153+
}}
154+
>
155+
<div
156+
className="text-xs lg:text-base lg:font-medium font-medium text-ox-purple text-center"
157+
style={{
158+
whiteSpace: "nowrap",
159+
}}
160+
>
161+
{renderWords()}{" "}
162+
</div>{" "}
163+
</motion.div>
164+
{/* <motion.span
165+
initial={{
166+
opacity: 0,
167+
}}
168+
animate={{
169+
opacity: 1,
170+
}}
171+
transition={{
172+
duration: 0.8,
173+
174+
repeat: Infinity,
175+
repeatType: "reverse",
176+
}}
177+
className={cn(
178+
"block rounded-sm w-[4px] h-4 sm:h-6 xl:h-12 bg-blue-500"
179+
)}
180+
></motion.span> */}
181+
</div>
182+
);
183+
};

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)