-
-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathCardHeader.tsx
More file actions
58 lines (55 loc) · 1.52 KB
/
CardHeader.tsx
File metadata and controls
58 lines (55 loc) · 1.52 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
import { useState } from "react"
import { ITemplate } from "@/api/generated"
import { Heart, StarIcon } from "lucide-react"
import { Badge } from "@/components/ui/badge"
import {
CardDescription,
CardTitle,
CardHeader as UICardHeader,
} from "@/components/ui/card"
import SocialButton from "@/components/common/SocialButton"
const CardHeader: React.FC<
Pick<ITemplate, "featured" | "title" | "author"> & {
isFavoriteTemplate: boolean
handleFavoriteTemplate: () => void
}
> = ({
featured,
title,
author,
isFavoriteTemplate,
handleFavoriteTemplate,
}) => {
const [isFavorite, setIsFavorite] = useState(isFavoriteTemplate)
return (
<UICardHeader>
<div>
<div className="flex justify-between">
<CardTitle className={`flex-1 ${featured && "pb-2"}`}>
{title}
</CardTitle>
<Heart
className={`size-5 hover:cursor-pointer ${
isFavorite ? "fill-red-500" : "hover:animate-pulse"
}`}
onClick={() => {
handleFavoriteTemplate()
setIsFavorite(!isFavorite)
}}
/>
</div>
{featured && (
<Badge>
<div className="flex items-center justify-center">
<StarIcon className="mr-2 size-4" />
Featured
</div>
</Badge>
)}
</div>
<CardDescription>Created By {author.name}</CardDescription>
<SocialButton author={author} />
</UICardHeader>
)
}
export default CardHeader