files-ui-main-logo
Files ui

FileMosaic

File mosaics 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 FileMosaic

The FileMosaic component supports displaying information from a object or from given props.
Also, the
onDelete
prop is used to remove the file selection.
file created from props.jsx
<>
{value ? (
<FileMosaic {...value} onDelete={removeFile} />
) : (
<FileInputButton value={value ? [value] : []} onChange={updateFiles} />
)}
<FileMosaic {...sampleFileProps} />
</>
// file props
const sampleFileProps = {
id: ":0:",
size: 28 * 1024 * 1024,
type: "text/plain",
name: "file created from props.jsx",
};

Image preview

By setting 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 imageUrlprop 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.
blur Thor arrives wakanda.jpg
Thor arrives wakanda.jpg
<>
{value ? (
<FileMosaic {...value} onDelete={removeFile} info preview/>
) : (
<FileInputButton onChange={updateFile} accept="image/*"/>
)}
<FileMosaic {...sampleFileProps} info/>
</>
// file props
const 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
.
file created from props.jsx
valid file created from props.png
File is too big. File type is not allowed.
non valid file created from props.jpg

Uploading status

The 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 FileMosaic component.

preparing stage

Preparing
preparing file.jsx
Preparing
preparing file.jsx

uploading stage

Uploading
uploading file.png
28 %
Uploading
uploading file.png
Uploading
uploading file.png
Uploading
uploading file.png

upload result stage

Uploading
upload aborted file.gif
Upload was aborted by the user
Uploading
upload with error file.jpg
File couldn't be uploaded to Files-ui earthquakes. File was too big.
Uploading
successfully uploaded file.png
File was uploaded correctly to Files-ui earthquakes

Actions: info, delete, see, watch, download

You can use the following actions.
  • FileMosaic with the onDelete prop will display a delete icon.
  • FileMosaic with the info prop will display an "info" icon that will display an info layer.
  • FileMosaic with the onSee prop will display the "see" button that can be used to retrieve an image
    URI
    obtained by reading a
    File
    object if given or just the
    imageUrl
    prop if given. In the first case, the file must be an image.
  • FileMosaic with the onWatch prop will display the "play" icon that can be used to retrieve the video as a
    File
    object if given or just the
    videoUrl
    prop if given. The file must be an video.
  • FileMosaic with the downloadUrl prop will display the "download" icon that can be used to start the download. If the onDownload prop is given, the "download" icon will also be visible, but it will be taken as the user will perform their own download.
actions sampleFile.jsx
actions sampleFile.jsx
blur actions sampleFile.jsx
actions sampleFile.jsx
actions sampleFile.jsx
actions sampleFile.jsx
actions sampleFile.jsx

Dark mode

The FileMosaic component supports dark mode by setting the prop
darkMode
to
true
.
sampleFile.jsx
sampleFile.jsx
<>
<FileMosaic {...sampleFileProps} info onDelete={removeFile} />
<FileMosaic {...sampleFileProps} info onDelete={removeFile} darkMode/>
</>

Smart image fit

FileMosaic with
smartImgFit
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.
blur (landscape)Thor arrives wakanda.gif
preview (landscape)Thor arrives wakanda.gif
(landscape)Thor arrives wakanda.gif
blur (landscape)Thor arrives wakanda.gif
(landscape)Thor arrives wakanda.gif
blur (landscape)Thor arrives wakanda.gif
(landscape)Thor arrives wakanda.gif
blur (portrait)Iron man in stark tower.gif
preview (portrait)Iron man in stark tower.gif
(portrait)Iron man in stark tower.gif
blur (portrait)Iron man in stark tower.gif
(portrait)Iron man in stark tower.gif
blur (portrait)Iron man in stark tower.gif
(portrait)Iron man in stark tower.gif

API

See the documentation below for a complete reference to all of the props available to the components mentioned here.