Files
warren/frontend/utils/icons.ts

44 lines
1.1 KiB
TypeScript

export function getFileIcon(mimeType: string | null) {
if (mimeType == null) {
return 'lucide:file';
}
if (mimeType.startsWith('image/')) {
return 'lucide:file-image';
}
if (mimeType.startsWith('video/')) {
return 'lucide:file-video-2';
}
if (mimeType.startsWith('audio/')) {
return 'lucide:file-audio-2';
}
if (mimeType.startsWith('application/')) {
if (mimeType === 'application/x-msdownload') {
return 'lucide:file-box';
}
if (mimeType === 'application/json') {
return 'lucide:file-json';
}
if (mimeType === 'application/pdf') {
return 'lucide:file-text';
}
if (mimeType === 'application/zip') {
return 'lucide:file-archive';
}
if (
mimeType === 'application/epub+zip' ||
mimeType === 'application/x-mobipocket-ebook'
) {
return 'lucide:file-text';
}
}
if (mimeType === 'text/html') {
return 'lucide:file-code';
}
return 'lucide:file';
}