FileCard
File cards are compact elements that represent a file in the UI. They can be used for just showing general info of the file, or either to allow the user to interact with them.
This widget allow users to see information of
Files
and / or trigger actions.Basic FileCard
The
Also, the
FileCard
component supports displaying information from a object or from given props.Also, the
onDelete
prop is used to remove the file selection.<> {value ? ( <FileCard {...value} onDelete={removeFile} /> ) : ( <FileInputButton value={value ? [value] : []} onChange={updateFiles} /> )} <FileCard {...sampleFileProps} /></> // file propsconst sampleFileProps = { id: ":0:", size: 28 * 1024 * 1024, type: "text/plain", name: "file created from props.jsx",};
Image preview
By setting the
To acomplish this task this component will take the
Finally, the
preview
prop to true
the component will show an image preview instead of a file icon.To acomplish this task this component will take the
imageUrl
prop or will read the File
object if given and if it is an image.Finally, the
info
prop is used to show the complete information of the file.<> {value ? ( <FileCard {...value} onDelete={removeFile} info preview/> ) : ( <FileInputButton onChange={updateFile} accept="image/*"/> )} <FileCard {...sampleFileProps} info/></> // file propsconst sampleFileProps = { id: "fileId", size: 28 * 1024 * 1024, type: "image/jpeg", name: "Thor arrives wakanda.jpg", imageUrl:"https://cdn.wallpapersafari.com/0/95/1zms6H.jpg"};
Validation
The
valid
prop can be set to true
, false
or undefined
.Uploading status
The
Each of the following examples demonstrates one state combination of the FileCard component.
uploadStatus
prop can be set to "preparing"
, "uploading"
, "aborted"
, "error"
or "success"
. Also the uploadMessage
prop is used for displaying the error or success message. Finally, the progress
prop can be used to show the current progress of the upload process.Each of the following examples demonstrates one state combination of the FileCard component.
preparing stage
Preparing
Preparing
uploading stage
Uploading
Uploading
Uploading
Uploading
upload result stage
Uploading
Uploading
Uploading
Actions: info, delete, see, watch, download
You can use the following actions.
- FileCard with the
onDelete
prop will display a delete icon. - FileCard with the
info
prop will display an "info" icon that will display an info layer. - FileCard with the
onSee
prop will display the "see" button that can be used to retrieve an imageURIobtained by reading aFileobject if given or just theimageUrlprop if given. In the first case, the file must be an image. - FileCard with the
onWatch
prop will display the "play" icon that can be used to retrieve the video as aFileobject if given or just thevideoUrlprop if given. The file must be an video. - FileCard with the
downloadUrl
prop will display the "download" icon that can be used to start the download. If theonDownload
prop is given, the "download" icon will also be visible, but it will be taken as the user will perform their own download.
Dark mode and Elevation
The
FileCard
component supports dark mode by setting the prop darkMode
to true
. The elevation can be used to establish a hierarchy between other content. In practical terms, the elevation controls the size of the shadow applied to the surface. In dark mode, raising the elevation also makes the surface lighter.Smart image fit
FileCard
withsmartImgFit
prop will display image according to its heigh and width.Image with height greater than its width has a "portrait" orientation. Otherwise it has a "landscape" orientation.
API
See the documentation below for a complete reference to all of the props available to the components mentioned here.