fileIcon.tsx 602 B

12345678910111213141516171819202122
  1. import {PlatformIcon} from 'platformicons';
  2. import {IconFile} from 'sentry/icons';
  3. import {fileExtensionToPlatform, getFileExtension} from 'sentry/utils/fileExtension';
  4. import theme from 'sentry/utils/theme';
  5. interface FileIconProps {
  6. fileName: string;
  7. }
  8. function FileIcon({fileName}: FileIconProps) {
  9. const fileExtension = getFileExtension(fileName);
  10. const iconName = fileExtension ? fileExtensionToPlatform(fileExtension) : null;
  11. if (!iconName) {
  12. return <IconFile size="sm" />;
  13. }
  14. return <PlatformIcon platform={iconName} size={theme.iconSizes.sm} />;
  15. }
  16. export default FileIcon;