-
Notifications
You must be signed in to change notification settings - Fork 827
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
File uploader beta item preview example (#5339)
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
documentation-site/examples/file-uploader-beta/item-preview.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import * as React from "react"; | ||
import { FileUploaderBeta, type FileRow } from "baseui/file-uploader-beta"; | ||
|
||
export default function Example() { | ||
const [fileRows, setFileRows] = React.useState<Array<FileRow>>([]); | ||
|
||
const processFileOnDrop = ( | ||
file: File, | ||
): Promise<{ errorMessage: string | null; fileInfo?: any }> => { | ||
return new Promise((resolve) => { | ||
// Fake an upload process for 2 seconds | ||
// For a real-world scenario, replace this with application upload logic | ||
setTimeout(() => { | ||
let fileInfo = { | ||
file, | ||
objectID: "1234", | ||
uploadID: "1234", | ||
uploadStatus: "success", | ||
}; | ||
resolve({ errorMessage: null, fileInfo }); | ||
}, 2000); | ||
}); | ||
}; | ||
|
||
return ( | ||
<FileUploaderBeta | ||
fileRows={fileRows} | ||
hint={ | ||
"Try uploading a file to see the item preview. Image files will show a thumbnail." | ||
} | ||
itemPreview | ||
processFileOnDrop={processFileOnDrop} | ||
setFileRows={setFileRows} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters