import React from 'react'; import PropTypes from 'prop-types'; import Icon from './Icon'; export default class UploadButton extends React.Component { constructor(props) { super(props); } openfile = () => { const input = this.props.inputRef.current; if (this.props.value) { this.props.onChange(''); } else { input.click(); } } attachmentChanged = (event) => { this.props.onChange(event.target.value); } render() { return (
e.stopPropagation()} style={{ display: 'none' }} ref={this.props.inputRef} value={this.props.value} onChange={this.attachmentChanged} />
); } } UploadButton.propTypes = { value: PropTypes.string.isRequired, onChange: PropTypes.func.isRequired, inputRef: PropTypes.shape({ current: PropTypes.instanceOf(Element) }) }; const inactiveStyle = { cursor: 'pointer', color: '#888' }; const activeStyle = { cursor: 'pointer', color: 'green' };