Skip to content

Commit 6cd77b1

Browse files
committed
refactor: extract Hero animations to reusable AnimatedGlow component Replaced CSS keyframe animations with Framer Motion in both Landing and Home page Hero components. Created a shared AnimatedGlow component in utils for better code reusability and testing.
1 parent ffbf6f7 commit 6cd77b1

6 files changed

Lines changed: 45 additions & 66 deletions

File tree

frontend/src/components/HomeComponents/Hero/Hero.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { CopyButton } from './CopyButton';
33
import { ToastNotification } from './ToastNotification';
44
import { useState } from 'react';
55
import { Eye, EyeOff } from 'lucide-react';
6+
import { AnimatedGlow } from '@/components/utils/AnimatedGlow';
67

78
export const Hero = (props: Props) => {
89
const [showUuid, setShowUuid] = useState(true);
@@ -94,7 +95,13 @@ export const Hero = (props: Props) => {
9495
</div>
9596
</div>
9697

97-
<div className="shadow"></div>
98+
<AnimatedGlow
99+
className="absolute top-[200px] w-[260px] h-[400px] lg:top-[200px] lg:w-[260px] lg:h-[400px] md:top-[70px] md:w-[100px] md:h-[350px]"
100+
style={{
101+
rotate: '35deg',
102+
borderRadius: '24px',
103+
}}
104+
/>
98105

99106
<ToastNotification />
100107
</section>

frontend/src/components/HomeComponents/Hero/__tests__/__snapshots__/Hero.test.tsx.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ exports[`Hero component using snapshot renders correctly 1`] = `
167167
</div>
168168
</div>
169169
<div
170-
class="shadow"
170+
class="absolute top-[200px] w-[260px] h-[400px] lg:top-[200px] lg:w-[260px] lg:h-[400px] md:top-[70px] md:w-[100px] md:h-[350px]"
171+
style="filter: blur(150px); border-radius: 24px; transform: rotate(35deg);"
171172
/>
172173
<div
173174
data-testid="toast-notification"

frontend/src/components/LandingComponents/Hero/Hero.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Button } from '../../ui/button';
33
import { buttonVariants } from '../../ui/button';
44
import { HeroCards } from './HeroCards';
55
import { GitHubLogoIcon } from '@radix-ui/react-icons';
6+
import { AnimatedGlow } from '@/components/utils/AnimatedGlow';
67

78
export const Hero = () => {
89
return (
@@ -51,7 +52,7 @@ export const Hero = () => {
5152
<HeroCards />
5253
</div>
5354

54-
<div className="shadow"></div>
55+
<AnimatedGlow className="absolute top-[200px] w-[300px] h-[400px] lg:w-[400px] lg:h-[400px] md:top-[150px] md:w-[200px] md:h-[300px]" />
5556
</section>
5657
);
5758
};

frontend/src/components/LandingComponents/Hero/__tests__/__snapshots__/Hero.test.tsx.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ exports[`Hero component using snapshot renders correctly 1`] = `
8484
</div>
8585
</div>
8686
<div
87-
class="shadow"
87+
class="absolute top-[200px] w-[300px] h-[400px] lg:w-[400px] lg:h-[400px] md:top-[150px] md:w-[200px] md:h-[300px]"
88+
style="filter: blur(150px);"
8889
/>
8990
</section>
9091
</DocumentFragment>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { motion } from 'framer-motion';
2+
3+
interface AnimatedGlowProps {
4+
className?: string;
5+
style?: React.CSSProperties;
6+
}
7+
8+
export const AnimatedGlow = ({ className, style }: AnimatedGlowProps) => {
9+
return (
10+
<motion.div
11+
className={className}
12+
style={{
13+
filter: 'blur(150px)',
14+
...style,
15+
}}
16+
animate={{
17+
background: [
18+
'hsla(330, 100%, 50%, 20%)',
19+
'hsla(240, 100%, 50%, 80%)',
20+
'hsla(330, 100%, 50%, 20%)',
21+
],
22+
right: ['460px', '160px', '460px'],
23+
}}
24+
transition={{
25+
duration: 8,
26+
repeat: Infinity,
27+
ease: 'linear',
28+
}}
29+
/>
30+
);
31+
};

frontend/src/index.css

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,3 @@
11
html {
22
scroll-behavior: smooth;
33
}
4-
5-
/* HeroCards background shadow */
6-
.shadow {
7-
position: absolute;
8-
background: hsla(330, 100%, 50%, 0%);
9-
border-radius: 24px;
10-
rotate: 35deg;
11-
12-
width: 260px;
13-
top: 200px;
14-
height: 400px;
15-
filter: blur(150px);
16-
animation: shadow-slide infinite 4s linear alternate;
17-
}
18-
19-
@keyframes shadow-slide {
20-
from {
21-
background: hsla(330, 100%, 50%, 20%); /* Pink shadow color */
22-
right: 460px;
23-
}
24-
to {
25-
background: hsla(240, 100%, 50%, 80%); /* Blue shadow color */
26-
right: 160px;
27-
}
28-
}
29-
30-
@media (max-width: 1024px) {
31-
.shadow {
32-
top: 70px;
33-
}
34-
35-
@keyframes shadow-slide {
36-
from {
37-
background: hsla(330, 100%, 50%, 20%); /* Pink shadow color */
38-
right: 460px;
39-
}
40-
to {
41-
background: hsla(240, 100%, 50%, 50%); /* Blue shadow color */
42-
right: 160px;
43-
}
44-
}
45-
}
46-
47-
@media (max-width: 768px) {
48-
.shadow {
49-
top: 70px;
50-
width: 100px;
51-
height: 350px;
52-
filter: blur(60px);
53-
}
54-
55-
@keyframes shadow-slide {
56-
from {
57-
background: hsla(330, 100%, 50%, 20%); /* Pink shadow color */
58-
right: 280px;
59-
}
60-
to {
61-
background: hsla(240, 100%, 50%, 30%); /* Blue shadow color */
62-
right: 100px;
63-
}
64-
}
65-
}

0 commit comments

Comments
 (0)