Skip to content

Commit

Permalink
Add documentation for FormFileUpload props (#14661)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Mar 27, 2019
1 parent ba64d41 commit 8baf2bb
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
52 changes: 52 additions & 0 deletions packages/components/src/form-file-upload/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,55 @@ const MyFormFileUpload = () => (
</FormFileUpload>
);
```

## Props

The component accepts the following props. Props not included in this set will be passed to the `IconButton` component.

### accept

A string passed to `input` element that tells the browser which file types can be upload to the upload by the user use. e.g: `image/*,video/*`.
More information about this string is available in https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#Unique_file_type_specifiers.

- Type: `String`
- Required: No


### children

Children are passed as children of `IconButton`.

- Type: `Boolean`
- Required: No

### icon

The icon to render. Supported values are: Dashicons (specified as strings), functions, WPComponent instances and `null`.

- Type: `String|Function|WPComponent|null`
- Required: No
- Default: `null`


### multiple

Whether to allow multiple selection of files or not.

- Type: `Boolean`
- Required: No
- Default: `false`

### onChange

Callback function passed directly to the `input` file element.

- Type: `Function`
- Required: Yes

### render

Optional callback function used to render the UI. If passed the component does not render any UI and calls this function to render it.
This function receives an object with the property `openFileDialog`. The property is a function that when called opens the browser window to upload files.

- Type: `Function`
- Required: No
10 changes: 9 additions & 1 deletion packages/components/src/form-file-upload/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ class FormFileUpload extends Component {
}

render() {
const { children, multiple = false, accept, onChange, icon = 'upload', render, ...props } = this.props;
const {
accept,
children,
icon = 'upload',
multiple = false,
onChange,
render,
...props
} = this.props;

const ui = render ?
render( { openFileDialog: this.openFileDialog } ) : (
Expand Down

0 comments on commit 8baf2bb

Please sign in to comment.