comicbox/components/TextInput.tsx

38 lines
965 B
TypeScript
Raw Normal View History

2022-07-25 17:31:20 +00:00
import {
DetailedHTMLProps,
InputHTMLAttributes,
TextareaHTMLAttributes,
} from 'react';
2022-07-25 17:31:20 +00:00
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) {
2022-07-25 17:31:20 +00:00
return (
<textarea
className={
'bg-slate-600 p-1 overflow-auto rounded ' + className
}
{...(props as any)}
/>
);
} else {
2022-07-25 17:31:20 +00:00
return (
<input
className={
'bg-slate-600 p-1 overflow-auto rounded ' + className
}
{...(props as any)}
/>
);
}
}