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

Password toggling functionality #528

Merged
merged 1 commit into from
Jun 24, 2024
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
63 changes: 63 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
},
"dependencies": {
"@fortawesome/fontawesome-free": "^6.5.2",
"@fortawesome/fontawesome-svg-core": "^6.5.2",
"@fortawesome/free-solid-svg-icons": "^6.5.2",
"@fortawesome/react-fontawesome": "^0.2.2",
"@react-oauth/google": "^0.12.1",
"@reduxjs/toolkit": "^2.2.5",
"antd": "^5.17.4",
Expand All @@ -22,6 +25,7 @@
"react-bootstrap": "^2.10.2",
"react-chatbot-kit": "^2.2.2",
"react-dom": "^18.2.0",
"react-fontawesome": "^1.7.1",
"react-icons": "^5.2.1",
"react-redux": "^9.1.2",
"react-router-dom": "^6.23.1",
Expand Down
15 changes: 14 additions & 1 deletion src/Components/Login/Login.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ button {
}

button:hover {
background-color: #0056b3;
background-color: #007bff;
}

.login-container p {
Expand Down Expand Up @@ -90,3 +90,16 @@ p a:hover {
/* justify-content: center;
display: flex; */
}
.eye {
float: right;
left:-9px;
margin-top: -45px;
position: relative;
z-index: 2;
width: 14px; /*Desired width*/
height: 14px; /*Desired height*/
}
.eye:hover {
color: #007efc;
cursor: pointer;
}
18 changes: 17 additions & 1 deletion src/Components/Login/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,25 @@ import React, { useState } from "react";
import { useNavigate, NavLink } from "react-router-dom";
import "./Login.css";
import { GoogleOAuthProvider, GoogleLogin } from '@react-oauth/google';
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; /*react libraries used
for importing eye icon */
import { faEye } from "@fortawesome/free-solid-svg-icons";


const Login = () => {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [warnings, setWarnings] = useState({ email: "", password: "" });
const [isVisible,setVisible] = useState(false);
const navigate = useNavigate();

const eye = <FontAwesomeIcon icon={faEye} />;

const togglePasswordFunction=()=>{ //toggling function for visibility of password
setVisible(isVisible?false:true)
};


const handleLogin = () => {
let emailWarning = "";
let passwordWarning = "";
Expand Down Expand Up @@ -66,8 +78,10 @@ const Login = () => {
}}
/>
{warnings.email && <p style={{ color: "red" }} className="warningmsg">{warnings.email}</p>}

<input
type="password"
type={ isVisible ? "text" : "password"}
className="pasword"
placeholder="Password"
value={password}
onChange={(e) => {
Expand All @@ -80,6 +94,8 @@ const Login = () => {
}
}}
/>
<i className = "eye" onClick={togglePasswordFunction}>{eye}</i>{" "}

{warnings.password && <p style={{ color: "red" }} className="warningmsg">{warnings.password}</p>}
</div>
<button onClick={handleLogin}>Login</button>
Expand Down