more custom elements

This commit is contained in:
SpikeHD
2022-05-10 00:35:50 -07:00
parent 18a74590f9
commit 6dcc91f216
6 changed files with 120 additions and 2 deletions

View File

@@ -0,0 +1,32 @@
import React from 'react'
import './TextInput.css'
interface IProps {
value?: string;
placeholder?: string;
onChange?: (value: string) => void;
readOnly?: boolean;
}
interface IState {
value: string
}
export default class TextInput extends React.Component<IProps, IState> {
constructor(props: IProps) {
super(props)
this.state = {
value: props.value || ''
}
}
render() {
return (
<input readOnly={this.props.readOnly || false} placeholder={this.props.placeholder || ''} className="TextInput" value={this.state.value} onChange={(e) => {
this.setState({ value: e.target.value })
if (this.props.onChange) this.props.onChange(e.target.value)
}} />
)
}
}