mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-15 08:34:43 +01:00
more custom elements
This commit is contained in:
32
src/ui/components/common/TextInput.tsx
Normal file
32
src/ui/components/common/TextInput.tsx
Normal 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)
|
||||
}} />
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user