show/hide password button
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
// Toggle password visibility so users can check for typos, especially on mobile.
|
||||
document.querySelectorAll(".password-toggle").forEach(function (button) {
|
||||
button.addEventListener("pointerdown", function (event) {
|
||||
// Toggle on press (not click) for an instant response. preventScroll avoids
|
||||
// a scroll-to-input animation that makes rapid toggling feel laggy, and
|
||||
// keeping focus on the input keeps the mobile keyboard open.
|
||||
event.preventDefault();
|
||||
var input = document.getElementById(button.getAttribute("data-toggle-for"));
|
||||
if (!input) return;
|
||||
var showing = input.type === "text";
|
||||
input.type = showing ? "password" : "text";
|
||||
button.textContent = showing ? "Show" : "Hide";
|
||||
button.setAttribute("aria-label", showing ? "Show password" : "Hide password");
|
||||
input.focus({ preventScroll: true });
|
||||
});
|
||||
});
|
||||
@@ -75,6 +75,10 @@ h3 { margin-bottom: 6px; font-size: 1rem; }
|
||||
.stack label { color: var(--muted); font-size: .82rem; font-weight: 700; }
|
||||
input { width: 100%; min-height: 46px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 12px; outline: none; color: var(--ink); background: #fff; }
|
||||
input:focus { border-color: var(--deep-sage); box-shadow: 0 0 0 4px rgba(85, 113, 93, .12); }
|
||||
.password-field { position: relative; }
|
||||
.password-field input { padding-right: 64px; }
|
||||
.password-toggle { position: absolute; top: 50%; right: 8px; transform: translateY(-50%); min-height: 32px; padding: 5px 10px; border: 0; border-radius: 9px; cursor: pointer; color: var(--deep-sage); background: #e7f0e1; font-weight: 800; font-size: .78rem; }
|
||||
.password-toggle:hover { background: #dbe9d2; }
|
||||
select { width: 100%; min-height: 46px; padding: 10px 34px 10px 13px; border: 1px solid var(--line); border-radius: 12px; outline: none; color: var(--ink); background: #fff; font: inherit; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'><path d='M4 6l4 4 4-4' fill='none' stroke='%2355715d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; }
|
||||
select:focus { border-color: var(--deep-sage); box-shadow: 0 0 0 4px rgba(85, 113, 93, .12); }
|
||||
select option { color: var(--ink); background: #fff; }
|
||||
|
||||
Reference in New Issue
Block a user