comicbox/components/TextInput.tsx

40 lines
1.1 KiB
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
}
2022-07-25 17:37:35 +00:00
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2022-07-25 17:31:20 +00:00
{...(props as any)}
/>
);
} else {
2022-07-25 17:31:20 +00:00
return (
<input
className={
'bg-slate-600 p-1 overflow-auto rounded ' + className
}
2022-07-25 17:37:35 +00:00
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2022-07-25 17:31:20 +00:00
{...(props as any)}
/>
);
}
}