feat: add reusable PasswordInput with show/hide toggle
Replaces all type="password" inputs site-wide with a PasswordInput component that includes an eye icon toggle for visibility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
32
frontend/src/components/common/PasswordInput.tsx
Normal file
32
frontend/src/components/common/PasswordInput.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { useState } from 'react'
|
||||
import { Eye, EyeOff } from 'lucide-react'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
interface PasswordInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type'> {
|
||||
className?: string
|
||||
}
|
||||
|
||||
export function PasswordInput({ className, ...props }: PasswordInputProps) {
|
||||
const [visible, setVisible] = useState(false)
|
||||
|
||||
return (
|
||||
<div className="relative">
|
||||
<input
|
||||
{...props}
|
||||
type={visible ? 'text' : 'password'}
|
||||
className={cn(className, 'pr-10')}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setVisible((v) => !v)}
|
||||
className="absolute right-2 top-1/2 -translate-y-1/2 rounded p-1 text-white/40 hover:bg-white/10 hover:text-white"
|
||||
tabIndex={-1}
|
||||
title={visible ? 'Hide password' : 'Show password'}
|
||||
>
|
||||
{visible ? <EyeOff className="h-4 w-4" /> : <Eye className="h-4 w-4" />}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default PasswordInput
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useState } from 'react'
|
||||
import type { IntakeFormField } from '@/types'
|
||||
import { PasswordInput } from '@/components/common/PasswordInput'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
interface IntakeFormModalProps {
|
||||
@@ -119,8 +120,7 @@ export function IntakeFormModal({ isOpen, fields, treeName, onSubmit, onCancel }
|
||||
|
||||
case 'password':
|
||||
input = (
|
||||
<input
|
||||
type="password"
|
||||
<PasswordInput
|
||||
value={value}
|
||||
onChange={(e) => setValue(field.variable_name, e.target.value)}
|
||||
placeholder={field.placeholder}
|
||||
|
||||
Reference in New Issue
Block a user