Skip to content

Commit 7b66b5b

Browse files
committed
refactor: replace Hero CSS animations with Framer Motion
Replaced custom CSS keyframe animations with Framer Motion in the Hero section to improve consistency and reduce build size. Removed 62 lines of CSS while maintaining identical visual appearance. Fixes #450
1 parent ffbf6f7 commit 7b66b5b

3 files changed

Lines changed: 22 additions & 64 deletions

File tree

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

Lines changed: 20 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 { motion } from 'framer-motion';
67

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

54-
<div className="shadow"></div>
55+
<motion.div
56+
className="absolute top-[200px] w-[300px] h-[400px] lg:w-[400px] lg:h-[400px] md:top-[150px] md:w-[200px] md:h-[300px]"
57+
style={{
58+
filter: 'blur(150px)',
59+
}}
60+
animate={{
61+
background: [
62+
'hsla(330, 100%, 50%, 20%)',
63+
'hsla(240, 100%, 50%, 80%)',
64+
'hsla(330, 100%, 50%, 20%)',
65+
],
66+
right: ['460px', '160px', '460px'],
67+
}}
68+
transition={{
69+
duration: 8,
70+
repeat: Infinity,
71+
ease: 'linear',
72+
}}
73+
/>
5574
</section>
5675
);
5776
};

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>

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)