Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

1.3 KB
Raw Blame
import { t } from "ttag";

import { HoverCard, Icon, Stack, Text } from "metabase/ui";

type IllustrationType = "background" | "icon";

interface CustomFileUploadInfoDot {
  type: IllustrationType;
}

const DESCRIPTIONS_WIDTHS: Record<IllustrationType, number> = {
  background: 400,
  icon: 250,
};

const getDescriptions = (): Record<IllustrationType, string[]> => ({
  background: [
    t`For best results, choose an image that is horizontally oriented and upload it as an SVG file. Other accepted formats are JPG and PNG.`,
    t`Your file should not be larger than 2MB.`,
  ],
  icon: [
    t`For best results, upload an SVG file. Other accepted formats are JPG and PNG.`,
    t`Your file should not be larger than 2MB.`,
  ],
});

export const ImageUploadInfoDot = ({ type }: CustomFileUploadInfoDot) => {
  return (
    <HoverCard position="top-start">
      <HoverCard.Target>
        <Icon name="info" c="text-secondary" />
      </HoverCard.Target>
      <HoverCard.Dropdown>
        <Stack p="lg" gap="sm" maw={DESCRIPTIONS_WIDTHS[type]}>
          {getDescriptions()[type].map((message, index) => (
            <Text key={index} size="sm">
              {message}
            </Text>
          ))}
        </Stack>
      </HoverCard.Dropdown>
    </HoverCard>
  );
};