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.

949 B
Raw Blame
import { Box, Flex, Icon, Image } from '@chakra-ui/react';
import { FolderIcon } from 'lucide-react';
import { useCallback, useState } from 'react';

/** Reserve cover geometry to prevent reflow. */

export const PROJECT_COVER_ASPECT_RATIO = 16 / 10;

export const ProjectCover = ({ coverUrl }: { coverUrl?: string }) => {
  const [hasFailed, setHasFailed] = useState(false);
  const handleError = useCallback(() => setHasFailed(true), []);
  const showImage = Boolean(coverUrl) && !hasFailed;

  return (
    <Box aspectRatio={PROJECT_COVER_ASPECT_RATIO} bg="bg.muted" overflow="hidden" position="relative" w="full">
      {showImage ? (
        <Image alt="" h="full" objectFit="cover" src={coverUrl} w="full" onError={handleError} />
      ) : (
        <Flex align="center" h="full" justify="center" w="full">
          <Icon aria-hidden as={FolderIcon} boxSize="7" color="fg.subtle" opacity={0.6} />
        </Flex>
      )}
    </Box>
  );
};