PaletteSwitcher/client/src/ImagePreview.tsx

38 lines
946 B
TypeScript
Raw Normal View History

2022-05-05 14:54:44 +00:00
import { faSpinner } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
2021-12-13 12:54:54 +00:00
import { useEffect } from "react";
2021-12-12 16:50:58 +00:00
interface ImagePreviewProps {
2021-12-13 12:54:54 +00:00
imageData: Blob;
2021-12-12 16:50:58 +00:00
}
function ImagePreview({ imageData }: ImagePreviewProps) {
2021-12-13 12:54:54 +00:00
const imageUrl = URL.createObjectURL(imageData);
useEffect(() => {
return () => {
2021-12-13 12:54:54 +00:00
URL.revokeObjectURL(imageUrl);
};
2021-12-13 12:54:54 +00:00
}, [imageUrl]);
2021-12-12 16:50:58 +00:00
return (
2022-05-05 14:54:44 +00:00
<div className="max-w-4xl mx-auto">
<div className="relative">
<img
alt="preview"
src={imageUrl}
className="blur-sm object-cover min-w-[70%] my-4 px-2 mx-auto"
/>
<div className="absolute inset-1/2 -translate-y-12 -translate-x-12 w-24 h-24">
<FontAwesomeIcon
icon={faSpinner}
className="absolute animate-spin text-8xl"
/>
</div>
</div>
2021-12-12 16:50:58 +00:00
</div>
);
}
export default ImagePreview;