-
Notifications
You must be signed in to change notification settings - Fork 788
/
Copy pathsite-card.tsx
56 lines (55 loc) · 2.32 KB
/
site-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
import BlurImage from "@/components/blur-image";
import type { SelectSite } from "@/lib/schema";
import { placeholderBlurhash, random } from "@/lib/utils";
import { BarChart, ExternalLink } from "lucide-react";
import Link from "next/link";
export default function SiteCard({ data }: { data: SelectSite }) {
const url = `${data.subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`;
return (
<div className="relative rounded-lg border border-stone-200 pb-10 shadow-md transition-all hover:shadow-xl dark:border-stone-700 dark:hover:border-white">
<Link
href={`/site/${data.id}`}
className="flex flex-col overflow-hidden rounded-lg"
>
<BlurImage
alt={data.name ?? "Card thumbnail"}
width={500}
height={400}
className="h-44 object-cover"
src={data.image ?? "/placeholder.png"}
placeholder="blur"
blurDataURL={data.imageBlurhash ?? placeholderBlurhash}
/>
<div className="border-t border-stone-200 p-4 dark:border-stone-700">
<h3 className="my-0 truncate font-cal text-xl font-bold tracking-wide dark:text-white">
{data.name}
</h3>
<p className="mt-2 line-clamp-1 text-sm font-normal leading-snug text-stone-500 dark:text-stone-400">
{data.description}
</p>
</div>
</Link>
<div className="absolute bottom-4 flex w-full justify-between space-x-4 px-4">
<a
href={
process.env.NEXT_PUBLIC_VERCEL_ENV
? `https://${url}`
: `http://${data.subdomain}.localhost:3000`
}
target="_blank"
rel="noreferrer"
className="truncate rounded-md bg-stone-100 px-2 py-1 text-sm font-medium text-stone-600 transition-colors hover:bg-stone-200 dark:bg-stone-800 dark:text-stone-400 dark:hover:bg-stone-700"
>
{url} ↗
</a>
<Link
href={`/site/${data.id}/analytics`}
className="flex items-center rounded-md bg-green-100 px-2 py-1 text-sm font-medium text-green-600 transition-colors hover:bg-green-200 dark:bg-green-900 dark:bg-opacity-50 dark:text-green-400 dark:hover:bg-green-800 dark:hover:bg-opacity-50"
>
<BarChart height={16} />
<p>{random(10, 40)}%</p>
</Link>
</div>
</div>
);
}