Skip to content

Commit

Permalink
File uploader beta label hint example (#5340)
Browse files Browse the repository at this point in the history
  • Loading branch information
epfeiffe committed Jun 28, 2024
1 parent 88edd5d commit 95af0f9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
20 changes: 0 additions & 20 deletions documentation-site/examples/file-uploader-beta/item-preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,13 @@ 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}
/>
);
Expand Down
14 changes: 14 additions & 0 deletions documentation-site/examples/file-uploader-beta/label-hint.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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>>([]);
return (
<FileUploaderBeta
fileRows={fileRows}
hint={"Test hint"}
label={"Test label"}
setFileRows={setFileRows}
/>
);
}
5 changes: 5 additions & 0 deletions documentation-site/pages/components/file-uploader-beta.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Exports from "../../components/exports";

import FileUploaderBetaBasic from "examples/file-uploader-beta/basic.tsx";
import FileUploaderBetaItemPreview from "examples/file-uploader-beta/item-preview.tsx";
import FileUploaderBetaLabelHint from "examples/file-uploader-beta/label-hint.tsx";
import FileUploaderBetaUploadRestrictions from "examples/file-uploader-beta/upload-restrictions.tsx";

import * as FileUploaderBetaExports from "baseui/file-uploader-beta";
Expand Down Expand Up @@ -50,6 +51,10 @@ To learn more, read the corresponding [OWASP article on file uploads](https://ww
<FileUploaderBetaItemPreview />
</Example>

<Example title="Label and hint" path="file-uploader-beta/label-hint.tsx">
<FileUploaderBetaLabelHint />
</Example>

<Example
title="Upload restrictions"
path="file-uploader-beta/upload-restrictions.tsx"
Expand Down

0 comments on commit 95af0f9

Please sign in to comment.