forked from harshal14395/next13-lms-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcourse-card.tsx
69 lines (66 loc) · 1.95 KB
/
course-card.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import Image from "next/image";
import Link from "next/link";
import { BookOpen } from "lucide-react";
import { IconBadge } from "@/components/icon-badge";
import { formatPrice } from "@/lib/format";
import { CourseProgress } from "@/components/course-progress";
interface CourseCardProps {
id: string;
title: string;
imageUrl: string;
chaptersLength: number;
price: number;
progress: number | null;
category: string;
};
export const CourseCard = ({
id,
title,
imageUrl,
chaptersLength,
price,
progress,
category
}: CourseCardProps) => {
return (
<Link href={`/courses/${id}`}>
<div className="group hover:shadow-sm transition overflow-hidden border rounded-lg p-3 h-full">
<div className="relative w-full aspect-video rounded-md overflow-hidden">
<Image
fill
className="object-cover"
alt={title}
src={imageUrl}
/>
</div>
<div className="flex flex-col pt-2">
<div className="text-lg md:text-base font-medium group-hover:text-sky-700 transition line-clamp-2">
{title}
</div>
<p className="text-xs text-muted-foreground">
{category}
</p>
<div className="my-3 flex items-center gap-x-2 text-sm md:text-xs">
<div className="flex items-center gap-x-1 text-slate-500">
<IconBadge size="sm" icon={BookOpen} />
<span>
{chaptersLength} {chaptersLength === 1 ? "Chapter" : "Chapters"}
</span>
</div>
</div>
{progress !== null ? (
<CourseProgress
variant={progress === 100 ? "success" : "default"}
size="sm"
value={progress}
/>
) : (
<p className="text-md md:text-sm font-medium text-slate-700">
{formatPrice(price)}
</p>
)}
</div>
</div>
</Link>
)
}