1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-27 15:47:41 +01:00
smov/src/components/TextInputs/TextInputControl.tsx

24 lines
530 B
TypeScript
Raw Normal View History

2022-02-07 23:22:35 +01:00
export interface TextInputControlPropsNoLabel {
onChange?: (data: string) => void;
value?: string;
}
export interface TextInputControlProps extends TextInputControlPropsNoLabel {
label?: string;
}
export function TextInputControl({ onChange, value, label }: TextInputControlProps) {
const input = <input type="text" onChange={(e) => onChange && onChange(e.target.value)} value={value} />
if (label) {
return (
<label>
<span>{label}</span>
{input}
</label>
)
}
return input;
}