Created
August 1, 2018 16:52
-
-
Save grantglidewell/136c45ad86690eb1c1475d8ba4a8a7f2 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 UrlFieldType extends Component { | |
constructor(props) { | |
super(props) | |
this.state = { | |
textInput: '' | |
} | |
} | |
render() { | |
const { textInput } = this.state | |
return ( | |
<article | |
className={`${styles.UrlFieldType} ${ | |
textInput.length > this.props.charCount ? styles.Error : '' | |
}`}> | |
<div className={styles.UrlFieldTypeLabel}> | |
<label>{this.props.label}</label> | |
<span> | |
{textInput.length}/{this.props.charCount} | |
</span> | |
</div> | |
<Input type="url" 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