Skip to content

Commit da67586

Browse files
Standardize List Display with Card Component (#433) (#460)
* Standardize List Display with Card Component (#433) * Addressed comments, added images, and implemented new styles * Increased padding on the x-axis
1 parent 80cf4c1 commit da67586

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

components/Card.tsx

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import React from 'react';
2+
import Link from 'next/link';
3+
4+
interface CardProps {
5+
title: string;
6+
body: string;
7+
icon?: string;
8+
link?: string;
9+
image?: string;
10+
}
11+
12+
const CardBody = ({ title, body, icon, link, image }: CardProps) => {
13+
return (
14+
<div className='group relative h-full w-full max-w-lg rounded-lg border border-gray-200 bg-white p-6 px-12 shadow-3xl transition-colors delay-[150ms] ease-in-out hover:bg-slate-100'>
15+
<div className='flex justify-center'>
16+
{image && <img src={image} className='h-32 w-36 p-2' />}
17+
</div>
18+
<div className='flex flex-row items-start'>
19+
{icon && (
20+
<span className='mr-6 flex h-14 w-14 flex-shrink-0 items-center justify-center rounded-lg border bg-blue-200 px-3 text-gray-900'>
21+
<img src={icon} alt={title} className='h-full w-full' />
22+
</span>
23+
)}
24+
<h3 className='mb-5 mt-1 items-center text-[2rem] font-bold text-gray-900'>
25+
{title}
26+
</h3>
27+
</div>
28+
<hr className='mb-4 mt-3.5 h-px border-0 bg-gray-400' />
29+
<p className='text-lg mb-8 mt-5'>{body}</p>
30+
{link && (
31+
<p className='absolute bottom-3 right-5 font-medium opacity-0 transition-opacity delay-150 ease-in-out group-hover:opacity-100'>
32+
Read More
33+
</p>
34+
)}
35+
</div>
36+
);
37+
};
38+
39+
const Card: React.FC<CardProps> = ({ title, body, icon, link, image }) => {
40+
return (
41+
<>
42+
{link ? (
43+
<Link href={link}>
44+
<CardBody {...{ title, body, icon, link, image }} />
45+
</Link>
46+
) : (
47+
<CardBody {...{ title, body, icon, link, image }} />
48+
)}
49+
</>
50+
);
51+
};
52+
53+
export default Card;

0 commit comments

Comments
 (0)