@@ -10,14 +10,14 @@ interface FileCardProps {
1010 onDelete ?: ( id : string ) => void ;
1111}
1212
13- function getFileIcon ( filename ?: string ) {
13+ function FileIcon ( { filename, size = 24 } : { filename ?: string ; size ?: number } ) {
1414 const ext = ( filename || '' ) . split ( '.' ) . pop ( ) ?. toLowerCase ( ) || '' ;
15- if ( [ 'pdf' , 'doc' , 'docx' , 'txt' , 'rtf' , 'odt' ] . includes ( ext ) ) return FileText ;
16- if ( [ 'zip' , 'rar' , '7z' , 'tar' , 'gz' , 'bz2' ] . includes ( ext ) ) return FileArchive ;
17- if ( [ 'jpg' , 'jpeg' , 'png' , 'gif' , 'webp' , 'bmp' , 'svg' ] . includes ( ext ) ) return FileImage ;
18- if ( [ 'mp4' , 'avi' , 'mkv' , 'mov' , 'wmv' , 'flv' ] . includes ( ext ) ) return FileVideo ;
19- if ( [ 'mp3' , 'wav' , 'ogg' , 'flac' , 'aac' , 'm4a' , 'webm' ] . includes ( ext ) ) return FileAudio ;
20- return File ;
15+ if ( [ 'pdf' , 'doc' , 'docx' , 'txt' , 'rtf' , 'odt' ] . includes ( ext ) ) return < FileText size = { size } /> ;
16+ if ( [ 'zip' , 'rar' , '7z' , 'tar' , 'gz' , 'bz2' ] . includes ( ext ) ) return < FileArchive size = { size } /> ;
17+ if ( [ 'jpg' , 'jpeg' , 'png' , 'gif' , 'webp' , 'bmp' , 'svg' ] . includes ( ext ) ) return < FileImage size = { size } /> ;
18+ if ( [ 'mp4' , 'avi' , 'mkv' , 'mov' , 'wmv' , 'flv' ] . includes ( ext ) ) return < FileVideo size = { size } /> ;
19+ if ( [ 'mp3' , 'wav' , 'ogg' , 'flac' , 'aac' , 'm4a' , 'webm' ] . includes ( ext ) ) return < FileAudio size = { size } /> ;
20+ return < File size = { size } /> ;
2121}
2222
2323function formatFileSize ( bytes ?: number ) : string {
@@ -38,15 +38,14 @@ function getFileColor(filename?: string): string {
3838
3939export const FileCard = memo ( function FileCard ( { item, onShare, onDelete } : FileCardProps ) {
4040 const { lang, t } = useLanguage ( ) ;
41- const IconComponent = getFileIcon ( item . filename ) ;
4241 const colorClass = getFileColor ( item . filename ) ;
4342 const ext = ( item . filename || '' ) . split ( '.' ) . pop ( ) ?. toUpperCase ( ) || 'FILE' ;
4443
4544 return (
4645 < div className = "break-inside-avoid bg-white dark:bg-slate-800 shadow-sm border border-slate-200/70 dark:border-slate-700/70 hover:shadow-xl hover:-translate-y-0.5 transition-all duration-300 rounded-[1.25rem] overflow-hidden group relative" >
4746 < div className = "p-5 flex items-center gap-4" >
4847 < div className = { `w-12 h-12 rounded-xl flex items-center justify-center shrink-0 ${ colorClass } ` } >
49- < IconComponent size = { 24 } />
48+ < FileIcon filename = { item . filename } size = { 24 } />
5049 </ div >
5150 < div className = "flex-1 min-w-0" >
5251 < p className = "text-sm font-medium text-slate-700 dark:text-slate-200 truncate" title = { item . filename } >
0 commit comments