Skip to content

FileControl

Junaid Bhura edited this page Feb 2, 2019 · 2 revisions

file-control

Usage

import { FileControl } = gumponents.components;

...

attributes: {
	file: {
		type: 'object',
		default: null,
	},
},

...

<FileControl
	label="Choose file"
	selectLabel="Choose video"
	removeLabel="Remove this video"
	onChange={ file => setAttributes( { file: file ? { id: file.id, name: file.filename } : null } ) }
	value={ file ? file.id : null }
/>

Props

label

The label for the control.

  • Type: String
  • Required: No

help

The help text for the control.

  • Type: String
  • Required: No

selectLabel

The label for the select button.

  • Type: String
  • Required: No

removeLabel

The label for the remove button.

  • Type: String
  • Required: No

value

The selected file ID for this control.

  • Type: Array
  • Required: Yes

onChange

A function that receives the values of the control.

  • Type: Function
  • Required: Yes