Created
February 18, 2021 08:40
-
-
Save b-aleksei/cbaf5ae0b75ecdc7ffde5fa120d166f3 to your computer and use it in GitHub Desktop.
input-password
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const showPassword = (btn) => { | |
const input = btn.parentElement.querySelector('input'); | |
if (btn.classList.contains('show')) { | |
btn.classList.remove('show'); | |
input.type = 'password'; | |
} else { | |
btn.classList.add('show'); | |
input.type = 'text'; | |
} | |
}; | |
/* | |
<label className="profile__label-wrap profile__text-field"> | |
<input type="password" name="password" placeholder="Не заполнено" required> | |
<button className="show-password" type="button"> | |
{{macro.svg('password-eye', 30, 30)}} | |
</button> | |
</label> | |
.show-password { | |
position: absolute; | |
top: 0; | |
right: 0; | |
transition-property: fill, stroke; | |
transition-duration: $delay-default; | |
fill: $color-default-black; | |
stroke: $color-default-white; | |
svg { | |
width: 30px; | |
height: 30px; | |
} | |
&.show { | |
fill: transparent; | |
stroke: transparent; | |
} | |
}*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment