Skip to content

Commit

Permalink
fix: improve password imputs and default behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
grzegorzpokorski committed Nov 24, 2023
1 parent 1405d48 commit ba1f380
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
42 changes: 22 additions & 20 deletions src/checkout/components/PasswordInput/PasswordInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,29 @@ export const PasswordInputComponent = <TName extends string>({
<label className="text-xs text-neutral-700">
{label}
{required && <span aria-hidden="true">*</span>}
<div className="relative mt-1 flex items-stretch shadow-sm">
<input
required={required}
spellCheck={false}
type={passwordVisible ? "text" : "password"}
autoCapitalize="off"
autoComplete="off"
{...field}
{...props}
className={clsx(
"block w-full appearance-none rounded-md border-neutral-300 pr-10 transition-colors focus:border-neutral-300 focus:outline-none focus:ring focus:ring-neutral-200 focus:ring-opacity-50 active:border-neutral-200 active:outline-none",
{ "border-red-300": error },
props.className,
)}
/>
<IconButton
ariaLabel="change password visibility"
onClick={() => setPasswordVisible(!passwordVisible)}
icon={passwordVisible ? <EyeIcon /> : <EyeHiddenIcon />}
className="absolute right-0 mt-px flex h-10 w-10 items-center justify-center rounded-md text-center focus:border-neutral-300 focus:outline-none focus:ring focus:ring-neutral-200 focus:ring-opacity-50 active:border-neutral-200 active:outline-none"
/>
</div>
</label>
<div className="relative mt-1 flex items-stretch shadow-sm">
<input
required={required}
spellCheck={false}
type={passwordVisible ? "text" : "password"}
{...field}
{...props}
className={clsx(
"block w-full appearance-none rounded-md border-neutral-300 pr-10 transition-colors focus:border-neutral-300 focus:outline-none focus:ring focus:ring-neutral-200 focus:ring-opacity-50 active:border-neutral-200 active:outline-none",
{ "border-red-300": error },
props.className,
)}
/>
<IconButton
ariaLabel="change password visibility"
onClick={() => setPasswordVisible(!passwordVisible)}
icon={passwordVisible ? <EyeIcon /> : <EyeHiddenIcon />}
className="absolute right-0 mt-px flex h-10 w-10 items-center justify-center rounded-md text-center focus:border-neutral-300 focus:outline-none focus:ring focus:ring-neutral-200 focus:ring-opacity-50 active:border-neutral-200 active:outline-none"
/>
</div>
</div>
{error && <p className="text-sm text-red-500">{error}</p>}
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/ui/components/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export function LoginForm() {
type="password"
name="password"
placeholder="Password"
autoCapitalize="off"
autoComplete="off"
className="w-full rounded border bg-neutral-50 px-4 py-2"
value={formValues.password}
onChange={changeHandler}
Expand Down

0 comments on commit ba1f380

Please sign in to comment.