Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Add eye icon to toggle password state #248 #249

Merged
merged 5 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pages/login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@ function LoginPage() {
);
}

export default withAnimation(LoginPage);
export default withAnimation(LoginPage);
2 changes: 1 addition & 1 deletion src/pages/signup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ function SignupPage() {
);
}

export default withAnimation(SignupPage);
export default withAnimation(SignupPage);
40 changes: 27 additions & 13 deletions src/shared/components/Input/Input.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import clsx from 'clsx';
import React from 'react';
import React, { useState } from 'react';
import { EyeIcon, EyeOffIcon } from '@heroicons/react/solid';

interface InputProps {
label?: string;
Expand All @@ -25,24 +26,37 @@ function Input({
centeredError,
...props
}: InputProps & React.HTMLProps<HTMLInputElement>) {
const [showPassword, setShowPassword] = useState(false);

return (
<div className="relative">
{label && (
<label className="block text-left font-semibold">{label}</label>
)}
<input
type={type}
value={value}
required={required}
placeholder={placeholder}
onChange={onChange}
className={clsx(
'my-2 block w-full rounded-md border px-4 py-2 shadow focus:outline-none',
error ? ' border-red-400' : ' border-transparent',
className
<div className="relative">
<input
type={showPassword ? 'text' : type}
value={value}
required={required}
placeholder={placeholder}
onChange={onChange}
className={clsx(
'my-2 block w-full rounded-md border px-4 py-2 shadow focus:outline-none',
error ? 'border-red-400' : 'border-transparent',
className
)}
{...props}
/>
{type === 'password' && (
<button
type="button"
className="absolute right-4 top-2"
onClick={() => setShowPassword(!showPassword)}
>
{showPassword ? <EyeIcon className="h-6 w-6 text-gray-500" /> : <EyeOffIcon className="h-6 w-6 text-gray-500" />}
</button>
)}
{...props}
/>
</div>
{!!error && (
<p
className={clsx(
Expand Down
Loading