import React from 'react'; import { connect } from 'react-redux'; import { updateMetadata } from '../actions/index'; /* const textarea = document.getElementById('publish-description'); const limit = 200; textarea.oninput = () => { textarea.style.height = ''; textarea.style.height = Math.min(textarea.scrollHeight, limit) + 'px'; } */ class MetadataInputs extends React.Component { constructor (props) { super(props); this.state = { showInputs : false, descriptionLimit : 100, descriptionHeight: '', }; this.toggleShowInputs = this.toggleShowInputs.bind(this); this.handleDescriptionInput = this.handleDescriptionInput.bind(this); this.handleNsfwCheck = this.handleNsfwCheck.bind(this); this.handleLicenseSelection = this.handleLicenseSelection.bind(this); this.setDescriptionTextBoxHeight = this.setDescriptionTextBoxHeight.bind(this); } toggleShowInputs () { this.setState({'showInputs': !this.state.showInputs}); } handleDescriptionInput (event) { event.preventDefault(); const name = event.target.name; const value = event.target.value; this.props.onMetadataChange(name, value); this.setDescriptionTextBoxHeight(event); } setDescriptionTextBoxHeight (event) { const scrollHeight = event.target.scrollHeight; // console.log('scrollHeight:', scrollHeight); const height = Math.min(scrollHeight, this.state.descriptionLimit) + 'px'; this.setState({descriptionHeight: height}); } handleNsfwCheck (event) { console.log('handle input', event); event.preventDefault(); const name = event.target.name; const value = event.target.checked; this.props.onMetadataChange(name, value); } handleLicenseSelection (event) { const name = event.target.name; const selectedOption = event.target.selectedOptions[0].value; this.props.onMetadataChange(name, selectedOption); } render () { return (