diff --git a/static/images/closed_eye.png b/static/images/closed_eye.png new file mode 100644 index 0000000..3c8d638 Binary files /dev/null and b/static/images/closed_eye.png differ diff --git a/static/images/filled_eye.png b/static/images/filled_eye.png new file mode 100644 index 0000000..c62aac8 Binary files /dev/null and b/static/images/filled_eye.png differ diff --git a/static/javascript/show_password.js b/static/javascript/show_password.js new file mode 100644 index 0000000..59c650f --- /dev/null +++ b/static/javascript/show_password.js @@ -0,0 +1,22 @@ +const showPasswordButtons = document.getElementsByClassName( + "show_password_toggle", +); + +for (const button of showPasswordButtons) { + button.addEventListener("click", function () { + const input = this.parentElement.querySelector( + "input[type='password'], input[type='text']", + ); + if (!input) return; + const isHidden = input.type === "password"; + input.type = isHidden ? "text" : "password"; + + if (isHidden) { + this.classList.add("open"); + this.classList.remove("closed"); + } else { + this.classList.remove("open"); + this.classList.add("closed"); + } + }); +} diff --git a/static/style.css b/static/style.css index 7186af3..868d417 100644 --- a/static/style.css +++ b/static/style.css @@ -95,3 +95,37 @@ input::placeholder { margin-bottom: 0px; color: var(--text-main) !important; } + +.password_box { + position: relative; + display: inline-block; +} + +.show_password_toggle { + width: 10px; + height: 10px; + position: absolute; + right: 5px; + bottom: 50%; + transform: translateY(50%); + background-size: contain; + background-repeat: no-repeat; + background-position: center; + background-color: rgba(0, 0, 0, 0); +} + +.show_password_toggle.closed { + background-image: url("/static/images/closed_eye.png"); +} + +.show_password_toggle.open { + background-image: url("/static/images/filled_eye.png"); +} + +.show_password_toggle:hover { + background-color: rgba(0, 0, 0, 0); +} + +.show_password_toggle:focus { + outline: none !important; +}