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

show password state management #76

Open
wants to merge 1 commit into
base: dev_team2
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions Frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.6.0",
"react-router-dom": "^6.4.2"
},
"devDependencies": {
Expand Down
29 changes: 25 additions & 4 deletions Frontend/src/pages/login/Login.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
import React from "react"
import React, { useState } from "react"
import "./login.css"
import { Link } from "react-router-dom"
import { AiOutlineEyeInvisible, AiOutlineEye } from "react-icons/ai";

function Login() {
const [ emailInput, setEmailInput] = useState("");
const[ passwordInput, setPasswordInput] = useState("");
const [ passwordType, setPasswordType] = useState("password");
const [isPassword, setIsPassword] = useState(true);

const handleToggle = () => {
if (isPassword) {
setPasswordType("text")
setIsPassword(false);
} else {
setPasswordType("password");
setIsPassword(true);
}
return setIsPassword(!isPassword);
}

return (
<div>
<section className="container forms">
Expand All @@ -24,16 +41,20 @@ function Login() {

<form action="#">
<div className="field input-field">
<input type="email" placeholder="Email" className="input" />
<input value={emailInput} type="email" placeholder="Email" className="input" onChange={(e) => setEmailInput(e.target.value)}/>
</div>

<div className="field input-field">
<input
type="password"
value={passwordInput}
type={passwordType}
placeholder="Password"
className="password"
onChange={(e) => setPasswordInput(e.target.value)}
/>
<i className="bx bx-hide eye-icon" />
<div role="presentation" className="eye-icon" onClick={handleToggle}>
{isPassword ? <AiOutlineEye /> : <AiOutlineEyeInvisible />}
</div>
</div>

<div className="field button-field">
Expand Down
30 changes: 25 additions & 5 deletions Frontend/src/pages/signup/Signup.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
import React from "react"
import React, { useState } from "react"
import "./signup.css"
import { Link } from "react-router-dom"
import { AiOutlineEyeInvisible, AiOutlineEye } from "react-icons/ai"

function Signup() {
const [ nameInput, setNameInput] = useState("");
const [ emailInput, setEmailInput] = useState("");
const [ passwordInput, setPasswordInput] = useState("");
const [ passwordType, setPasswordType] = useState("password");
const [ isPassword, setIsPassword] = useState(true);

const handleToggle = () => {
if (isPassword) {
setPasswordType("text")
setIsPassword(false);
} else {
setPasswordType("password");
setIsPassword(true);
}
return setIsPassword(!isPassword);
}
return (
<section className="container forms">
<div className="form login">
Expand All @@ -11,15 +28,18 @@ function Signup() {

<form action="#">
<div className="field input-field">
<input type="text" placeholder="Full Name" className="input" />
<input value={nameInput} type="text" placeholder="Full Name" className="input" onChange={(e) => setNameInput(e.target.value)} />
</div>

<div className="field input-field">
<input type="email" placeholder="Email" className="input" />
<input value={emailInput} type="email" placeholder="Email" className="input" onChange={(e) => setEmailInput(e.target.value)}/>
</div>
<div className="field input-field">
<input type="password" placeholder="Password" className="password" />
<i className="bx bx-hide eye-icon" />
<input value={passwordInput} type={passwordType} placeholder="Password" className="password" onChange={(e) => setPasswordInput(e.target.value)}/>

<div role="presentation" className="eye-icon" onClick={handleToggle}>
{isPassword ? <AiOutlineEye /> : <AiOutlineEyeInvisible />}
</div>
</div>

<div className="field button-field">
Expand Down