2025-09-20 12:47:10 -07:00
|
|
|
import cn from "classnames";
|
|
|
|
|
import { LoaderIcon } from "./icons";
|
2025-01-15 19:59:29 +05:30
|
|
|
|
2025-09-20 12:47:10 -07:00
|
|
|
type ImageEditorProps = {
|
2025-01-15 19:59:29 +05:30
|
|
|
title: string;
|
|
|
|
|
content: string;
|
|
|
|
|
isCurrentVersion: boolean;
|
|
|
|
|
currentVersionIndex: number;
|
|
|
|
|
status: string;
|
|
|
|
|
isInline: boolean;
|
2025-09-20 12:47:10 -07:00
|
|
|
};
|
2025-01-15 19:59:29 +05:30
|
|
|
|
|
|
|
|
export function ImageEditor({
|
|
|
|
|
title,
|
|
|
|
|
content,
|
|
|
|
|
status,
|
|
|
|
|
isInline,
|
|
|
|
|
}: ImageEditorProps) {
|
|
|
|
|
return (
|
|
|
|
|
<div
|
2025-09-20 12:47:10 -07:00
|
|
|
className={cn("flex w-full flex-row items-center justify-center", {
|
|
|
|
|
"h-[calc(100dvh-60px)]": !isInline,
|
|
|
|
|
"h-[200px]": isInline,
|
2025-01-15 19:59:29 +05:30
|
|
|
})}
|
|
|
|
|
>
|
2025-09-20 12:47:10 -07:00
|
|
|
{status === "streaming" ? (
|
2025-09-09 15:44:07 -04:00
|
|
|
<div className="flex flex-row items-center gap-4">
|
2025-01-15 19:59:29 +05:30
|
|
|
{!isInline && (
|
|
|
|
|
<div className="animate-spin">
|
|
|
|
|
<LoaderIcon />
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
<div>Generating Image...</div>
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
<picture>
|
2025-09-20 12:47:10 -07:00
|
|
|
{/** biome-ignore lint/nursery/useImageSize: "Generated image without explicit size" */}
|
2025-01-15 19:59:29 +05:30
|
|
|
<img
|
2025-09-20 12:47:10 -07:00
|
|
|
alt={title}
|
|
|
|
|
className={cn("h-fit w-full max-w-[800px]", {
|
|
|
|
|
"p-0 md:p-20": !isInline,
|
2025-01-15 19:59:29 +05:30
|
|
|
})}
|
|
|
|
|
src={`data:image/png;base64,${content}`}
|
|
|
|
|
/>
|
|
|
|
|
</picture>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|