2023-08-07 13:42:00 +02:00
|
|
|
import { isYoutubeLink } from "@lib/string.ts";
|
|
|
|
import { IconBrandYoutube } from "@components/icons.tsx";
|
|
|
|
|
2023-07-30 18:27:45 +02:00
|
|
|
export function Card(
|
2023-08-09 15:20:14 +02:00
|
|
|
{ link, title, image, backgroundSize = 100 }: {
|
|
|
|
backgroundSize?: number;
|
|
|
|
link?: string;
|
|
|
|
title?: string;
|
|
|
|
image?: string;
|
|
|
|
},
|
2023-07-30 18:27:45 +02:00
|
|
|
) {
|
2023-08-09 15:20:14 +02:00
|
|
|
const backgroundStyle = {
|
|
|
|
backgroundImage: `url(${image})`,
|
|
|
|
backgroundSize: "cover",
|
|
|
|
};
|
|
|
|
|
|
|
|
if (backgroundSize !== 100) {
|
|
|
|
backgroundStyle["backgroundSize"] = `${backgroundSize}%`;
|
|
|
|
backgroundStyle["backgroundRepeat"] = "no-repeat";
|
|
|
|
backgroundStyle["backgroundPosition"] = "center";
|
|
|
|
}
|
|
|
|
|
2023-07-30 18:27:45 +02:00
|
|
|
return (
|
|
|
|
<a
|
|
|
|
href={link}
|
2023-08-09 15:20:14 +02:00
|
|
|
style={backgroundStyle}
|
2023-07-30 23:55:51 +02:00
|
|
|
class="text-white rounded-3xl shadow-md p-4 relative overflow-hidden
|
2023-07-30 18:27:45 +02:00
|
|
|
lg:w-56 lg:h-56
|
2023-08-02 01:58:03 +02:00
|
|
|
sm:w-48 sm:h-48
|
2023-08-02 17:35:10 +02:00
|
|
|
w-[37vw] h-[37vw]"
|
2023-07-30 18:27:45 +02:00
|
|
|
>
|
|
|
|
<div class="h-full flex flex-col justify-between relative z-10">
|
|
|
|
<div>
|
|
|
|
{/* Recipe Card content */}
|
|
|
|
</div>
|
2023-08-07 13:42:00 +02:00
|
|
|
<div class="mt-2 flex items-center gap-2">
|
|
|
|
{isYoutubeLink(link || "") && <IconBrandYoutube />}
|
2023-07-30 18:27:45 +02:00
|
|
|
{title}
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-07-31 17:21:17 +02:00
|
|
|
<div
|
|
|
|
class="absolute inset-x-0 bottom-0 h-3/4"
|
|
|
|
style={{ background: "linear-gradient(transparent, #000e)" }}
|
|
|
|
/>
|
2023-07-30 18:27:45 +02:00
|
|
|
</a>
|
|
|
|
);
|
|
|
|
}
|