comicbox/components/TextInput.tsx
2022-07-25 18:31:20 +01:00

37 lines
965 B
TypeScript

import {
DetailedHTMLProps,
InputHTMLAttributes,
TextareaHTMLAttributes,
} from 'react';
type Props =
| ({ multiline: true } & DetailedHTMLProps<
TextareaHTMLAttributes<HTMLTextAreaElement>,
HTMLTextAreaElement
>)
| ({ multiline: false | undefined } & DetailedHTMLProps<
InputHTMLAttributes<HTMLInputElement>,
HTMLInputElement
>);
export default function TextInput({ multiline, className, ...props }: Props) {
if (multiline) {
return (
<textarea
className={
'bg-slate-600 p-1 overflow-auto rounded ' + className
}
{...(props as any)}
/>
);
} else {
return (
<input
className={
'bg-slate-600 p-1 overflow-auto rounded ' + className
}
{...(props as any)}
/>
);
}
}