InvokeAI/invokeai/frontend/web/src/common/components/ImageMetadataOverlay.tsx

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

45 lines
980 B
TypeScript
Raw Normal View History

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';
import { ImageDTO } from 'services/api/types';
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,
insetInlineStart: 0,
2023-05-11 04:18:35 +00:00
p: 2,
alignItems: 'flex-start',
2023-05-11 04:18:35 +00:00
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;