Skip to content

Commit 724f072

Browse files
committed
Added thumbnails to home page
1 parent ccb500e commit 724f072

File tree

1 file changed

+26
-8
lines changed
  • frontend/src/components/pages

1 file changed

+26
-8
lines changed

frontend/src/components/pages/Home.js

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,34 @@ export function Home() {
6262
<p>Loading courses...</p>
6363
) : courses.length > 0 ? (
6464
courses.map((course) => (
65-
<div key={course.ID} className="course-box">
66-
<a href={`/courses/${course.ID}`} key={course.ID}>
67-
<h3><b>{course.title}</b></h3>
68-
</a>
69-
<p>{course.description}</p>
70-
</div>
65+
<a
66+
href={`/courses/${course.ID}`}
67+
key={course.ID}
68+
className="w-[12rem] aspect-[9/8]"
69+
>
70+
<div className="bg-gray-100 rounded shadow hover:bg-gray-300 flex flex-col h-full w-full outline outline-1 outline-black/25">
71+
<div className="h-[60%]">
72+
<img
73+
className="rounded outline outline-1 outline-black/40 object-cover w-full h-full"
74+
src={process.env.PUBLIC_URL + `/content/${course.ID}/thumbnail.png`}
75+
onError={(e) => {
76+
e.target.onError = null;
77+
e.target.src = `/default_thumbnails/tn${course.ID % 5}.png`;
78+
}}
79+
alt="Thumbnail"
80+
/>
81+
</div>
82+
<div className="h-[40%] p-3 overflow-hidden flex flex-col justify-center">
83+
<h3 className="text-lg font-semibold truncate">{course.title}</h3>
84+
<p className="truncate text-sm">{course.description}</p>
85+
</div>
86+
</div>
87+
</a>
88+
7189
))
7290
) : (
73-
<div className="course-box">
74-
<h3><b>Placeholder</b></h3>
91+
<div className="col-span-full text-center">
92+
<h3 className="text-lg font-bold">Placeholder</h3>
7593
<p>Nothing to show, yet</p>
7694
</div>
7795
)}

0 commit comments

Comments
 (0)