Skip to content

Added the eyeicon for passwords #2480

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

Closed
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
Binary file added client/images/hide.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/images/view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 18 additions & 10 deletions client/modules/User/components/LoginForm.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import React from 'react';
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Form, Field } from 'react-final-form';
import { useDispatch } from 'react-redux';
import Button from '../../../common/Button';
import { validateLogin } from '../../../utils/reduxFormUtils';
import { validateAndLoginUser } from '../actions';
import viewimg from '../../../images/view.png';
import hideimg from '../../../images/hide.png';

function LoginForm() {
const { t } = useTranslation();

const [showpassword, setShowpassword] = useState(false);
const dispatch = useDispatch();

function onSubmit(formProps) {
return dispatch(validateAndLoginUser(formProps));
}
Expand Down Expand Up @@ -48,14 +51,19 @@ function LoginForm() {
<label htmlFor="password" className="form__label">
{t('LoginForm.Password')}
</label>
<input
className="form__input"
aria-label={t('LoginForm.PasswordARIA')}
type="password"
id="password"
autoComplete="current-password"
{...field.input}
/>
<div className="form__password-div">
<input
className="form__input"
aria-label={t('LoginForm.PasswordARIA')}
type={showpassword ? 'text' : 'password'}
id="password"
autoComplete="current-password"
{...field.input}
/>
<button onClick={() => setShowpassword(!showpassword)}>
<img src={showpassword ? viewimg : hideimg} alt="" />
</button>
</div>
{field.meta.touched && field.meta.error && (
<span className="form-error">{field.meta.error}</span>
)}
Expand Down
26 changes: 17 additions & 9 deletions client/modules/User/components/SignupForm.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React from 'react';
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Form, Field } from 'react-final-form';
import { useDispatch } from 'react-redux';
import { validateSignup } from '../../../utils/reduxFormUtils';
import { validateAndSignUpUser } from '../actions';
import Button from '../../../common/Button';
import apiClient from '../../../utils/apiClient';
import viewimg from '../../../images/view.png';
import hideimg from '../../../images/hide.png';

function asyncValidate(fieldToValidate, value) {
if (!value || value.trim().length === 0)
Expand Down Expand Up @@ -33,6 +35,7 @@ function validateEmail(email) {

function SignupForm() {
const { t } = useTranslation();
const [showpassword, setShowpassword] = useState(false);

const dispatch = useDispatch();
function onSubmit(formProps) {
Expand Down Expand Up @@ -97,14 +100,19 @@ function SignupForm() {
<label htmlFor="password" className="form__label">
{t('SignupForm.Password')}
</label>
<input
className="form__input"
aria-label={t('SignupForm.PasswordARIA')}
type="password"
id="password"
autoComplete="new-password"
{...field.input}
/>
<div className="form__password-div">
<input
className="form__input"
aria-label={t('SignupForm.PasswordARIA')}
type={showpassword ? 'text' : 'password'}
id="password"
autoComplete="new-password"
{...field.input}
/>
<button onClick={() => setShowpassword(!showpassword)}>
<img src={showpassword ? viewimg : hideimg} alt="" />
</button>
</div>
{field.meta.touched && field.meta.error && (
<span className="form-error">{field.meta.error}</span>
)}
Expand Down
22 changes: 22 additions & 0 deletions client/styles/components/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,28 @@
margin-left: auto;
margin-right: auto;
}

.form__password-div {
display: flex;
align-items: center;
max-width: 90vw;
width: #{360 / $base-font-size}rem;
}
.form__password-div button{
display: flex;
padding: 0 2px;
}
.form__password-div button:focus{
box-shadow: none;
}
.form__password-div img{
width: 30px;

@media (max-width: 770px) {
width: 24px;
}
}


// .form [type="submit"] {
// @extend %button;
Expand Down