Projects Section
The ProjectsSection component is a versatile and dynamic React component designed to showcase a collection of projects in a visually appealing manner. It efficiently displays project details such as titles, taglines, descriptions, and links, including hosted and GitHub links, with an engaging layout. This component is perfect for developers looking to enhance their portfolio or project showcase with a modern, responsive design that highlights key project features and encourages user interaction.
Preview
Follow below steps 👇🏻
Install dependencies
1npm i framer-motion lucide-react
Component
Create a file project-section.tsx in your components folder and paste this code
1'use client';23import { AnimatePresence, motion } from 'framer-motion';4import { Github, Globe, MoveUpRight } from 'lucide-react';5import Image from 'next/image';6import Link from 'next/link';7import { ReactNode, useEffect, useState } from 'react';89type ProjectType = {10id: number;11hostedLink?: string;12githubLink?: string;13title: string;14tagLine: string;15description: string[];16src: string;17highlightColor?: string;18};1920const LinkButton = ({21href,22text,23icon,24color = 'green'25}: {26href: string;27text: string;28icon: ReactNode;29color: string;30}) => {31const [hovering, setHovering] = useState(false);3233return (34<Link href={href} target="_blank" rel="noopener noreferrer">35<AnimatePresence mode="wait">36<a37onMouseEnter={() => setHovering(true)}38onMouseLeave={() => setHovering(false)}39href={href}40target="_blank"41className="flex items-center gap-1.5 leading-none text-black rounded-full transition-all duration-200 cursor-pointer p-1 text-xs"42style={{43color: color44}}45>46{!hovering && (47<motion.div48key={href}49initial={{50opacity: 0,51x: -1452}}53animate={{54opacity: 1,55x: 056}}57exit={{58opacity: 0,59x: -1460}}61transition={{62duration: 0.263}}64>65{icon}66</motion.div>67)}6869<motion.div70key={'children' + href}71layout72transition={{73duration: 0.274}}75>76{text}77</motion.div>7879{hovering && (80<motion.div81key={'right-arrow' + href}82initial={{83opacity: 0,84x: 1485}}86animate={{87opacity: 1,88x: 089}}90exit={{91opacity: 0,92x: -1493}}94transition={{95duration: 0.296}}97className="hidden sm:block"98>99<MoveUpRight size={16} />100</motion.div>101)}102</a>103</AnimatePresence>104</Link>105);106};107108const ProjectCard = ({ project }: { project: ProjectType }) => {109const [isSmallScreen, setIsSmallScreen] = useState(false);110const [loading, setLoading] = useState(true);111112useEffect(() => {113const handleResize = () => {114setIsSmallScreen(window.innerWidth < 640);115};116handleResize();117window.addEventListener('resize', handleResize);118setLoading(false);119return () => window.removeEventListener('resize', handleResize);120}, []);121122return (123!loading && (124<div className="border-b-[1px] border-white/20 w-full relative group">125<motion.div126style={{127height: isSmallScreen ? 'auto' : '148px'128}}129initial={{ height: isSmallScreen ? 'auto' : '148px' }}130whileHover={{ height: 'auto' }}131transition={{ duration: 0.3, ease: 'easeInOut' }}132className="overflow-hidden flex flex-col"133>134<div135style={{136height: '48px'137}}138className="shrink-0"139/>140<div className="flex sm:flex-row flex-col items-start justify-between">141<div className="flex flex-col items-start justify-between w-full sm:w-[calc(100%-320px)]">142<div className="flex flex-col items-start justify-start">143<p className="font-bold text-white">{project.title}</p>144<p>{project.tagLine}</p>145</div>146<div className="flex items-center gap-5 mt-2">147{project.hostedLink && (148<LinkButton149color="#0084ff"150href={project.hostedLink}151text="Live"152icon={<Globe size={16} />}153/>154)}155{project.githubLink && (156<LinkButton157color="#2dba4e"158href={project.githubLink}159text="Github"160icon={<Github size={16} />}161/>162)}163</div>164</div>165<div166className="relative w-full sm:w-[300px] aspect-video sm:rotate-6 group-hover:rotate-0 transition-all duration-300 sm:mt-0 mt-4 overflow-hidden"167style={{168boxShadow: `0px 0px 40px 1px ${project.highlightColor}7A`169}}170>171<Image src={project.src || ''} alt={project.title} fill className="object-cover" />172</div>173</div>174<div className="flex flex-col items-start justify-start gap-4 text-justify mt-4">175{project.description.map((description) => {176return <p key={description}>{description}</p>;177})}178</div>179<div180style={{181height: '48px'182}}183/>184</motion.div>185</div>186)187);188};189190const ProjectsSection = ({ projects }: { projects: ProjectType[] }) => {191return (192<div className="flex flex-col items-start justify-start">193<div className="flex flex-col items-start justify-start w-full mt-4">194{projects.map((project) => {195return <ProjectCard key={project.id + project.title} project={project} />;196})}197</div>198</div>199);200};201202export default ProjectsSection;
Usage
1<ProjectsSection2projects={[3{4id: 1,5title: 'Stackbits',6tagLine: 'Ready to use snippets for your next project',7hostedLink: 'https://stackbits.dev',8src: 'https://images.unsplash.com/photo-1588200908342-23b585c03e26?q=80&w=3540&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',9description: [10'StackBits is a robust component library that accelerates web development by providing reusable frontend and backend code snippets. It offers ready-to-use components for React, Next.js, JavaScript, and Tailwind CSS, along with backend utilities like authentication flows and API handlers, eliminating boilerplate code and enhancing efficiency.'11],12highlightColor: '#7701FF'13},14{15id: 2,16hostedLink: 'https://readmechef.com',17title: 'ReadMeChef',18tagLine:19'What if I told you that you could create a perfect README in just one step?',20src: 'https://images.unsplash.com/photo-1608742213509-815b97c30b36?q=80&w=3540&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',21description: [22'ReadMeChef is an AI-powered tool that generates high-quality, professional README files instantly without any manual input. It offers intelligent content suggestions, customizable templates, and seamless Markdown formatting, ensuring clear and engaging documentation for any project, whether new or existing.'23],24highlightColor: '#00ff00'25},26{27id: 2,28hostedLink: 'https://peeklink.stackbits.dev',29title: 'peeklink',30tagLine: 'Perfect your social media presence before your share.',31githubLink: 'https://github.com/samitkapoor/peeklink',32src: 'https://images.unsplash.com/photo-1578091879915-33ee869e2cd7?q=80&w=3702&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',33highlightColor: '#D2D2D2',34description: [35'Peeklink is a tool designed for builders to preview how their project links will appear when shared on social media platforms. It provides a comprehensive report highlighting any missing OpenGraph tags, ensuring that your links are optimized for the best possible presentation and engagement.'36]37}38]}39/>
⭐️ Got a question or feedback?
Feel free to reach out!