1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-26 15:37:41 +01:00
smov/src3/components/text-inputs/TextInputControl.tsx

40 lines
705 B
TypeScript
Raw Normal View History

2022-02-07 23:22:35 +01:00
export interface TextInputControlPropsNoLabel {
onChange?: (data: string) => void;
value?: string;
2022-02-10 23:45:17 +01:00
placeholder?: string;
className?: string;
2022-02-07 23:22:35 +01:00
}
export interface TextInputControlProps extends TextInputControlPropsNoLabel {
label?: string;
}
2022-02-10 23:45:17 +01:00
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}
/>
);
2022-02-07 23:22:35 +01:00
if (label) {
return (
<label>
<span>{label}</span>
{input}
</label>
2022-02-10 23:45:17 +01:00
);
2022-02-07 23:22:35 +01:00
}
return input;
}