Skip to content

Added eye icon #2467

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

Merged
merged 9 commits into from
Jun 12, 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
52 changes: 35 additions & 17 deletions client/modules/User/components/LoginForm.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
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 { AiOutlineEye, AiOutlineEyeInvisible } from 'react-icons/ai';
import Button from '../../../common/Button';
import { validateLogin } from '../../../utils/reduxFormUtils';
import { validateAndLoginUser } from '../actions';
Expand All @@ -13,6 +14,10 @@ function LoginForm() {
function onSubmit(formProps) {
return dispatch(validateAndLoginUser(formProps));
}
const [showPassword, setShowPassword] = useState(false);
const handleVisibility = () => {
setShowPassword(!showPassword);
};

return (
<Form
Expand Down Expand Up @@ -45,22 +50,35 @@ function LoginForm() {
</Field>
<Field name="password">
{(field) => (
<p className="form__field">
<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}
/>
{field.meta.touched && field.meta.error && (
<span className="form-error">{field.meta.error}</span>
)}
</p>
<div>
<p className="form__field">
<label htmlFor="password" className="form__label">
{t('LoginForm.Password')}
</label>
<button
className="form__eye__icon"
type="button"
onClick={handleVisibility}
>
{showPassword ? (
<AiOutlineEyeInvisible />
) : (
<AiOutlineEye />
)}
</button>
<input
className="form__input"
aria-label={t('LoginForm.PasswordARIA')}
type={showPassword ? 'text' : 'password'}
id="password"
autoComplete="current-password"
{...field.input}
/>
{field.meta.touched && field.meta.error && (
<span className="form-error">{field.meta.error}</span>
)}
</p>
</div>
)}
</Field>
{submitError && !modifiedSinceLastSubmit && (
Expand Down
101 changes: 68 additions & 33 deletions client/modules/User/components/SignupForm.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
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 { AiOutlineEye, AiOutlineEyeInvisible } from 'react-icons/ai';
import { validateSignup } from '../../../utils/reduxFormUtils';
import { validateAndSignUpUser } from '../actions';
import Button from '../../../common/Button';
Expand Down Expand Up @@ -39,6 +40,14 @@ function SignupForm() {
function onSubmit(formProps) {
return dispatch(validateAndSignUpUser(formProps));
}
const [showPassword, setShowPassword] = useState(false);
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
const handleVisibility = () => {
setShowPassword(!showPassword);
};
const handleConfirmVisibility = () => {
setShowConfirmPassword(!showConfirmPassword);
};

return (
<Form
Expand Down Expand Up @@ -95,42 +104,68 @@ function SignupForm() {
</Field>
<Field name="password">
{(field) => (
<p className="form__field">
<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}
/>
{field.meta.touched && field.meta.error && (
<span className="form-error">{field.meta.error}</span>
)}
</p>
<div>
<p className="form__field">
<label htmlFor="password" className="form__label">
{t('SignupForm.Password')}
</label>
<button
className="form__eye__icon"
type="button"
onClick={handleVisibility}
>
{showPassword ? (
<AiOutlineEyeInvisible />
) : (
<AiOutlineEye />
)}
</button>
<input
className="form__input"
aria-label={t('SignupForm.PasswordARIA')}
type={showPassword ? 'text' : 'password'}
id="password"
autoComplete="new-password"
{...field.input}
/>
{field.meta.touched && field.meta.error && (
<span className="form-error">{field.meta.error}</span>
)}
</p>
</div>
)}
</Field>
<Field name="confirmPassword">
{(field) => (
<p className="form__field">
<label htmlFor="confirm password" className="form__label">
{t('SignupForm.ConfirmPassword')}
</label>
<input
className="form__input"
type="password"
aria-label={t('SignupForm.ConfirmPasswordARIA')}
id="confirm password"
autoComplete="new-password"
{...field.input}
/>
{field.meta.touched && field.meta.error && (
<span className="form-error">{field.meta.error}</span>
)}
</p>
<div>
<p className="form__field">
<label htmlFor="confirmPassword" className="form__label">
{t('SignupForm.ConfirmPassword')}
</label>
<button
className="form__eye__icon"
type="button"
onClick={handleConfirmVisibility}
>
{showConfirmPassword ? (
<AiOutlineEyeInvisible />
) : (
<AiOutlineEye />
)}
</button>
<input
className="form__input"
type={showConfirmPassword ? 'text' : 'password'}
aria-label={t('SignupForm.ConfirmPasswordARIA')}
id="confirmPassword" // Match the id with htmlFor
autoComplete="new-password"
{...field.input}
/>
{field.meta.touched && field.meta.error && (
<span className="form-error">{field.meta.error}</span>
)}
</p>
</div>
)}
</Field>
<Button type="submit" disabled={submitting || invalid || pristine}>
Expand Down
17 changes: 15 additions & 2 deletions client/styles/components/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,26 @@
color: getThemifyVariable("form-input-text-color");
background-color: getThemifyVariable("input-background-color");
}

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

.form__eye__icon {
font-size: 28px;
position: relative;
top: 7px;
right: -355px;
margin-left: -40px;
}


.form__input[type='password']::-ms-reveal {
display: none;
}

.form__input-flexible-height {
height: auto;
resize: none;
Expand Down
Loading