2023-07-30 18:27:45 +02:00
|
|
|
import { Recipe } from "@lib/recipes.ts";
|
2023-07-26 13:47:01 +02:00
|
|
|
|
2023-07-30 19:40:39 +02:00
|
|
|
import IconExternalLink from "https://deno.land/x/tabler_icons_tsx@0.0.3/tsx/external-link.tsx";
|
|
|
|
import { Star } from "@components/Stars.tsx";
|
2023-07-30 23:55:51 +02:00
|
|
|
export function RecipeHero(
|
|
|
|
{ data, backlink }: {
|
|
|
|
backlink: string;
|
|
|
|
data: { meta?: { image?: string; link?: string }; name: string };
|
|
|
|
},
|
|
|
|
) {
|
|
|
|
const { meta: { image } = {} } = data;
|
2023-07-30 18:27:45 +02:00
|
|
|
|
2023-07-30 23:55:51 +02:00
|
|
|
const imageUrl =
|
|
|
|
(image?.startsWith("Recipes/images/") || image?.startsWith("Media/movies/"))
|
|
|
|
? `/api/images?image=${image}&width=800`
|
|
|
|
: image;
|
2023-07-30 18:27:45 +02:00
|
|
|
|
2023-07-26 13:47:01 +02:00
|
|
|
return (
|
2023-07-30 21:43:09 +02:00
|
|
|
<div
|
|
|
|
class={`relative w-full h-[${
|
|
|
|
imageUrl ? 400 : 200
|
|
|
|
}px] rounded-3xl overflow-hidden`}
|
|
|
|
>
|
|
|
|
{imageUrl &&
|
|
|
|
(
|
|
|
|
<img
|
|
|
|
src={imageUrl}
|
|
|
|
alt="Recipe Banner"
|
|
|
|
class="object-cover w-full h-full"
|
|
|
|
/>
|
|
|
|
)}
|
2023-07-26 13:47:01 +02:00
|
|
|
|
2023-07-30 19:40:39 +02:00
|
|
|
<div class="absolute top-8 left-8 ">
|
2023-07-26 13:47:01 +02:00
|
|
|
<a
|
2023-07-30 19:40:39 +02:00
|
|
|
class="px-4 py-2 bg-gray-300 text-gray-800 rounded-lg block"
|
2023-07-30 23:55:51 +02:00
|
|
|
href={backlink}
|
2023-07-26 13:47:01 +02:00
|
|
|
>
|
|
|
|
Back
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
2023-07-30 23:55:51 +02:00
|
|
|
{data.meta?.link &&
|
2023-07-30 19:40:39 +02:00
|
|
|
(
|
|
|
|
<div class="absolute top-8 right-8 ">
|
|
|
|
<a
|
2023-07-30 23:55:51 +02:00
|
|
|
href={data.meta.link}
|
2023-07-30 19:40:39 +02:00
|
|
|
target="__blank"
|
|
|
|
class="p-2 ml-4 bg-gray-300 text-gray-800 rounded-lg flex"
|
|
|
|
name="Link to Original recipe"
|
|
|
|
>
|
|
|
|
<IconExternalLink />
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
|
2023-07-30 21:43:09 +02:00
|
|
|
<div
|
|
|
|
class={`absolute inset-x-0 bottom-0 py-4 px-8 py-8 ${
|
|
|
|
imageUrl ? "noisy-gradient" : ""
|
|
|
|
} flex gap-4 items-center pt-12`}
|
|
|
|
>
|
2023-07-30 18:27:45 +02:00
|
|
|
<h2
|
2023-07-30 19:40:39 +02:00
|
|
|
class="relative text-4xl font-bold z-10"
|
2023-07-30 21:43:09 +02:00
|
|
|
style={{ color: imageUrl ? "#1F1F1F" : "white" }}
|
2023-07-30 18:27:45 +02:00
|
|
|
>
|
2023-07-30 23:55:51 +02:00
|
|
|
{data.name}
|
2023-07-26 13:47:01 +02:00
|
|
|
</h2>
|
2023-07-30 19:40:39 +02:00
|
|
|
|
2023-07-30 23:55:51 +02:00
|
|
|
{data.meta?.rating && <Star rating={data.meta.rating} />}
|
2023-07-26 13:47:01 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|