danswer/web/src/app/chat/files/images/InMessageImage.tsx
pablodanswer 3540aa579b
Add ux improvements (#2130)
* add ux improvements

* add danswer version display

* show version properly

* improve copy + add web version to settings context

* update copy + danswer version
2024-08-14 16:43:52 +00:00

37 lines
1.1 KiB
TypeScript

import { useState } from "react";
import { FullImageModal } from "./FullImageModal";
import { buildImgUrl } from "./utils";
export function InMessageImage({ fileId }: { fileId: string }) {
const [fullImageShowing, setFullImageShowing] = useState(false);
const [imageLoaded, setImageLoaded] = useState(false);
return (
<>
<FullImageModal
fileId={fileId}
open={fullImageShowing}
onOpenChange={(open) => setFullImageShowing(open)}
/>
<div className="relative w-full h-full max-w-96 max-h-96">
{!imageLoaded && (
<div className="absolute inset-0 bg-gray-200 animate-pulse rounded-lg" />
)}
<img
width={1200}
height={1200}
alt="Chat Message Image"
onLoad={() => setImageLoaded(true)}
className={`object-contain object-left overflow-hidden rounded-lg w-full h-full max-w-96 max-h-96 transition-opacity duration-300
${imageLoaded ? "opacity-100" : "opacity-0"}`}
onClick={() => setFullImageShowing(true)}
src={buildImgUrl(fileId)}
loading="lazy"
/>
</div>
</>
);
}