1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-25 15:27:40 +01:00
smov/src3/components/text-inputs/TextInputControl.tsx
2022-03-13 19:08:28 +01:00

39 lines
705 B
TypeScript

export interface TextInputControlPropsNoLabel {
onChange?: (data: string) => void;
value?: string;
placeholder?: string;
className?: string;
}
export interface TextInputControlProps extends TextInputControlPropsNoLabel {
label?: string;
}
export function TextInputControl({
onChange,
value,
label,
className,
placeholder,
}: TextInputControlProps) {
const input = (
<input
type="text"
className={className}
placeholder={placeholder}
onChange={(e) => onChange && onChange(e.target.value)}
value={value}
/>
);
if (label) {
return (
<label>
<span>{label}</span>
{input}
</label>
);
}
return input;
}