blob: 7413c2fe80e2d25a5315b2cbf8de8d372141cfc7 (
plain) (
blame)
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
|
import { Badge } from "@/components/ui/badge";
import {
ImageCard,
ImageCardBanner,
ImageCardBody,
ImageCardContent,
ImageCardFooter,
ImageCardTitle,
} from "@/components/ui/imageCard";
import { ZBookmark } from "@/lib/types/api/bookmarks";
import Link from "next/link";
import BookmarkOptions from "./BookmarkOptions";
export default function LinkCard({ bookmark }: { bookmark: ZBookmark }) {
const link = bookmark.content;
const parsedUrl = new URL(link.url);
// A dummy white pixel for when there's no image.
// TODO: Better handling for cards with no images
const image =
link.imageUrl ??
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdj+P///38ACfsD/QVDRcoAAAAASUVORK5CYII=";
return (
<ImageCard
className={
"border-grey-100 border bg-gray-50 duration-300 ease-in hover:border-blue-300 hover:transition-all"
}
>
<Link href={link.url}>
<ImageCardBanner src={image} />
</Link>
<ImageCardContent>
<ImageCardTitle>
<Link className="line-clamp-2" href={link.url}>
{link?.title ?? parsedUrl.host}
</Link>
</ImageCardTitle>
{/* There's a hack here. Every tag has the full hight of the container itself. That why, when we enable flex-wrap,
the overflowed don't show up. */}
<ImageCardBody className="flex h-full flex-wrap space-x-1 overflow-hidden">
{bookmark.tags.map((t) => (
<Link
className="flex h-full flex-col justify-end"
key={t.id}
href={`/dashboard/tags/${t.name}`}
>
<Badge
variant="default"
className="text-nowrap bg-gray-300 text-gray-500 hover:text-white"
>
#{t.name}
</Badge>
</Link>
))}
</ImageCardBody>
<ImageCardFooter>
<div className="flex justify-between text-gray-500">
<div className="my-auto">
<Link className="line-clamp-1 hover:text-black" href={link.url}>
{parsedUrl.host}
</Link>
</div>
<BookmarkOptions bookmark={bookmark} />
</div>
</ImageCardFooter>
</ImageCardContent>
</ImageCard>
);
}
|