-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add password visibility button to authentication pages (#572)
* LoginForm Visibility Feature * Others Pages Password Visibility Feature * `register/[uuid].js` Password Visibility Feature * Ran Formatter * Created PasswordInput component * Add cursors-pointer style * Ran formatter * GH requested Changes * Fixed name/id props * Removing right Props from Input * Adding ids props and some fixes * removed type props * Revert "Removing right Props from Input" This reverts commit 3ac9ec6. * InputBase Wrapper Component
- Loading branch information
Showing
6 changed files
with
121 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { forwardRef, useState } from "react"; | ||
|
||
import { InputBase, InputDefaultProps } from "@components/Input"; | ||
|
||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import { faEye, faEyeSlash } from "@fortawesome/free-solid-svg-icons"; | ||
|
||
export default forwardRef<HTMLInputElement, InputDefaultProps>( | ||
function PasswordInput( | ||
{ text, id, name, type, fgColor, bgColor, enabled, ...rest }, | ||
ref | ||
) { | ||
const [isPasswordVisible, setIsPasswordVisible] = useState(false); | ||
|
||
const togglePasswordVisibility = () => { | ||
setIsPasswordVisible(!isPasswordVisible); | ||
}; | ||
|
||
return ( | ||
<InputBase | ||
text={text} | ||
id={id} | ||
fgColor={fgColor} | ||
bgColor={bgColor} | ||
enabled={enabled} | ||
> | ||
<input | ||
id={id} | ||
name={name} | ||
type={isPasswordVisible ? "text" : "password"} | ||
required | ||
className="w-full bg-transparent outline-none" | ||
disabled={enabled == false} | ||
ref={ref} | ||
{...rest} | ||
/> | ||
<FontAwesomeIcon | ||
className="mx-2 cursor-pointer" | ||
onClick={togglePasswordVisibility} | ||
icon={isPasswordVisible ? faEyeSlash : faEye} | ||
/> | ||
</InputBase> | ||
); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters