Skip to content

Commit 52e7e1a

Browse files
committed
refactor: create IconWrapper component for project card icons
1 parent 847b1b2 commit 52e7e1a

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/components/ProjectCard.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
import React from "react";
12
import { MdLink, MdPhotoLibrary, MdCode } from "react-icons/md";
23
import { motion } from "framer-motion";
4+
import { IconType } from "react-icons";
5+
6+
const IconWrapper = ({ icon: Icon }: { icon: IconType }) => {
7+
return <Icon />;
8+
};
39

410
interface project {
511
title: string;
@@ -12,7 +18,12 @@ interface project {
1218

1319
export const ProjectCard = ({ title, desc, date, gallery, code, live }: project) => {
1420
return (
15-
<motion.div initial={{ opacity: 0 }} whileInView={{ opacity: 1 }} viewport={{ once: false }} className="flex flex-col h-full">
21+
<motion.div
22+
initial={{ opacity: 0 }}
23+
whileInView={{ opacity: 1 }}
24+
viewport={{ once: false }}
25+
className="flex flex-col h-full"
26+
>
1627
<div className="py-1 px-2 mb-2 bg-pink-50 rounded-full border border-gray-700 border-solid w-fit">
1728
<p className="text-xs md:text-sm">{date}</p>
1829
</div>
@@ -22,12 +33,12 @@ export const ProjectCard = ({ title, desc, date, gallery, code, live }: project)
2233
<div className="flex">
2334
{live && (
2435
<a href={live} target="_blank" rel="noreferrer" className="mr-4 text-lg text-gray-700 md:mr-6 md:text-xl">
25-
<MdLink />
36+
<IconWrapper icon={MdLink} />
2637
</a>
2738
)}
2839
{code && (
2940
<a href={code} target="_blank" rel="noreferrer" className="mr-4 text-lg text-gray-700 md:mr-6 md:text-xl">
30-
<MdCode />
41+
<IconWrapper icon={MdCode} />
3142
</a>
3243
)}
3344
{gallery && (
@@ -37,7 +48,7 @@ export const ProjectCard = ({ title, desc, date, gallery, code, live }: project)
3748
rel="noreferrer"
3849
className="mr-4 text-lg text-gray-700 md:mr-6 md:text-xl"
3950
>
40-
<MdPhotoLibrary />
51+
<IconWrapper icon={MdPhotoLibrary} />
4152
</a>
4253
)}
4354
</div>

0 commit comments

Comments
 (0)