-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathContentCard.tsx
More file actions
127 lines (126 loc) · 4.14 KB
/
ContentCard.tsx
File metadata and controls
127 lines (126 loc) · 4.14 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import { CheckCircle2, Play } from 'lucide-react';
import { Bookmark } from '@prisma/client';
import BookmarkButton from './bookmark/BookmarkButton';
import { formatTime } from '@/lib/utils';
import VideoThumbnail from './videothumbnail';
import CardComponent from './CardComponent';
import { motion } from 'framer-motion';
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from './ui/tooltip';
import React from 'react';
export const ContentCard = ({
title,
onClick,
markAsCompleted,
type,
videoProgressPercent,
bookmark,
contentId,
contentDuration,
weeklyContentTitles,
}: {
type: 'folder' | 'video' | 'notion';
contentId?: number;
image: string;
title: string;
onClick: () => void;
markAsCompleted?: boolean;
percentComplete?: number | null;
videoProgressPercent?: number;
bookmark?: Bookmark | null;
contentDuration?: number;
uploadDate?: string;
weeklyContentTitles?: string[];
}) => {
return (
<TooltipProvider delayDuration={0}>
<Tooltip>
<TooltipTrigger asChild>
<motion.div
onClick={onClick}
tabIndex={0}
role="button"
onKeyDown={(e: React.KeyboardEvent) =>
['Enter', ' '].includes(e.key) && onClick()
}
className={`group relative flex h-fit w-full max-w-md cursor-pointer flex-col gap-2 rounded-2xl transition-all duration-300 hover:-translate-y-2`}
>
{markAsCompleted && (
<div className="absolute right-2 top-2 z-[1]">
<CheckCircle2 color="green" size={30} fill="lightgreen" />
</div>
)}
{type === 'video' && (
<div className="absolute bottom-12 right-2 z-[1] rounded-md p-2 font-semibold text-white">
<Play className="size-6" />
</div>
)}
{type !== 'video' && (
<div className="relative overflow-hidden rounded-md">
<CardComponent
title={title}
contentDuration={
contentDuration && formatTime(contentDuration)
}
type={type}
/>
{!!videoProgressPercent && (
<div className="absolute bottom-0 h-1 w-full bg-[#707071]">
<div
className="h-full bg-[#FF0101]"
style={{ width: `${videoProgressPercent}%` }}
/>
</div>
)}
</div>
)}
{type === 'video' && (
<div className="relative overflow-hidden">
<VideoThumbnail
title={title}
contentId={contentId ?? 0}
imageUrl=""
// imageUrl={
// 'https://d2szwvl7yo497w.cloudfront.net/courseThumbnails/video.png'
// }
/>
{!!videoProgressPercent && (
<div className="absolute bottom-0 h-1 w-full bg-[#707071]">
<div
className="h-full bg-[#5eff01]"
style={{ width: `${videoProgressPercent}%` }}
></div>
</div>
)}
</div>
)}
<div className="flex items-center justify-between gap-4">
<h3 className="w-full truncate text-xl font-bold capitalize tracking-tighter md:text-2xl">
{title}
</h3>
{bookmark !== undefined && contentId && (
<BookmarkButton
bookmark={bookmark}
contentId={contentId}
size={24}
align="end"
side="top"
/>
)}
</div>
</motion.div>
</TooltipTrigger>
{Array.isArray(weeklyContentTitles) &&
weeklyContentTitles?.length > 0 && (
<TooltipContent sideOffset={16}>
{weeklyContentTitles?.map((title) => <p>{title}</p>)}
</TooltipContent>
)}
</Tooltip>
</TooltipProvider>
);
};