2023-05-11 04:18:35 +00:00
|
|
|
|
import { Badge, Flex } from '@chakra-ui/react';
|
2023-06-01 04:17:32 +00:00
|
|
|
|
import { isString } from 'lodash-es';
|
2023-05-11 04:18:35 +00:00
|
|
|
|
import { useMemo } from 'react';
|
2023-05-22 09:45:08 +00:00
|
|
|
|
import { ImageDTO } from 'services/api';
|
2023-05-11 04:18:35 +00:00
|
|
|
|
|
|
|
|
|
type ImageMetadataOverlayProps = {
|
2023-05-22 09:45:08 +00:00
|
|
|
|
image: ImageDTO;
|
2023-05-11 04:18:35 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const ImageMetadataOverlay = ({ image }: ImageMetadataOverlayProps) => {
|
|
|
|
|
const model = useMemo(() => {
|
2023-05-22 09:45:08 +00:00
|
|
|
|
if (!isString(image.metadata?.model)) {
|
2023-05-11 04:18:35 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-22 09:45:08 +00:00
|
|
|
|
return image.metadata?.model;
|
2023-05-11 04:18:35 +00:00
|
|
|
|
}, [image.metadata]);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Flex
|
|
|
|
|
sx={{
|
|
|
|
|
pointerEvents: 'none',
|
|
|
|
|
flexDirection: 'column',
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
top: 0,
|
|
|
|
|
right: 0,
|
|
|
|
|
p: 2,
|
|
|
|
|
alignItems: 'flex-end',
|
|
|
|
|
gap: 2,
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-06-01 04:17:32 +00:00
|
|
|
|
<Badge variant="solid" colorScheme="base">
|
|
|
|
|
{image.width} × {image.height}
|
|
|
|
|
</Badge>
|
2023-05-11 04:18:35 +00:00
|
|
|
|
{model && (
|
|
|
|
|
<Badge variant="solid" colorScheme="base">
|
|
|
|
|
{model}
|
|
|
|
|
</Badge>
|
|
|
|
|
)}
|
|
|
|
|
</Flex>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default ImageMetadataOverlay;
|