11import './uploader.css'
22
33import Box from '@mui/material/Box'
4- import Card from '@mui/material/Card'
54import IconButton from '@mui/material/IconButton'
65import LinearProgress from '@mui/material/LinearProgress'
76import Tooltip from '@mui/material/Tooltip'
@@ -12,10 +11,9 @@ import React, { useEffect, useRef, useState } from 'react'
1211import { createPortal } from 'react-dom'
1312import { v4 as getUUID } from 'uuid'
1413
15- import { shortenString } from '../../../helper '
14+ import FilePreview from '../../../filePreview/filePreview '
1615import type { UploaderProps } from '../../../types'
1716
18- const maximumFileNameLength = 15
1917const maximumLoadingProgress = 100
2018
2119interface FileInfo {
@@ -251,41 +249,33 @@ function Uploader(props: UploaderProps) {
251249 }
252250 }
253251
254- function renderFilePreview ( file : FileInfo , index : number ) {
255- return (
256- < Card className = "rustic-file-preview" key = { index } >
257- < Typography variant = "subtitle2" data-cy = "file-name" >
258- { shortenString ( file . name , maximumFileNameLength ) }
259- </ Typography >
260-
261- < Box className = "rustic-flex-center" >
262- { file . loadingProgress < maximumLoadingProgress && (
263- < LinearProgress
264- variant = "determinate"
265- color = "secondary"
266- value = { file . loadingProgress }
267- className = "rustic-upload-progress"
268- />
269- ) }
270- < Tooltip title = "Delete" >
271- < IconButton
272- data-cy = "delete-button"
273- color = "primary"
274- onClick = { ( ) => handleDelete ( file , index ) }
275- className = "rustic-delete-button"
276- aria-label = "cancel file upload"
277- >
278- < span className = "material-symbols-rounded" > cancel</ span >
279- </ IconButton >
280- </ Tooltip >
281- </ Box >
282- </ Card >
283- )
284- }
285-
286252 const filePreviews = (
287- < Box className = "rustic-files" >
288- { addedFiles . map ( ( file , index ) => renderFilePreview ( file , index ) ) }
253+ < Box className = "rustic-files rustic-padding-16" >
254+ { addedFiles . map ( ( file , index ) => (
255+ < FilePreview file = { { name : file . name } } key = { index } >
256+ < Box className = "rustic-flex-center" >
257+ { file . loadingProgress < maximumLoadingProgress && (
258+ < LinearProgress
259+ variant = "determinate"
260+ color = "secondary"
261+ value = { file . loadingProgress }
262+ className = "rustic-upload-progress"
263+ />
264+ ) }
265+ < Tooltip title = "Delete" >
266+ < IconButton
267+ data-cy = "delete-button"
268+ color = "primary"
269+ onClick = { ( ) => handleDelete ( file , index ) }
270+ className = "rustic-delete-button"
271+ aria-label = "cancel file upload"
272+ >
273+ < span className = "material-symbols-rounded" > cancel</ span >
274+ </ IconButton >
275+ </ Tooltip >
276+ </ Box >
277+ </ FilePreview >
278+ ) ) }
289279 </ Box >
290280 )
291281
0 commit comments