From 3dda4d65404bbea97f60c0eec2b08340095318ef Mon Sep 17 00:00:00 2001 From: Ajay Bura Date: Sat, 9 Jul 2022 10:35:17 +0530 Subject: [PATCH] Add toggle to show password in auth page (#73) --- public/res/ic/outlined/eye-blind.svg | 4 ++++ public/res/ic/outlined/eye.svg | 15 +++------------ src/app/templates/auth/Auth.jsx | 20 +++++++++++++++++--- src/app/templates/auth/Auth.scss | 17 ++++++++++++++++- 4 files changed, 40 insertions(+), 16 deletions(-) create mode 100644 public/res/ic/outlined/eye-blind.svg diff --git a/public/res/ic/outlined/eye-blind.svg b/public/res/ic/outlined/eye-blind.svg new file mode 100644 index 0000000..fbc8e2a --- /dev/null +++ b/public/res/ic/outlined/eye-blind.svg @@ -0,0 +1,4 @@ + + + + diff --git a/public/res/ic/outlined/eye.svg b/public/res/ic/outlined/eye.svg index fb31e4f..1ce868b 100644 --- a/public/res/ic/outlined/eye.svg +++ b/public/res/ic/outlined/eye.svg @@ -1,13 +1,4 @@ - - - - - - - - - - + + + diff --git a/src/app/templates/auth/Auth.jsx b/src/app/templates/auth/Auth.jsx index f7998fe..0c27c00 100644 --- a/src/app/templates/auth/Auth.jsx +++ b/src/app/templates/auth/Auth.jsx @@ -21,6 +21,8 @@ import Avatar from '../../atoms/avatar/Avatar'; import ContextMenu, { MenuItem, MenuHeader } from '../../atoms/context-menu/ContextMenu'; import ChevronBottomIC from '../../../../public/res/ic/outlined/chevron-bottom.svg'; +import EyeIC from '../../../../public/res/ic/outlined/eye.svg'; +import EyeBlindIC from '../../../../public/res/ic/outlined/eye-blind.svg'; import CinnySvg from '../../../../public/res/svg/cinny.svg'; import SSOButtons from '../../molecules/sso-buttons/SSOButtons'; @@ -162,6 +164,7 @@ Homeserver.propTypes = { function Login({ loginFlow, baseUrl }) { const [typeIndex, setTypeIndex] = useState(0); + const [passVisible, setPassVisible] = useState(false); const loginTypes = ['Username', 'Email']; const isPassword = loginFlow?.filter((flow) => flow.type === 'm.login.password')[0]; const ssoProviders = loginFlow?.filter((flow) => flow.type === 'm.login.sso')[0]; @@ -242,7 +245,10 @@ function Login({ loginFlow, baseUrl }) { {errors.username && {errors.username}} {typeIndex === 1 && } {errors.email && {errors.email}} - +
+ + setPassVisible(!passVisible)} src={passVisible ? EyeIC : EyeBlindIC} size="extra-small" /> +
{errors.password && {errors.password}} {errors.other && {errors.other}}
@@ -275,6 +281,8 @@ let sid; let clientSecret; function Register({ registerInfo, loginFlow, baseUrl }) { const [process, setProcess] = useState({}); + const [passVisible, setPassVisible] = useState(false); + const [cPassVisible, setCPassVisible] = useState(false); const formRef = useRef(); const ssoProviders = loginFlow?.filter((flow) => flow.type === 'm.login.sso')[0]; @@ -444,9 +452,15 @@ function Register({ registerInfo, loginFlow, baseUrl }) {
{errors.username && {errors.username}} - +
+ + setPassVisible(!passVisible)} src={passVisible ? EyeIC : EyeBlindIC} size="extra-small" /> +
{errors.password && {errors.password}} - +
+ + setCPassVisible(!cPassVisible)} src={cPassVisible ? EyeIC : EyeBlindIC} size="extra-small" /> +
{errors.confirmPassword && {errors.confirmPassword}} {isEmail && } {errors.email && {errors.email}} diff --git a/src/app/templates/auth/Auth.scss b/src/app/templates/auth/Auth.scss index 8249e16..956a270 100644 --- a/src/app/templates/auth/Auth.scss +++ b/src/app/templates/auth/Auth.scss @@ -97,7 +97,8 @@ } .auth-form { - & > .input-container { + & > .input-container, + &__pass-eye-wrapper { margin: var(--sp-tight) 0 var(--sp-ultra-tight); } @@ -107,6 +108,20 @@ margin-top: calc(var(--sp-extra-loose) + var(--sp-tight)); } + &__pass-eye-wrapper { + position: relative; + & .ic-btn { + position: absolute; + @include dir.prop(right, 6px, unset); + @include dir.prop(left, unset, 6px ); + bottom: 6px; + border-radius: 4px; + } + & input { + @include dir.side(padding, var(--sp-normal), 46px); + } + } + &__btns { padding-top: var(--sp-loose); margin-bottom: var(--sp-extra-loose);