feat: enhance Input component with placeholder support and styling adjustments
This commit is contained in:
parent
f66ddde6f0
commit
4b8fc0721e
@ -7,6 +7,7 @@ import {
|
|||||||
type RegisterOptions,
|
type RegisterOptions,
|
||||||
} from 'react-hook-form'
|
} from 'react-hook-form'
|
||||||
import { useRemixFormContext } from 'remix-hook-form'
|
import { useRemixFormContext } from 'remix-hook-form'
|
||||||
|
import { twMerge } from 'tailwind-merge'
|
||||||
|
|
||||||
import { EyeIcon } from '~/components/icons/eye'
|
import { EyeIcon } from '~/components/icons/eye'
|
||||||
|
|
||||||
@ -25,7 +26,15 @@ type TInputProperties<T extends FieldValues> = Omit<
|
|||||||
export const Input = <TFormValues extends Record<string, unknown>>(
|
export const Input = <TFormValues extends Record<string, unknown>>(
|
||||||
properties: TInputProperties<TFormValues>,
|
properties: TInputProperties<TFormValues>,
|
||||||
) => {
|
) => {
|
||||||
const { id, label, name, rules, type = 'text', ...rest } = properties
|
const {
|
||||||
|
id,
|
||||||
|
label,
|
||||||
|
name,
|
||||||
|
rules,
|
||||||
|
type = 'text',
|
||||||
|
placeholder,
|
||||||
|
...rest
|
||||||
|
} = properties
|
||||||
const [inputType, setInputType] = useState(type)
|
const [inputType, setInputType] = useState(type)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -46,7 +55,8 @@ export const Input = <TFormValues extends Record<string, unknown>>(
|
|||||||
<input
|
<input
|
||||||
id={id}
|
id={id}
|
||||||
type={inputType}
|
type={inputType}
|
||||||
className="w-full rounded-md border border-[#DFDFDF] p-2"
|
className="h-[42px] w-full rounded-md border border-[#DFDFDF] p-2"
|
||||||
|
placeholder={inputType === 'password' ? '******' : placeholder}
|
||||||
{...register(name, rules)}
|
{...register(name, rules)}
|
||||||
{...rest}
|
{...rest}
|
||||||
/>
|
/>
|
||||||
@ -55,22 +65,17 @@ export const Input = <TFormValues extends Record<string, unknown>>(
|
|||||||
type="button"
|
type="button"
|
||||||
variant="icon"
|
variant="icon"
|
||||||
size="fit"
|
size="fit"
|
||||||
className="absolute top-9 right-3 text-gray-500"
|
className="absolute right-3 h-[42px] text-gray-500"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
setInputType(inputType === 'password' ? 'text' : 'password')
|
setInputType(inputType === 'password' ? 'text' : 'password')
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{inputType === 'password' ? (
|
|
||||||
<EyeIcon
|
<EyeIcon
|
||||||
width={15}
|
className={twMerge(
|
||||||
height={15}
|
'h-4 w-4',
|
||||||
/>
|
inputType === 'password' ? 'text-gray-500/50' : 'text-gray-500',
|
||||||
) : (
|
|
||||||
<EyeIcon
|
|
||||||
width={15}
|
|
||||||
height={15}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -98,6 +98,7 @@ export const FormLogin = (properties: TProperties) => {
|
|||||||
}}
|
}}
|
||||||
className="font-semibold text-[#2E2F7C]"
|
className="font-semibold text-[#2E2F7C]"
|
||||||
variant="link"
|
variant="link"
|
||||||
|
size="fit"
|
||||||
>
|
>
|
||||||
Reset Kata Sandi
|
Reset Kata Sandi
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user