file uploads
This commit is contained in:
30
frontend/utils/icons.ts
Normal file
30
frontend/utils/icons.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
export function getFileIcon(fileType: string) {
|
||||
if (fileType.startsWith('image/')) {
|
||||
return 'lucide:file-image';
|
||||
}
|
||||
|
||||
if (fileType.startsWith('video/')) {
|
||||
return 'lucide:file-video-2';
|
||||
}
|
||||
|
||||
if (fileType.startsWith('audio/')) {
|
||||
return 'lucide:file-audio-2';
|
||||
}
|
||||
|
||||
if (fileType.startsWith('application/')) {
|
||||
if (fileType === 'application/x-msdownload') {
|
||||
return 'lucide:file-box';
|
||||
}
|
||||
if (fileType === 'application/json') {
|
||||
return 'lucide:file-json';
|
||||
}
|
||||
if (fileType === 'application/pdf') {
|
||||
return 'lucide:file-text';
|
||||
}
|
||||
}
|
||||
if (fileType === 'text/html') {
|
||||
return 'lucide:file-code';
|
||||
}
|
||||
|
||||
return 'lucide:file';
|
||||
}
|
||||
@@ -47,3 +47,16 @@ export function joinPaths(base: string, other: string): string {
|
||||
|
||||
return base + other;
|
||||
}
|
||||
|
||||
export function splitOnce(
|
||||
str: string,
|
||||
search: string
|
||||
): [string, string | null] {
|
||||
const index = str.indexOf(search);
|
||||
|
||||
if (index === -1) {
|
||||
return [str, null];
|
||||
}
|
||||
|
||||
return [str.slice(0, index), str.slice(index + 1)];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user