Skip to content

Instantly share code, notes, and snippets.

@grantglidewell
Created August 1, 2018 16:52
Show Gist options
  • Save grantglidewell/136c45ad86690eb1c1475d8ba4a8a7f2 to your computer and use it in GitHub Desktop.
Save grantglidewell/136c45ad86690eb1c1475d8ba4a8a7f2 to your computer and use it in GitHub Desktop.
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