import classNames from 'classnames/bind' import Image from './image' import Text from './text' const cx = classNames.bind(_s) export default class FileInput extends PureComponent { static propTypes = { onChange: PropTypes.func, file: PropTypes.any, fileType: PropTypes.string, disabled: PropTypes.bool, title: PropTypes.string, height: PropTypes.string, width: PropTypes.string, } static defaultProps = { fileType: 'image' } state = { file: null, } handleOnChange = (e) => { this.props.onChange(e) this.setState({ file: URL.createObjectURL(e.target.files[0]) }) } render() { const { fileType, disabled, title, height, width, } = this.props const { file } = this.state const imageClasses = cx({ border2PX: 1, borderDashed: 1, borderColorSecondary: 1, backgroundColorPrimary: 1, px10: 1, py10: 1, radiusSmall: 1, cursorPointer: 1, }) return (
{ !!title &&
{title}
}
) } }