2022-11-17 17:34:20 +01:00
|
|
|
import { ChangeEventHandler } from "react";
|
|
|
|
|
|
|
|
export type Props = {
|
2022-11-18 14:11:52 +01:00
|
|
|
contrastBackground?: boolean;
|
2022-11-20 16:54:25 +01:00
|
|
|
prevValue?: string;
|
2022-11-18 14:11:52 +01:00
|
|
|
defaultValue?: string;
|
|
|
|
value?: string;
|
|
|
|
onChange?: ChangeEventHandler<HTMLInputElement>;
|
2022-11-17 17:34:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function TextInput(props: Props) {
|
2022-11-18 14:11:52 +01:00
|
|
|
const bg = props.contrastBackground
|
|
|
|
? "bg-slate-50 dark:bg-slate-700"
|
|
|
|
: "bg-white dark:bg-slate-800";
|
|
|
|
|
|
|
|
return (
|
|
|
|
<input
|
|
|
|
type="text"
|
2022-11-20 16:54:25 +01:00
|
|
|
data-prev-value={props.prevValue ?? props.value}
|
2022-11-18 14:11:52 +01:00
|
|
|
className={`p-1 lg:p-2 rounded-md ${bg} border-slate-300 text-black dark:border-slate-900 dark:text-white`}
|
|
|
|
defaultValue={props.defaultValue}
|
|
|
|
value={props.value}
|
|
|
|
onChange={props.onChange}
|
|
|
|
/>
|
|
|
|
);
|
2022-11-17 17:34:20 +01:00
|
|
|
}
|