Skip to content

Commit 45b9f38

Browse files
committed
Refactor Hero to enhance responsiveness
1 parent c19a1eb commit 45b9f38

File tree

1 file changed

+20
-94
lines changed

1 file changed

+20
-94
lines changed

components/hero/Hero.tsx

Lines changed: 20 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -13,118 +13,48 @@ import PeopleGroupIcon from "@/components/icons/people-group";
1313
import { Button } from "@/components/ui/button";
1414

1515
export default function Hero() {
16-
const { ref: bgRef, inView: bgInView } = useInView({ triggerOnce: false, threshold: 0.1 });
16+
const { ref: bgRef, inView: bgInView } = useInView({ threshold: 0.1 });
1717
const bgControls = useAnimation();
1818

1919
const handleBgAnimation = useCallback(() => {
20-
if (bgInView) bgControls.start({ opacity: 1, y: 0 });
21-
else bgControls.start({ opacity: 0, y: 20 });
20+
bgControls.start(bgInView ? { opacity: 1, y: 0 } : { opacity: 0, y: 20 });
2221
}, [bgInView, bgControls]);
2322

2423
useEffect(() => {
2524
handleBgAnimation();
2625
}, [handleBgAnimation]);
2726

28-
const { ref: transRef, inView: transInView } = useInView({ triggerOnce: false, threshold: 0.1 });
27+
const { ref: transRef, inView: transInView } = useInView({ threshold: 0.1 });
2928

3029
return (
3130
<div className="relative overflow-hidden">
32-
{/* Animated Blue Blob - Top Right */}
3331
<motion.div
34-
className="absolute -right-20 -top-20 h-64 w-64 rounded-full bg-gradient-to-br from-blue-400/20 to-blue-600/15 blur-3xl"
32+
className="absolute -right-20 -top-20 h-56 w-56 rounded-full bg-gradient-to-br from-blue-400/20 to-blue-600/15 blur-3xl sm:h-64 sm:w-64"
3533
animate={{
3634
x: [0, 15, -10, 20, 0],
3735
y: [0, -12, 18, -8, 0],
3836
scale: [1, 1.1, 0.95, 1.05, 1],
3937
}}
40-
transition={{
41-
duration: 25,
42-
repeat: Infinity,
43-
ease: "easeInOut",
44-
}}
45-
/>
46-
47-
{/* Animated Blue Blob - Top Left */}
48-
<motion.div
49-
className="absolute -left-32 -top-32 h-80 w-80 rounded-full bg-gradient-to-br from-blue-500/15 to-blue-700/10 blur-3xl"
50-
animate={{
51-
x: [0, -20, 10, -30, 0],
52-
y: [0, 15, -10, 22, 0],
53-
scale: [1, 0.95, 1.1, 0.9, 1],
54-
}}
55-
transition={{
56-
duration: 30,
57-
repeat: Infinity,
58-
ease: "easeInOut",
59-
delay: 5,
60-
}}
61-
/>
62-
63-
{/* Animated Blue Blob - Bottom Left */}
64-
<motion.div
65-
className="from-blue-300/18 to-blue-500/12 absolute -bottom-24 -left-16 h-72 w-72 rounded-full bg-gradient-to-br blur-3xl"
66-
animate={{
67-
x: [0, 25, -15, 35, 0],
68-
y: [0, -20, 12, -30, 0],
69-
scale: [1, 1.15, 0.9, 1.1, 1],
70-
}}
71-
transition={{
72-
duration: 28,
73-
repeat: Infinity,
74-
ease: "easeInOut",
75-
delay: 10,
76-
}}
77-
/>
78-
79-
{/* Animated Blue Blob - Bottom Right */}
80-
<motion.div
81-
className="from-blue-400/18 to-blue-600/12 absolute -bottom-20 -right-16 h-56 w-56 rounded-full bg-gradient-to-br blur-3xl"
82-
animate={{
83-
x: [0, -18, 12, -25, 0],
84-
y: [0, 22, -15, 30, 0],
85-
scale: [1, 0.9, 1.2, 0.95, 1],
86-
}}
87-
transition={{
88-
duration: 26,
89-
repeat: Infinity,
90-
ease: "easeInOut",
91-
delay: 15,
92-
}}
93-
/>
94-
95-
{/* Animated Blue Blob - Center */}
96-
<motion.div
97-
className="absolute left-1/4 top-1/2 h-48 w-48 -translate-y-1/2 rounded-full bg-gradient-to-br from-blue-300/15 to-blue-500/10 blur-2xl"
98-
animate={{
99-
x: [0, 30, -20, 40, 0],
100-
y: [0, -15, 25, -10, 0],
101-
scale: [1, 1.1, 0.9, 1.05, 1],
102-
}}
103-
transition={{
104-
duration: 32,
105-
repeat: Infinity,
106-
ease: "easeInOut",
107-
delay: 20,
108-
}}
38+
transition={{ duration: 25, repeat: Infinity, ease: "easeInOut" }}
10939
/>
11040

11141
<AnimatedSection
112-
className="relative mx-auto max-w-screen-xl px-6 pb-24 pt-60 lg:flex lg:items-center lg:justify-between lg:gap-12"
42+
className="relative mx-auto max-w-screen-xl px-5 pb-24 pt-72 sm:px-8 sm:pb-28 sm:pt-52 md:pt-60 lg:flex lg:items-center lg:justify-between lg:gap-12"
11343
animationType="fade"
11444
aria-labelledby="hero-heading"
11545
>
11646
<div className="flex flex-col items-center text-center lg:flex-1 lg:items-start lg:text-left">
11747
<AnimatedElement
11848
as="div"
119-
className="mb-6 flex flex-wrap items-center justify-center gap-3 lg:justify-start"
49+
className="mb-5 flex flex-wrap items-center justify-center gap-3 lg:justify-start"
12050
animationType="fadeDown"
12151
delay={0.05}
12252
>
123-
<span className="inline-flex items-center gap-1.5 rounded-full bg-blue-100/80 px-4 py-1.5 text-xs font-semibold text-blue-700 ring-1 ring-inset ring-blue-600/20 dark:bg-blue-950 dark:text-blue-300 dark:ring-blue-400/30">
53+
<span className="inline-flex items-center gap-1.5 rounded-full bg-blue-100/80 px-3 py-1 text-xs font-semibold text-blue-700 ring-1 ring-inset ring-blue-600/20 dark:bg-blue-950 dark:text-blue-300 dark:ring-blue-400/30">
12454
<CheckCircle className="h-3.5 w-3.5" />
12555
Open Source
12656
</span>
127-
<span className="inline-flex items-center gap-1.5 rounded-full bg-blue-200/70 px-4 py-1.5 text-xs font-semibold text-blue-800 ring-1 ring-inset ring-blue-700/20 dark:bg-blue-950 dark:text-blue-300 dark:ring-blue-400/30">
57+
<span className="inline-flex items-center gap-1.5 rounded-full bg-blue-200/70 px-3 py-1 text-xs font-semibold text-blue-800 ring-1 ring-inset ring-blue-700/20 dark:bg-blue-950 dark:text-blue-300 dark:ring-blue-400/30">
12858
<Users className="h-3.5 w-3.5" />
12959
40+ Contributors
13060
</span>
@@ -133,7 +63,7 @@ export default function Hero() {
13363
<AnimatedElement
13464
as="h1"
13565
id="hero-heading"
136-
className="max-w-2xl whitespace-nowrap text-5xl font-bold leading-tight tracking-tight md:text-6xl lg:text-7xl"
66+
className="max-w-2xl break-words text-4xl font-bold leading-tight tracking-tight sm:text-5xl md:text-6xl lg:text-7xl"
13767
animationType="fadeDown"
13868
delay={0.1}
13969
>
@@ -144,18 +74,18 @@ export default function Hero() {
14474

14575
<AnimatedElement
14676
as="p"
147-
className="mt-6 max-w-2xl text-lg text-gray-600 dark:text-gray-300 md:text-xl lg:text-2xl"
77+
className="mt-5 max-w-2xl text-base text-gray-600 dark:text-gray-300 sm:text-lg md:text-xl"
14878
animationType="fadeUp"
14979
delay={0.2}
15080
>
15181
Building the future with{" "}
15282
<span className="font-semibold text-blue-600 dark:text-blue-400">open source</span>.
153-
<br />
83+
<br className="hidden sm:block" />
15484
Join our community of passionate developers.
15585
</AnimatedElement>
15686

15787
<AnimatedContainer
158-
className="mt-10 flex flex-col gap-4 sm:flex-row sm:gap-4"
88+
className="mt-8 flex w-full flex-col gap-3 sm:flex-row sm:justify-center lg:justify-start"
15989
staggerDelay={0.1}
16090
delay={0.3}
16191
>
@@ -164,7 +94,7 @@ export default function Hero() {
16494
<motion.div ref={bgRef} animate={bgControls} initial={{ opacity: 0, y: 20 }}>
16595
<Button
16696
variant="primary"
167-
className="flex items-center gap-2"
97+
className="w-full sm:w-auto flex items-center justify-center gap-2"
16898
leftIcon={<PeopleGroupIcon className="h-5 w-5" />}
16999
>
170100
See our team!
@@ -183,7 +113,7 @@ export default function Hero() {
183113
>
184114
<Button
185115
variant="outline"
186-
className="group flex items-center gap-2"
116+
className="w-full sm:w-auto group flex items-center justify-center gap-2"
187117
rightIcon={
188118
<ArrowForwardHeroIcon className="h-4 w-4 transition-transform group-hover:translate-x-1" />
189119
}
@@ -195,14 +125,10 @@ export default function Hero() {
195125
</AnimatedElement>
196126

197127
<AnimatedElement as="div" animationType="fadeRight" interactive>
198-
<Link
199-
href="https://github.com/EternalCodeTeam"
200-
target="_blank"
201-
rel="noopener noreferrer"
202-
>
128+
<Link href="https://github.com/EternalCodeTeam" target="_blank" rel="noopener noreferrer">
203129
<Button
204130
variant="outline"
205-
className="flex items-center gap-2"
131+
className="w-full sm:w-auto flex items-center justify-center gap-2"
206132
leftIcon={<Github className="h-4 w-4" />}
207133
>
208134
GitHub
@@ -213,7 +139,7 @@ export default function Hero() {
213139

214140
<AnimatedElement
215141
as="div"
216-
className="mt-12 flex flex-wrap items-center justify-center gap-8 text-sm lg:justify-start"
142+
className="mt-10 flex flex-wrap items-center justify-center gap-5 text-sm lg:justify-start"
217143
animationType="fadeUp"
218144
delay={0.4}
219145
>
@@ -234,11 +160,11 @@ export default function Hero() {
234160

235161
<AnimatedElement
236162
as="div"
237-
className="mt-20 w-full lg:mt-0 lg:w-[52%] lg:flex-shrink-0"
163+
className="mt-20 w-full lg:mt-0 lg:w-[52%]"
238164
animationType="fadeLeft"
239165
delay={0.5}
240166
>
241-
<div className="relative">
167+
<div className="relative mx-auto max-w-md sm:max-w-lg md:max-w-xl">
242168
<Terminal />
243169
</div>
244170
</AnimatedElement>

0 commit comments

Comments
 (0)