Created
August 1, 2018 16:40
-
-
Save grantglidewell/b2ef988a3cf77f2b75b2acca064c075e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class TextareaFieldType extends Component { | |
constructor(props) { | |
super(props) | |
this.state = { | |
textInput: '' | |
} | |
} | |
render() { | |
const { textInput } = this.state | |
return ( | |
<article | |
className={`${styles.TextareaFieldType} ${ | |
textInput.length > this.props.charCount ? styles.Error : '' | |
}`}> | |
<div className={styles.TextareaFieldTypeLabel}> | |
<label>{this.props.label}</label> | |
<span> | |
{textInput.length}/{this.props.charCount} | |
</span> | |
</div> | |
<textarea | |
className={styles.TextArea} | |
onChange={this.onChange} | |
value={textInput} | |
/> | |
</article> | |
) | |
} | |
onChange = evt => { | |
this.setState({ | |
textInput: evt.target.value | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment