Skip to content

Commit 3a1a667

Browse files
authored
feat: scroll animation (#44)
* feat: scroll animation * feat: not used
1 parent 97aae58 commit 3a1a667

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

app/_components/home/OpenSource.tsx

+24-10
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,40 @@
11
import { ArrowRightIcon } from "lucide-react";
2-
import { Button } from "../common/button";
32
import { OPEN_SOURCE } from "@/app/_constants/open-source";
43
import Link from "next/link";
54
import Image from "next/image";
65
import { addBasePath } from "@/app/_lib/add-base-path";
6+
import { useScroll, useTransform, motion } from "framer-motion";
7+
import { useRef } from "react";
8+
import clsx from "clsx";
79

810
export default function OpenSource() {
11+
const sectionRef = useRef(null);
12+
13+
const { scrollYProgress } = useScroll({
14+
target: sectionRef,
15+
offset: ["start 0.9", "start 0.8"],
16+
});
17+
18+
const backgroundColor = useTransform(scrollYProgress, [0, 1], ["#FFFFFF", "#000000"]);
19+
const titleColor = useTransform(scrollYProgress, [0, 1], ["#071414", "#E6FDFC"]);
20+
const textColor = useTransform(scrollYProgress, [0, 1], ["#767676", "#BEBEBE"]);
21+
const buttonColor = useTransform(scrollYProgress, [0, 1], ["#002424", "#E6FDFC"]);
22+
923
return (
10-
<div className="flex w-full flex-col bg-[linear-gradient(0deg,_#000_90%,_rgba(0,0,0,0)_100%)] items-center gap-20 pb-[100px] pt-[200px] px-4 md:pb-0 md:px-8">
11-
<div className="flex flex-col md:items-center md:text-center gap-6">
12-
<h2 className="font-oceanic text-[24px] leading-normal md:text-[40px] md:leading-[46px] text-[#E6FDFC] md:whitespace-pre-line">
24+
<motion.div style={{ backgroundColor }} className={clsx(["flex w-full flex-col items-center gap-20 pb-[100px] pt-[200px] md:pb-0 md:px-8 duration-1000 transition-all"])}>
25+
<div ref={sectionRef} className="flex flex-col md:items-center md:text-center gap-6 px-4">
26+
<motion.h2 style={{ color: titleColor }} className={clsx(["font-oceanic text-[24px] leading-normal md:text-[40px] md:leading-[46px] md:whitespace-pre-line duration-700 transition-all"])}>
1327
{"Based on powerful\nOpen Source Ecosystem"}
14-
</h2>
15-
<p className="text-base text-[#BEBEBE] md:text-lg md:whitespace-pre-line">
28+
</motion.h2>
29+
<motion.p style={{ color: textColor }} className={clsx(["text-base md:text-lg md:whitespace-pre-line duration-700 transition-all"])}>
1630
Wrtn Agent OS is built on a powerful and reliable Wrtn Labs Open
1731
Source Ecosystem
18-
</p>
32+
</motion.p>
1933

2034
<Link href="https://github.com./wrtnlabs" target="_blank">
21-
<Button variant="secondary" className="text-[#E6FDFC] border-[#E6FDFC]">
35+
<motion.button style={{ color: buttonColor, borderColor: buttonColor }} className="text-sm border rounded-full cursor-pointer flex gap-2 px-6 py-[14px] transition-all duration-300">
2236
Our Ecosystem <ArrowRightIcon strokeWidth={1.5} size={20} />
23-
</Button>
37+
</motion.button>
2438
</Link>
2539
</div>
2640

@@ -71,6 +85,6 @@ export default function OpenSource() {
7185
</Link>
7286
))}
7387
</div>
74-
</div>
88+
</motion.div >
7589
);
7690
}

0 commit comments

Comments
 (0)