105 lines
2.7 KiB
TypeScript
105 lines
2.7 KiB
TypeScript
import { ArrowRight } from "lucide-react";
|
|
|
|
import CtaButton from "@/front/Components/Layout/CtaButton";
|
|
import ContentCard from "@/front/Components/Shared/ContentCard";
|
|
|
|
interface TextBlock {
|
|
type: "text";
|
|
content: string;
|
|
}
|
|
interface ImageBlock {
|
|
type: "image";
|
|
src: string;
|
|
srcWebp?: string;
|
|
alt?: string;
|
|
}
|
|
interface CtaBlockType {
|
|
type: "cta";
|
|
label: string;
|
|
href: string;
|
|
color?: "bleu" | "rouge";
|
|
}
|
|
interface PanelBlock {
|
|
type: "panel";
|
|
title?: string;
|
|
content: string;
|
|
ctaLabel?: string;
|
|
ctaHref?: string;
|
|
bgColor?: string;
|
|
textColor?: string;
|
|
}
|
|
|
|
type Block = TextBlock | ImageBlock | CtaBlockType | PanelBlock;
|
|
|
|
interface ContentBlocksProps {
|
|
blocks: Block[];
|
|
}
|
|
|
|
export default function ContentBlocks({
|
|
blocks,
|
|
}: Readonly<ContentBlocksProps>) {
|
|
return (
|
|
<div className="flex flex-col gap-8">
|
|
{blocks.map((block) => {
|
|
switch (block.type) {
|
|
case "text":
|
|
return (
|
|
<div
|
|
key={block.content}
|
|
className="flex flex-col gap-4 font-poppins-regular text-body text-bleu [&_a]:font-bold [&_a]:underline [&_li]:ml-4 [&_p]:mb-0 [&_strong]:font-bold [&_ul]:list-disc [&_ul]:space-y-1 [&_ul]:pl-2"
|
|
dangerouslySetInnerHTML={{ __html: block.content }}
|
|
/>
|
|
);
|
|
|
|
case "image":
|
|
return (
|
|
<picture key={block.src}>
|
|
{block.srcWebp && (
|
|
<source srcSet={block.srcWebp} type="image/webp" />
|
|
)}
|
|
<img
|
|
src={block.src}
|
|
alt={block.alt ?? ""}
|
|
className="w-full rounded-2xl object-cover"
|
|
/>
|
|
</picture>
|
|
);
|
|
|
|
case "cta":
|
|
return (
|
|
<div key={block.href}>
|
|
<CtaButton
|
|
href={block.href}
|
|
icon={<ArrowRight />}
|
|
iconPosition="right"
|
|
color={block.color ?? "rouge"}
|
|
>
|
|
{block.label}
|
|
</CtaButton>
|
|
</div>
|
|
);
|
|
|
|
case "panel":
|
|
return (
|
|
<div
|
|
key={block.content}
|
|
className="flex justify-center py-6 lg:py-12"
|
|
>
|
|
<ContentCard
|
|
title={block.title ?? ""}
|
|
description={block.content}
|
|
btnText={block.ctaLabel ?? ""}
|
|
btnLink={block.ctaHref ?? "#"}
|
|
bgColor={block.bgColor ?? "bg-bleu"}
|
|
textColor={block.textColor ?? "text-white"}
|
|
/>
|
|
</div>
|
|
);
|
|
|
|
default:
|
|
return null;
|
|
}
|
|
})}
|
|
</div>
|
|
);
|
|
}
|