forked from ByteGrad/portfolio-website
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bcb8b62
commit 944881a
Showing
6 changed files
with
130 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { articleData } from "@/lib/data"; | ||
import { motion, useScroll, useTransform } from "framer-motion"; | ||
import Image from "next/image"; | ||
import { useRef } from "react"; | ||
type ArticleProps = (typeof articleData)[number]; | ||
|
||
export default function Article({ | ||
title, | ||
description, | ||
url, | ||
imageUrl, | ||
icon, | ||
source | ||
}: ArticleProps) { | ||
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" | ||
> | ||
<a href={url} target="_blank"> | ||
<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> | ||
<p | ||
className="mt-2 bg-white p-4 text-gray-700 hover:text-gray-950 flex items-center gap-2 rounded-full focus:scale-[1.15] hover:scale-[1.15] active:scale-105 transition cursor-pointer borderBlack dark:bg-white/10 dark:text-white/60" | ||
> | ||
Source: {source} {icon} | ||
</p> | ||
</div> | ||
|
||
<Image | ||
src={imageUrl} | ||
alt="Articles written about me" | ||
quality={95} | ||
width="300" | ||
height="300" | ||
className="absolute hidden sm:block top-8 -right-40 w-[28.25rem] rounded-t-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> | ||
</a> | ||
</motion.div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"use client"; | ||
|
||
import { useTheme } from "@/context/theme-context"; | ||
import { useSectionInView } from "@/lib/hooks"; | ||
import SectionHeading from "./section-heading"; | ||
import { articleData } from "@/lib/data"; | ||
import React from "react"; | ||
import Article from "./article"; | ||
|
||
export default function Articles() { | ||
const { ref } = useSectionInView('Articles'); | ||
const { theme } = useTheme(); | ||
return ( | ||
<section id="articles" ref={ref} className="scroll-mt-28 mb-28 sm:mb-40"> | ||
<SectionHeading>My articles</SectionHeading> | ||
<div> | ||
{articleData.map((article, i) => ( | ||
<React.Fragment key={i}> | ||
<Article {...article} /> | ||
</React.Fragment> | ||
))} | ||
</div> | ||
</section> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.