From 9138932d1bcc9a731022c7d1198009e49df8defa Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 25 May 2026 13:02:41 +0200 Subject: [PATCH] feat(docs-ui): include new FileIcon shared module (continuation) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Companion to prior commit — the untracked file-icon.tsx that both EntityFolderView and FileGrid now import. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/components/files/file-icon.tsx | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/components/files/file-icon.tsx diff --git a/src/components/files/file-icon.tsx b/src/components/files/file-icon.tsx new file mode 100644 index 00000000..82c3e2e8 --- /dev/null +++ b/src/components/files/file-icon.tsx @@ -0,0 +1,30 @@ +import { FileText, Film, Image, Sheet } from 'lucide-react'; + +import { cn } from '@/lib/utils'; + +interface FileIconProps { + mimeType: string | null; + className?: string; +} + +/** + * Shared file-type icon mapping. Same colour/glyph palette across FileGrid + * and EntityFolderView so rows in the two surfaces read identically. + */ +export function FileIcon({ mimeType, className }: FileIconProps) { + const base = cn('shrink-0', className ?? 'h-3.5 w-3.5'); + + if (!mimeType) return ; + // eslint-disable-next-line jsx-a11y/alt-text + if (mimeType.startsWith('image/')) return ; + if (mimeType === 'application/pdf') return ; + if ( + mimeType === 'application/vnd.ms-excel' || + mimeType === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || + mimeType === 'text/csv' + ) { + return ; + } + if (mimeType.startsWith('video/')) return ; + return ; +}