-
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.
Add FileUploaderBeta Documentation (#5334)
* Test commit * Add inital documentation for FileUploaderBeta
- Loading branch information
Showing
7 changed files
with
260 additions
and
0 deletions.
There are no files selected for viewing
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
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
21 changes: 21 additions & 0 deletions
21
documentation-site/components/thumbs/components/FileUploaderBeta.jsx
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,21 @@ | ||
/* | ||
Copyright (c) Uber Technologies, Inc. | ||
This source code is licensed under the MIT license found in the | ||
LICENSE file in the root directory of this source tree. | ||
*/ | ||
/* THIS FILE IS AUTO-GENERATED. DO NOT MODIFY. */ | ||
|
||
import React from "react"; | ||
|
||
export default function SvgFileUploaderBeta(props) { | ||
return ( | ||
<svg width={232} height={145} fill="none" {...props}> | ||
<path fill={props.colors[0]} d="M48 37h137v72H48z" /> | ||
<path fill={props.colors[2]} d="M96 75h41v11H96z" /> | ||
<path fill={props.colors[1]} d="M83 59h67v8H83z" /> | ||
<path fill={props.colors[2]} d="M152 94h27v23h-27z" /> | ||
<path fill={props.colors[1]} d="M150 92h27v23h-27z" /> | ||
</svg> | ||
); | ||
} |
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
133 changes: 133 additions & 0 deletions
133
documentation-site/components/yard/config/file-uploader-beta.ts
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,133 @@ | ||
/* | ||
Copyright (c) Uber Technologies, Inc. | ||
This source code is licensed under the MIT license found in the | ||
LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import { FileUploaderBeta } from "baseui/file-uploader-beta"; | ||
import { PropTypes } from "react-view"; | ||
import type { TConfig } from "../types"; | ||
import buttonConfig from "./button"; | ||
|
||
const changeHandlers = [ | ||
"onClick", | ||
"onFocus", | ||
"onBlur", | ||
"onKeyDown", | ||
"onDragStart", | ||
"onDragEnter", | ||
"onDragOver", | ||
"onDragLeave", | ||
"onDrop", | ||
"onDropAccepted", | ||
"onDropRejected", | ||
"onFileDialogCancel", | ||
"onCancel", | ||
"onRetry", | ||
]; | ||
|
||
const FileUploaderBetaConfig: TConfig = { | ||
componentName: "FileUploaderBeta", | ||
imports: { | ||
"baseui/file-uploader-beta": { named: ["FileUploaderBeta"] }, | ||
}, | ||
scope: { | ||
FileUploaderBeta, | ||
}, | ||
theme: [], | ||
props: { | ||
accept: { | ||
value: "", | ||
type: PropTypes.String, | ||
description: | ||
"Set accepted file types. See https://github.com/okonet/attr-accept for more information", | ||
}, | ||
fileRows: { | ||
value: "[]", | ||
type: PropTypes.Array, | ||
description: "Array of file objects.", | ||
stateful: true, | ||
}, | ||
setFileRows: { | ||
value: "newFileRows => setFileRows(newFileRows)", | ||
type: PropTypes.Function, | ||
description: "Function to set file rows.", | ||
}, | ||
maxSize: { | ||
value: undefined, | ||
type: PropTypes.Number, | ||
description: "Maximum file size (in bytes).", | ||
}, | ||
minSize: { | ||
value: undefined, | ||
type: PropTypes.Number, | ||
description: "Minimum file size (in bytes).", | ||
}, | ||
multiple: { | ||
value: undefined, | ||
type: PropTypes.Boolean, | ||
description: | ||
"Allow drag n drop (or selection from the file dialog) of multiple files", | ||
}, | ||
disableClick: { | ||
value: undefined, | ||
type: PropTypes.Boolean, | ||
description: | ||
"Disallow clicking on the dropzone container to open file dialog.", | ||
}, | ||
disabled: { | ||
value: false, | ||
type: PropTypes.Boolean, | ||
description: "Renders component in disabled state.", | ||
}, | ||
errorMessage: { | ||
value: undefined, | ||
type: PropTypes.String, | ||
description: "Error message to be displayed.", | ||
}, | ||
...changeHandlers.reduce((acc, current) => { | ||
//@ts-ignore | ||
acc[current] = { | ||
value: undefined, | ||
type: PropTypes.Function, | ||
description: `Called when the ${current} event is triggered.`, | ||
hidden: true, | ||
}; | ||
return acc; | ||
}, {}), | ||
name: { | ||
value: undefined, | ||
type: PropTypes.String, | ||
description: "Name attribute.", | ||
hidden: true, | ||
}, | ||
["aria-describedby"]: { | ||
value: undefined, | ||
type: PropTypes.String, | ||
description: `Sets aria-describedby attribute.`, | ||
hidden: true, | ||
}, | ||
overrides: { | ||
value: undefined, | ||
type: PropTypes.Custom, | ||
description: "Lets you customize all aspects of the component.", | ||
custom: { | ||
names: [ | ||
{ ...buttonConfig, componentName: "ButtonComponent" }, | ||
{ ...buttonConfig, componentName: "CancelButtonComponent" }, | ||
{ ...buttonConfig, componentName: "RetryButtonComponent" }, | ||
"ContentMessage", | ||
"ErrorMessage", | ||
"FileDragAndDrop", | ||
"HiddenInput", | ||
"Spinner", | ||
"ProgressBar", | ||
], | ||
sharedProps: {}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default FileUploaderBetaConfig; |
36 changes: 36 additions & 0 deletions
36
documentation-site/pages/components/file-uploader-beta.mdx
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 Example from "../../components/example"; | ||
import Layout from "../../components/layout"; | ||
import Exports from "../../components/exports"; | ||
|
||
import * as FileUploaderBetaExports from "baseui/file-uploader-beta"; | ||
|
||
import Yard from "../../components/yard/index"; | ||
import fileUploaderBetaYardConfig from "../../components/yard/config/file-uploader-beta"; | ||
|
||
export default Layout; | ||
|
||
# File Uploader Beta | ||
|
||
<Yard placeholderHeight={120} {...fileUploaderBetaYardConfig} /> | ||
|
||
Creates a dropzone for file uploads. | ||
|
||
## Accessibility | ||
|
||
- "Browse files" has `aria-controls="fileupload"` set. | ||
|
||
## When to use | ||
|
||
- Enable file(s) upload through drag and drop or the system _Browse files_ dialog. | ||
|
||
## Security considerations | ||
|
||
By default, the file uploader does not concern itself with validating and discarding potentially malicious files, as Base Web never runs any of the uploaded files. **It's the responsibility of the consuming application to do so.** To help with that, this component supports the `accept` property, which can limit the acceptable file extensions. | ||
|
||
To learn more, read the corresponding [OWASP article on file uploads](https://www.owasp.org/index.php/Unrestricted_File_Upload). | ||
|
||
<Exports | ||
component={FileUploaderBetaExports} | ||
title="File uploader beta exports" | ||
path="baseui/file-uploader-beta" | ||
/> |
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