54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import { cn } from "@/lib/utils";
|
|
|
|
type HomeAnimationEmbedProps = {
|
|
htmlContent: string;
|
|
title?: string;
|
|
description?: string;
|
|
className?: string;
|
|
frameClassName?: string;
|
|
};
|
|
|
|
export function HomeAnimationEmbed({
|
|
htmlContent,
|
|
title,
|
|
description,
|
|
className,
|
|
frameClassName,
|
|
}: HomeAnimationEmbedProps) {
|
|
if (!htmlContent.trim()) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<div
|
|
className={cn(
|
|
"overflow-hidden rounded-[24px] border border-black/10 bg-white shadow-[0_10px_24px_rgba(0,0,0,0.05)]",
|
|
className,
|
|
)}
|
|
>
|
|
{title || description ? (
|
|
<div className="flex items-start justify-between gap-4 border-b border-black/8 px-4 py-3">
|
|
<div className="min-w-0">
|
|
{title ? (
|
|
<div className="text-[14px] font-semibold text-black">{title}</div>
|
|
) : null}
|
|
{description ? (
|
|
<div className="mt-1 text-[12px] text-black/45">{description}</div>
|
|
) : null}
|
|
</div>
|
|
</div>
|
|
) : null}
|
|
|
|
<div className={cn("h-[360px] w-full bg-[#f6f6f6] md:h-[420px]", frameClassName)}>
|
|
<iframe
|
|
title={title || "首页互动动画"}
|
|
srcDoc={htmlContent}
|
|
sandbox="allow-scripts allow-forms allow-pointer-lock"
|
|
loading="lazy"
|
|
className="h-full w-full border-0"
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|