Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

41 blog article card #58

Merged
merged 9 commits into from
Oct 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/components/articlecard/ArticleCard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import Image from "next/image";
import Link from "next/link";

/*
textOnleft prop: is the order of content and image in the design.
In the card, we have content on the left and image on the right, and the reverse order in the following card.

*/

const ArticleCard = ({
title,
description,
imageUrl,
articleUrl = "",
textOnleft = false,
}) => {
return (
<div className='my-8 flex flex-col w-full px-8 py-5 gap-4 md:flex-row md:gap-10 md:my-16 md:items-center lg:w-[90%] mx-auto'>
<div className='w-full md:w-1/2'>
<Image
src={imageUrl}
alt={title}
width={500}
height={500}
className='object-cover rounded-lg'
/>
</div>
<div
className={`${textOnleft ? "md:order-first" : ""}
flex flex-col gap-6 text-center items-center md:text-left md:items-start md:w-1/2 `}
>
<h1 className='text-2xl text-black font-semibold'>{title}</h1>
<p className='text-black md:w-3/4'>{description}</p>
<Link
href={articleUrl}
className='bg-green px-4 py-2 text-white rounded-lg cursor-pointer w-1/2 md:w-fit md:px-6'
>
Read more
</Link>
</div>
</div>
);
};

export default ArticleCard;
Loading