Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

1.4 KB
Raw Blame
import { Icon, type SystemStyleObject } from '@chakra-ui/react';
import { absolutizeApiUrl } from '@platform/transport/http';
import { StreamingImageFrame } from '@platform/ui/streaming-image/StreamingImageFrame';
import {
  imageUrlToStreamingSource,
  progressImageToStreamingSource,
} from '@platform/ui/streaming-image/streamingImageSource';
import { ImageOffIcon } from 'lucide-react';

const QUEUE_ITEM_THUMBNAIL_SX: SystemStyleObject = {
  boxShadow: 'inset 0 0 0 1px {colors.border.subtle}',
  display: 'flex',
  alignItems: 'center',
  justifyContent: 'center',
} as const;
const IMAGE_OFF_PLACEHOLDER = <Icon as={ImageOffIcon} w="4" h="4" />;

export const QueueItemThumbnail = ({
  imageName,
  liveImage,
  boxSize = '8',
  rounded = 'md',
}: {
  imageName: string | null;
  liveImage?: { dataUrl: string; width: number; height: number } | null;
  // seed: number;
  boxSize?: string;
  rounded?: string;
}) => {
  const finalImage = imageUrlToStreamingSource({
    alt: imageName ?? '',
    src: imageName ? absolutizeApiUrl(`/api/v1/images/i/${encodeURIComponent(imageName)}/thumbnail`) : null,
  });

  return (
    <StreamingImageFrame
      bg="bg.subtle"
      boxSize={boxSize}
      flexShrink={0}
      finalImage={finalImage}
      liveImage={progressImageToStreamingSource(liveImage)}
      rounded={rounded}
      css={QUEUE_ITEM_THUMBNAIL_SX}
    >
      {IMAGE_OFF_PLACEHOLDER}
    </StreamingImageFrame>
  );
};