2023-07-06 11:47:08 -04:00
|
|
|
import React, { ChangeEvent, FC } from 'react';
|
|
|
|
|
import { Input, Label } from '~/components';
|
2023-05-18 04:51:30 +05:30
|
|
|
import { cn } from '~/utils/';
|
|
|
|
|
|
2023-07-06 11:47:08 -04:00
|
|
|
interface InputWithLabelProps {
|
|
|
|
|
value: string;
|
|
|
|
|
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
|
|
|
label: string;
|
|
|
|
|
id: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const InputWithLabel: FC<InputWithLabelProps> = ({ value, onChange, label, id }) => {
|
2023-05-18 04:51:30 +05:30
|
|
|
const defaultTextProps =
|
|
|
|
|
'rounded-md border border-gray-300 bg-transparent text-sm shadow-[0_0_10px_rgba(0,0,0,0.10)] outline-none placeholder:text-gray-400 focus:outline-none focus:ring-gray-400 focus:ring-opacity-20 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-400 dark:bg-gray-700 dark:text-gray-50 dark:shadow-[0_0_15px_rgba(0,0,0,0.10)] dark:focus:border-gray-400 dark:focus:outline-none dark:focus:ring-0 dark:focus:ring-gray-400 dark:focus:ring-offset-0';
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
2023-05-18 11:09:31 -07:00
|
|
|
<Label htmlFor={id} className="text-left text-sm font-medium">
|
2023-05-18 04:51:30 +05:30
|
|
|
{label}
|
|
|
|
|
<br />
|
|
|
|
|
</Label>
|
|
|
|
|
|
|
|
|
|
<Input
|
|
|
|
|
id={id}
|
|
|
|
|
value={value || ''}
|
|
|
|
|
onChange={onChange}
|
|
|
|
|
placeholder={`Enter ${label}`}
|
|
|
|
|
className={cn(
|
|
|
|
|
defaultTextProps,
|
2023-07-14 09:36:49 -04:00
|
|
|
'flex h-10 max-h-10 w-full resize-none px-3 py-2 focus:outline-none focus:ring-0 focus:ring-opacity-0 focus:ring-offset-0',
|
2023-05-18 04:51:30 +05:30
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default InputWithLabel;
|