Created
August 1, 2018 16:39
-
-
Save grantglidewell/e8aef5e2bb966e3bd87a616630cc39b2 to your computer and use it in GitHub Desktop.
This file contains 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 TextFieldType extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
textInput: "" | |
}; | |
} | |
render() { | |
const { textInput } = this.state; | |
return ( | |
<article | |
className={`${styles.TextFieldType} ${ | |
textInput.length > this.props.charCount ? styles.Error : "" | |
}`} | |
> | |
<div className={styles.TextFieldTypeLabel}> | |
<label>{this.props.label}</label> | |
<span> | |
{textInput.length}/{this.props.charCount} | |
</span> | |
</div> | |
<Input type="text" 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