68 lines
1.5 KiB
TypeScript
68 lines
1.5 KiB
TypeScript
import { ArrowRight } from "lucide-react";
|
|
|
|
import CtaButton from "@/front/Components/Layout/CtaButton";
|
|
|
|
interface TextBlock {
|
|
type: "text";
|
|
content: string;
|
|
}
|
|
interface ImageBlock {
|
|
type: "image";
|
|
src: string;
|
|
alt?: string;
|
|
}
|
|
interface CtaBlock {
|
|
type: "cta";
|
|
label: string;
|
|
href: string;
|
|
color?: "bleu" | "rouge";
|
|
}
|
|
|
|
type Block = TextBlock | ImageBlock | CtaBlock;
|
|
|
|
interface AnswerBlocksProps {
|
|
blocks: Block[];
|
|
}
|
|
|
|
export default function AnswerBlocks({ blocks }: Readonly<AnswerBlocksProps>) {
|
|
return (
|
|
<div className="flex flex-col gap-4">
|
|
{blocks.map((block) => {
|
|
if (block.type === "text") {
|
|
return (
|
|
<div
|
|
key={block.content}
|
|
className="flex flex-col gap-3 font-poppins-regular text-body text-white [&_li]:ml-4 [&_p]:mb-0 [&_ul]:list-disc [&_ul]:space-y-1 [&_ul]:pl-2"
|
|
dangerouslySetInnerHTML={{ __html: block.content }}
|
|
/>
|
|
);
|
|
}
|
|
|
|
if (block.type === "image") {
|
|
return (
|
|
<img
|
|
key={block.src}
|
|
src={block.src}
|
|
alt={block.alt ?? ""}
|
|
className="rounded-2xl"
|
|
/>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div key={block.href}>
|
|
<CtaButton
|
|
href={block.href}
|
|
icon={<ArrowRight />}
|
|
iconPosition="right"
|
|
color={block.color ?? "rouge"}
|
|
size="sm"
|
|
>
|
|
{block.label}
|
|
</CtaButton>
|
|
</div>
|
|
);
|
|
})}
|
|
</div>
|
|
);
|
|
}
|