Skip to content

Commit 5b771d4

Browse files
committed
Refactor components for improved animations and layout consistency
- Updated About, Contact, Experience, Projects, and Hero components to enhance scroll-based animations and layout responsiveness. - Replaced motion.div with div in several components for better performance and simplified structure. - Adjusted ParallaxLayer speeds and transform values for smoother visual effects. - Streamlined code by removing unused imports and optimizing animation settings across components.
1 parent fb36375 commit 5b771d4

File tree

6 files changed

+80
-52
lines changed

6 files changed

+80
-52
lines changed

src/components/About.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import { useRef } from "react";
4-
import { motion, useScroll, useTransform } from "framer-motion";
4+
import { useScroll, useTransform } from "framer-motion";
55
import BioSection from "./About/BioSection";
66
import ProfileImage from "./About/ProfileImage";
77
import SwissMotion from "./SwissMotion";
@@ -19,7 +19,8 @@ export default function About() {
1919
offset: ["start end", "end start"]
2020
});
2121

22-
const contentY = useTransform(scrollYProgress, [0, 1], [30, -30]);
22+
const bioY = useTransform(scrollYProgress, [0, 1], [50, -50]);
23+
const profileY = useTransform(scrollYProgress, [0, 1], [10, -10]);
2324

2425
// Signature "About" section animations - multiple diagonal lines
2526
const diagonalCount = 5;
@@ -32,7 +33,7 @@ export default function About() {
3233
className="py-24 md:py-32 relative overflow-hidden"
3334
>
3435
{/* Swiss style accent elements with unique About section animations */}
35-
<ParallaxLayer speed={0.15} direction="left" className="absolute right-0 top-1/4 z-0">
36+
<ParallaxLayer speed={0.35} direction="left" className="absolute right-0 top-1/4 z-0">
3637
<ShapeAnimation
3738
type="line"
3839
color="var(--accent)"
@@ -48,7 +49,7 @@ export default function About() {
4849
{diagonals.map((_, i) => (
4950
<ParallaxLayer
5051
key={`diagonal-${i}`}
51-
speed={0.05 + (i * 0.02)}
52+
speed={0.1 + (i * 0.04)}
5253
direction="right"
5354
className={`absolute left-1/4 z-0`}
5455
style={{ top: `${20 + (i * 12)}%` }}
@@ -65,7 +66,7 @@ export default function About() {
6566
</ParallaxLayer>
6667
))}
6768

68-
<ParallaxLayer speed={0.2} direction="up" className="absolute left-16 top-16 z-0">
69+
<ParallaxLayer speed={0.4} direction="up" className="absolute left-16 top-16 z-0">
6970
<ShapeAnimation
7071
type="square"
7172
color="var(--accent-tertiary)"
@@ -87,15 +88,13 @@ export default function About() {
8788
/>
8889

8990
{/* Content with Swiss style grid and alternating animations */}
90-
<motion.div
91-
className="swiss-grid"
92-
style={{ y: contentY }}
93-
>
91+
<div className="swiss-grid">
9492
<SwissMotion
9593
type="slide"
9694
delay={0.3}
9795
duration={0.7}
9896
className="swiss-asymmetric-left"
97+
style={{ y: bioY }}
9998
>
10099
<BioSection />
101100
</SwissMotion>
@@ -105,10 +104,11 @@ export default function About() {
105104
delay={0.5}
106105
duration={0.8}
107106
className="swiss-asymmetric-right mt-12 md:mt-0"
107+
style={{ y: profileY }}
108108
>
109109
<ProfileImage />
110110
</SwissMotion>
111-
</motion.div>
111+
</div>
112112

113113
{/* About section signature: Staggered grid of squares at the bottom */}
114114
<SwissMotion type="stagger" staggerChildren={0.05} delay={0.7} className="mt-16 grid grid-cols-6 md:grid-cols-12 gap-2 max-w-4xl mx-auto">

src/components/Contact.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export default function Contact() {
1717
offset: ["start end", "end start"]
1818
});
1919

20-
const contentY = useTransform(scrollYProgress, [0, 1], [20, -20]);
20+
const contactInfoY = useTransform(scrollYProgress, [0, 1], [-10, 30]);
21+
const socialLinksY = useTransform(scrollYProgress, [0, 1], [10, -30]);
2122

2223
return (
2324
<section
@@ -28,7 +29,7 @@ export default function Contact() {
2829
{/* Simplified background elements */}
2930
<div className="absolute inset-0 z-0 overflow-hidden">
3031
{/* Single horizontal line animation */}
31-
<ParallaxLayer speed={0.1} direction="right" className="absolute left-0 top-1/3 z-0">
32+
<ParallaxLayer speed={0.25} direction="right" className="absolute left-0 top-1/3 z-0">
3233
<ShapeAnimation
3334
type="line"
3435
color="var(--accent)"
@@ -41,7 +42,7 @@ export default function Contact() {
4142
</ParallaxLayer>
4243

4344
{/* Single clean geometric shape */}
44-
<ParallaxLayer speed={0.08} direction="up" className="absolute right-16 bottom-1/4 z-0">
45+
<ParallaxLayer speed={0.35} direction="up" className="absolute right-16 bottom-1/4 z-0">
4546
<ShapeAnimation
4647
type="square"
4748
color="var(--accent-secondary)"
@@ -64,16 +65,16 @@ export default function Contact() {
6465
className="mb-16 md:mb-20"
6566
/>
6667

67-
<motion.div
68+
<div
6869
className="grid grid-cols-1 lg:grid-cols-12 gap-8 md:gap-12"
69-
style={{ y: contentY }}
7070
>
7171
{/* Contact Information - Cleaner layout */}
7272
<SwissMotion
7373
type="slide"
7474
delay={0.3}
7575
duration={0.6}
7676
className="lg:col-span-5"
77+
style={{ y: contactInfoY }}
7778
>
7879
<div className="swiss-card relative overflow-hidden p-8 md:p-10">
7980
{/* Swiss style accent line */}
@@ -137,6 +138,7 @@ export default function Contact() {
137138
delay={0.4}
138139
duration={0.6}
139140
className="lg:col-span-7"
141+
style={{ y: socialLinksY }}
140142
>
141143
<div className="swiss-card relative p-8 md:p-10">
142144
{/* Swiss style accent lines */}
@@ -207,7 +209,7 @@ export default function Contact() {
207209
</div>
208210
</div>
209211
</SwissMotion>
210-
</motion.div>
212+
</div>
211213

212214
{/* Refined footer note */}
213215
<SwissMotion type="fade" delay={0.7} className="mt-16 text-center flex flex-col items-center">

src/components/Experience.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import { useRef, useMemo } from "react";
4-
import { motion, useInView } from "framer-motion";
4+
import { motion, useInView, useScroll, useTransform } from "framer-motion";
55
import { useIsMobile } from "@/hooks/useIsMobile";
66
import { SectionHeader } from "./common";
77

@@ -19,6 +19,11 @@ const getCircleCounts = (isMobile: boolean) => isMobile ? [1, 2] : [1, 2, 3];
1919

2020
export default function Experience() {
2121
const isMobile = useIsMobile();
22+
const ref = useRef<HTMLElement>(null);
23+
const { scrollYProgress } = useScroll({
24+
target: ref,
25+
offset: ["start end", "end start"]
26+
});
2227

2328
// Memoized constants based on device
2429
const LINE_COUNT = useMemo(() => getLineCount(isMobile), [isMobile]);
@@ -28,6 +33,9 @@ export default function Experience() {
2833
const getOptimizedDelay = (baseDelay: number) => isMobile ? baseDelay * 0.7 : baseDelay;
2934
const getOptimizedDuration = (baseDuration: number) => isMobile ? baseDuration * 0.6 : baseDuration;
3035

36+
const lottieAndSkillsY = useTransform(scrollYProgress, [0, 1], [-20, 20]);
37+
const timelineY = useTransform(scrollYProgress, [0, 1], [-40, 40]);
38+
3139
// Refs for scroll animations
3240
const refs = {
3341
skills: useRef<HTMLDivElement>(null),
@@ -43,14 +51,14 @@ export default function Experience() {
4351
};
4452

4553
return (
46-
<section id="experience" className="py-24 md:py-32 relative overflow-hidden">
54+
<section id="experience" ref={ref} className="py-24 md:py-32 relative overflow-hidden">
4755
{/* Decorative background elements - conditionally rendered and simplified for mobile */}
4856
{(!isMobile || (isMobile && LINE_COUNT > 0)) && (
4957
<div className="absolute left-4 md:left-12 top-0 bottom-0 w-12 z-0 flex flex-col justify-around">
5058
{Array.from({ length: LINE_COUNT }).map((_, i) => (
5159
<ParallaxLayer
5260
key={`line-${i}`}
53-
speed={isMobile ? 0.03 : 0.05 + (i * 0.03)}
61+
speed={isMobile ? 0.1 : 0.2 + (i * 0.05)}
5462
direction={i % 2 ? "left" : "right"}
5563
>
5664
<ShapeAnimation
@@ -74,7 +82,7 @@ export default function Experience() {
7482
{CIRCLE_COUNTS.map((i) => (
7583
<ParallaxLayer
7684
key={`circle-${i}`}
77-
speed={isMobile ? 0.05 * i : 0.1 * i}
85+
speed={isMobile ? 0.15 * i : 0.25 * i}
7886
direction={i % 2 ? "right" : "left"}
7987
>
8088
<ShapeAnimation
@@ -104,6 +112,7 @@ export default function Experience() {
104112

105113
<motion.div
106114
className="max-w-6xl mx-auto mb-16"
115+
style={{ y: lottieAndSkillsY, willChange: 'transform' }}
107116
initial={{ opacity: 0 }}
108117
animate={{ opacity: 1 }}
109118
transition={{
@@ -162,6 +171,7 @@ export default function Experience() {
162171
duration={getOptimizedDuration(0.8)}
163172
className="mt-16 pt-16 border-t border-[var(--border)]"
164173
mobileOptimized={true}
174+
style={{ y: timelineY, willChange: 'transform' }}
165175
>
166176
<SwissMotion
167177
type={isMobile ? "fade" : "slide"}

src/components/Hero/BackgroundElements.tsx

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const BackgroundElements = memo(function BackgroundElements({ isMobile }: Backgr
2424
<div className="absolute top-0 left-0 w-[200%] h-[2px] bg-[var(--accent)] origin-top-left rotate-45 transform -translate-x-1/4"></div>
2525
</SwissMotion>
2626

27-
<ParallaxLayer speed={0.3} direction="up" className="absolute bottom-16 left-0 -z-10">
27+
<ParallaxLayer speed={0.4} direction="up" className="absolute bottom-16 left-0 -z-10">
2828
<ShapeAnimation
2929
type="square"
3030
color="var(--accent-secondary)"
@@ -36,7 +36,7 @@ const BackgroundElements = memo(function BackgroundElements({ isMobile }: Backgr
3636
/>
3737
</ParallaxLayer>
3838

39-
<ParallaxLayer speed={0.25} direction="left" className="absolute top-24 left-1/4 -z-10">
39+
<ParallaxLayer speed={0.35} direction="left" className="absolute top-24 left-1/4 -z-10">
4040
<ShapeAnimation
4141
type="triangle"
4242
color="var(--accent)"
@@ -48,7 +48,7 @@ const BackgroundElements = memo(function BackgroundElements({ isMobile }: Backgr
4848
/>
4949
</ParallaxLayer>
5050

51-
<ParallaxLayer speed={0.35} direction="right" className="absolute top-32 right-8 -z-10">
51+
<ParallaxLayer speed={0.45} direction="right" className="absolute top-32 right-8 -z-10">
5252
<ShapeAnimation
5353
type="circle"
5454
color="var(--accent-tertiary)"
@@ -60,7 +60,7 @@ const BackgroundElements = memo(function BackgroundElements({ isMobile }: Backgr
6060
/>
6161
</ParallaxLayer>
6262

63-
<ParallaxLayer speed={0.4} direction="right" className="absolute bottom-40 right-5 -z-10">
63+
<ParallaxLayer speed={0.5} direction="right" className="absolute bottom-40 right-5 -z-10">
6464
<ShapeAnimation
6565
type="diagonal"
6666
color="var(--accent-secondary)"
@@ -88,7 +88,7 @@ const BackgroundElements = memo(function BackgroundElements({ isMobile }: Backgr
8888
</SwissMotion>
8989

9090
{/* Dynamic accent shapes */}
91-
<ParallaxLayer speed={0.2} direction="up" className="absolute bottom-16 left-16 -z-10">
91+
<ParallaxLayer speed={0.35} direction="up" className="absolute bottom-16 left-16 -z-10">
9292
<ShapeAnimation
9393
type="square"
9494
color="var(--accent-secondary)"
@@ -99,7 +99,7 @@ const BackgroundElements = memo(function BackgroundElements({ isMobile }: Backgr
9999
/>
100100
</ParallaxLayer>
101101

102-
<ParallaxLayer speed={0.3} direction="down" className="absolute top-32 right-32 -z-10">
102+
<ParallaxLayer speed={0.45} direction="up" className="absolute top-32 right-32 -z-10">
103103
<ShapeAnimation
104104
type="circle"
105105
color="var(--accent-tertiary)"
@@ -111,7 +111,7 @@ const BackgroundElements = memo(function BackgroundElements({ isMobile }: Backgr
111111
</ParallaxLayer>
112112

113113
{/* Additional energetic shapes */}
114-
<ParallaxLayer speed={0.15} direction="left" className="absolute top-40 left-1/4 -z-10">
114+
<ParallaxLayer speed={0.55} direction="right" className="absolute top-40 left-1/4 -z-10">
115115
<ShapeAnimation
116116
type="triangle"
117117
color="var(--accent)"
@@ -123,7 +123,7 @@ const BackgroundElements = memo(function BackgroundElements({ isMobile }: Backgr
123123
/>
124124
</ParallaxLayer>
125125

126-
<ParallaxLayer speed={0.25} direction="right" className="absolute bottom-40 right-1/3 -z-10">
126+
<ParallaxLayer speed={0.65} direction="right" className="absolute bottom-40 right-1/3 -z-10">
127127
<ShapeAnimation
128128
type="diagonal"
129129
color="var(--accent-secondary)"
@@ -134,6 +134,18 @@ const BackgroundElements = memo(function BackgroundElements({ isMobile }: Backgr
134134
loop={true}
135135
/>
136136
</ParallaxLayer>
137+
138+
<ParallaxLayer speed={0.85} direction="left" className="absolute bottom-1/3 left-1/4 -z-10">
139+
<ShapeAnimation
140+
type="cross"
141+
color="var(--accent)"
142+
size={40}
143+
variant="draw"
144+
delay={1.1}
145+
duration={1.5}
146+
loop={true}
147+
/>
148+
</ParallaxLayer>
137149
</>
138150
);
139151
});

src/components/Hero/HeroVisual.tsx

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,31 @@ import SwissMotion from "../SwissMotion";
55
import AccentBorders from "./visual/AccentBorders";
66
import GridCanvas from "./visual/GridCanvas";
77
import { ANIMATION } from "./constants";
8+
import ParallaxLayer from "../ParallaxLayer";
89

910
/**
1011
* Visual Swiss design grid display for the right side of the hero section
1112
*/
1213
const HeroVisual = memo(function HeroVisual() {
1314
return (
1415
<div className="swiss-asymmetric-right flex items-center justify-center relative">
15-
<SwissMotion
16-
type="scale"
17-
delay={0.5}
18-
duration={ANIMATION.duration.medium}
19-
className="relative"
20-
>
21-
{/* Swiss style grid pattern */}
22-
<div className="w-60 h-60 md:w-80 md:h-80 lg:w-96 lg:h-96 swiss-grid-pattern relative">
23-
{/* Accent shapes for Swiss style */}
24-
<AccentBorders />
25-
26-
{/* Dynamic Swiss-style visual elements */}
27-
<GridCanvas />
28-
</div>
29-
</SwissMotion>
16+
<ParallaxLayer speed={0.1} direction="down">
17+
<SwissMotion
18+
type="scale"
19+
delay={0.5}
20+
duration={ANIMATION.duration.medium}
21+
className="relative"
22+
>
23+
{/* Swiss style grid pattern */}
24+
<div className="w-60 h-60 md:w-80 md:h-80 lg:w-96 lg:h-96 swiss-grid-pattern relative">
25+
{/* Accent shapes for Swiss style */}
26+
<AccentBorders />
27+
28+
{/* Dynamic Swiss-style visual elements */}
29+
<GridCanvas />
30+
</div>
31+
</SwissMotion>
32+
</ParallaxLayer>
3033
</div>
3134
);
3235
});

0 commit comments

Comments
 (0)