-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject.tsx
71 lines (64 loc) · 2.29 KB
/
project.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"use client";
import { useRef } from "react";
import { projectsData } from "@/lib/data";
import Image from "next/image";
import { motion, useScroll, useTransform } from "framer-motion";
type ProjectProps = (typeof projectsData)[number];
export default function Project({
title,
description,
tags,
imageUrl,
}: ProjectProps) {
const ref = useRef<HTMLDivElement>(null);
const { scrollYProgress } = useScroll({
target: ref,
offset: ["0 1", "1.33 1"],
});
const scaleProgess = useTransform(scrollYProgress, [0, 1], [0.8, 1]);
const opacityProgess = useTransform(scrollYProgress, [0, 1], [0.6, 1]);
return (
<motion.div
ref={ref}
style={{
scale: scaleProgess,
opacity: opacityProgess,
}}
className="group mb-3 sm:mb-8 last:mb-0"
>
<section className="bg-gray-100 max-w-[42rem] border border-black/5 rounded-lg overflow-hidden sm:pr-8 relative sm:h-[20rem] hover:bg-gray-200 transition sm:group-even:pl-8 dark:text-white dark:bg-white/10 dark:hover:bg-white/20">
<div className="pt-4 pb-7 px-5 sm:pl-10 sm:pr-2 sm:pt-10 sm:max-w-[50%] flex flex-col h-full sm:group-even:ml-[18rem]">
<h3 className="text-2xl font-semibold">{title}</h3>
<p className="mt-2 leading-relaxed text-gray-700 dark:text-white/70">
{description}
</p>
<ul className="flex flex-wrap mt-4 gap-2 sm:mt-auto">
{tags.map((tag, index) => (
<li
className="bg-gray-600 dark:bg-gray-900 px-3 py-1 text-[0.7rem] uppercase tracking-wider text-white rounded-full"
key={index}
>
{tag}
</li>
))}
</ul>
</div>
<Image
src={imageUrl}
alt="Project I worked on"
quality={95}
className="absolute hidden sm:block top-8 -right-40 w-[28.25rem] rounded-lg shadow-2xl
transition
group-hover:scale-[1.04]
group-hover:-translate-x-3
group-hover:translate-y-3
group-hover:-rotate-2
group-even:group-hover:translate-x-3
group-even:group-hover:translate-y-3
group-even:group-hover:rotate-2
group-even:right-[initial] group-even:-left-40"
/>
</section>
</motion.div>
);
}