98 lines
3.6 KiB
TypeScript
Raw Normal View History

2023-10-13 19:02:59 -04:00
import Image from "next/image";
import Link from "next/link";
import { RiArrowRightLine } from "react-icons/ri";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card";
2023-10-15 19:04:54 -04:00
import { NDKUserProfile } from "@nostr-dev-kit/ndk";
import { BANNER } from "@/constants/app";
import { getNameToShow } from "@/lib/utils";
2023-10-13 19:02:59 -04:00
type CreatorCardProps = {
profile?: NDKUserProfile;
2023-10-15 19:04:54 -04:00
npub: string;
recentWork: {
id: string;
title: string;
summary: string;
2023-10-16 00:28:09 -04:00
href: string;
2023-10-15 19:04:54 -04:00
}[];
2023-10-13 19:02:59 -04:00
};
export default function CreatorCard({
2023-10-15 19:04:54 -04:00
profile,
npub,
recentWork,
2023-10-13 19:02:59 -04:00
}: CreatorCardProps) {
return (
<Card className="relative h-[350px] w-[250px] min-w-[250] overflow-hidden">
<Image
alt="background"
2023-10-15 19:04:54 -04:00
src={profile?.banner ?? BANNER}
2023-10-13 19:02:59 -04:00
className="absolute inset-0 object-cover"
fill
unoptimized
/>
<div className="absolute inset-0 bg-background/60 backdrop-blur-md transition-all">
<div className="group relative flex h-full w-full flex-col items-center justify-end transition-all">
2023-10-14 23:09:21 -04:00
<CardHeader className="absolute inset-x-0 top-[59%] transform pt-4 text-center transition-all duration-300 group-hover:top-[8px] group-hover:ml-[75px] group-hover:text-left">
2023-10-16 00:28:09 -04:00
<Link href={`/${npub}`}>
<CardTitle className="hover:underline">
{getNameToShow({ profile, npub })}
</CardTitle>
</Link>
2023-10-13 19:02:59 -04:00
<CardDescription className="line-clamp-3 group-hover:text-xs">
2023-10-15 19:04:54 -04:00
{profile?.about}
2023-10-13 19:02:59 -04:00
</CardDescription>
</CardHeader>
<Image
alt="user"
2023-10-15 19:04:54 -04:00
src={
profile?.image ??
profile?.picture ??
`https://bitcoinfaces.xyz/api/get-image?name=${npub}&onchain=false`
}
2023-10-14 23:09:21 -04:00
className="absolute left-1/2 top-1/2 aspect-square -translate-x-1/2 -translate-y-[70%] transform overflow-hidden rounded-lg object-cover transition-all duration-300 group-hover:left-[50px] group-hover:top-[65px] group-hover:w-[70px]"
2023-10-13 19:02:59 -04:00
height={100}
width={100}
unoptimized
/>
<Card className="absolute top-full min-h-full w-5/6 overflow-hidden transition-all duration-300 group-hover:top-1/3">
<CardHeader className="border-b p-4 pb-3">
<CardTitle>Recent work:</CardTitle>
</CardHeader>
<CardContent className="overflow-hidden px-0">
2023-10-15 19:04:54 -04:00
<ul className="w-full">
{recentWork.map((item) => (
<li key={item.id} className="w-full overflow-hidden">
2023-10-13 19:02:59 -04:00
<Link
2023-10-16 00:28:09 -04:00
href={item.href}
2023-10-15 19:04:54 -04:00
className="flex max-w-full items-center justify-between overflow-hidden py-1.5 pl-4 pr-2 transition-colors hover:bg-muted hover:text-primary"
2023-10-13 19:02:59 -04:00
>
2023-10-15 19:04:54 -04:00
<div className="shrink overflow-x-hidden">
2023-10-13 19:02:59 -04:00
<h4 className="line-clamp-1 text-sm font-semibold text-card-foreground">
{item.title}
</h4>
<p className="line-clamp-2 text-[10px] leading-4 text-muted-foreground">
2023-10-15 19:04:54 -04:00
{item.summary ?? ""}
2023-10-13 19:02:59 -04:00
</p>
</div>
2023-10-15 19:04:54 -04:00
<div className="center ml-auto shrink-0 pl-2">
2023-10-13 19:02:59 -04:00
<RiArrowRightLine className="h-5 w-5" />
</div>
</Link>
</li>
))}
</ul>
</CardContent>
</Card>
</div>
</div>
</Card>
);
}