Skip to content

Commit

Permalink
feat: change password type
Browse files Browse the repository at this point in the history
  • Loading branch information
AtulPant2704 committed May 27, 2022
1 parent 2f7bb13 commit 679d41e
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 13 deletions.
16 changes: 16 additions & 0 deletions src/pages/Authentication/Authentication.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,19 @@
.user-history label {
margin-left: 5px;
}

.form-wrapper label span {
color: var(--danger-color);
}

.form-wrapper .input-wrapper {
width: 100%;
position: relative;
}

.form-wrapper .password-icon {
position: absolute;
right: 3%;
top: 43%;
cursor: pointer;
}
24 changes: 20 additions & 4 deletions src/pages/Authentication/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const Login = () => {
password: "",
});
const [rememberMe, setRememberMe] = useState(false);
const [passwordType, setPasswordType] = useState("password");

const guestUser = {
email: "[email protected]",
Expand Down Expand Up @@ -94,7 +95,9 @@ const Login = () => {
<h2 className="form-heading">Login</h2>
<form className="login">
<div className="form-email">
<label htmlFor="email">Email address</label>
<label htmlFor="email">
Email address <span>*</span>
</label>
<input
id="email"
type="email"
Expand All @@ -105,17 +108,30 @@ const Login = () => {
onChange={changeHandler}
/>
</div>
<div className="form-password">
<label htmlFor="password">Password</label>
<div className="form-password input-wrapper">
<label htmlFor="password">
Password <span>*</span>
</label>
<input
id="password"
type="password"
type={passwordType}
placeholder="********"
name="password"
value={user.password}
required
onChange={changeHandler}
/>
{passwordType === "password" ? (
<i
className="fa-solid fa-eye password-icon"
onClick={() => setPasswordType("text")}
></i>
) : (
<i
className="fa-solid fa-eye-slash password-icon"
onClick={() => setPasswordType("password")}
></i>
)}
</div>
<div className="user-history">
<input
Expand Down
52 changes: 43 additions & 9 deletions src/pages/Authentication/SignUp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const SignUp = () => {
lastName: "",
confirmPassword: "",
});
const [passwordType, setPasswordType] = useState("password");
const [confirmPasswordType, setConfirmPasswordType] = useState("password");

const changeHandler = (event) => {
const { name, value } = event.target;
Expand Down Expand Up @@ -76,7 +78,9 @@ const SignUp = () => {
<h2 className="form-heading">Signup</h2>
<form action="" method="post">
<div className="form-username">
<label htmlFor="first-name">First Name</label>
<label htmlFor="first-name">
First Name <span>*</span>
</label>
<input
id="first-name"
type="text"
Expand All @@ -86,7 +90,9 @@ const SignUp = () => {
required
onChange={changeHandler}
/>
<label htmlFor="last-name">Last Name</label>
<label htmlFor="last-name">
Last Name <span>*</span>
</label>
<input
id="last-name"
type="text"
Expand All @@ -98,7 +104,9 @@ const SignUp = () => {
/>
</div>
<div className="form-email">
<label htmlFor="email">Email address</label>
<label htmlFor="email">
Email address <span>*</span>
</label>
<input
id="email"
type="email"
Expand All @@ -109,29 +117,55 @@ const SignUp = () => {
onChange={changeHandler}
/>
</div>
<div className="form-password">
<label htmlFor="password">Password</label>
<div className="form-password input-wrapper">
<label htmlFor="password">
Password <span>*</span>
</label>
<input
id="password"
type="password"
type={passwordType}
placeholder="********"
name="password"
value={user.password}
required
onChange={changeHandler}
/>
{passwordType === "password" ? (
<i
className="fa-solid fa-eye password-icon"
onClick={() => setPasswordType("text")}
></i>
) : (
<i
className="fa-solid fa-eye-slash password-icon"
onClick={() => setPasswordType("password")}
></i>
)}
</div>
<div className="form-confirm-password">
<label htmlFor="confirm-password">Confirm Password</label>
<div className="form-confirm-password input-wrapper">
<label htmlFor="confirm-password">
Confirm Password <span>*</span>
</label>
<input
id="confirm-password"
type="password"
type={confirmPasswordType}
placeholder="********"
name="confirmPassword"
value={user.confirmPassword}
required
onChange={changeHandler}
/>
{confirmPasswordType === "password" ? (
<i
className="fa-solid fa-eye password-icon"
onClick={() => setConfirmPasswordType("text")}
></i>
) : (
<i
className="fa-solid fa-eye-slash password-icon"
onClick={() => setConfirmPasswordType("password")}
></i>
)}
</div>
<button
type="submit"
Expand Down

0 comments on commit 679d41e

Please sign in to comment.