Skip to content

Commit 4647846

Browse files
committed
[Update] Added a new component for course card
1 parent 098a782 commit 4647846

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import React from 'react';
2+
3+
export default function CourseCard({ course }) {
4+
return (
5+
<a
6+
href={`/courses/${course.ID}`}
7+
className="max-w-[40vw] aspect-[9/8] hover:underline"
8+
aria-label={`View course: ${course.title}`}
9+
>
10+
<div className="bg-gray-100 rounded shadow hover:bg-gray-300 flex flex-col h-full w-full outline outline-1 outline-black/25">
11+
{/* Thumbnail */}
12+
<div className="h-[60%]">
13+
<img
14+
className="rounded outline outline-1 outline-black/40 object-fill w-full h-full block aspect-[16/9]"
15+
src={`${process.env.PUBLIC_URL}/content/${course.ID}/thumbnail.png`}
16+
onError={(e) => {
17+
e.target.onerror = null;
18+
e.target.src = `/default_thumbnails/tn${course.ID % 5}.png`;
19+
}}
20+
alt={`${course.title} Thumbnail`}
21+
/>
22+
</div>
23+
24+
{/* Course Information */}
25+
<div className="h-[40%] p-2 md:p-4 xl:p-2 overflow-hidden">
26+
<h3 className="text-base font-semibold truncate overflow-hidden">
27+
{course.title}
28+
</h3>
29+
<p className="truncate overflow-hidden">{course.description}</p>
30+
</div>
31+
</div>
32+
</a>
33+
);
34+
}

0 commit comments

Comments
 (0)