mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 21:29:38 +02:00
20 lines
517 B
JavaScript
20 lines
517 B
JavaScript
|
import { Controller } from "@hotwired/stimulus";
|
||
|
|
||
|
// Connects to data-controller="password-visibility"
|
||
|
export default class extends Controller {
|
||
|
static targets = ["input", "showIcon", "hideIcon"];
|
||
|
|
||
|
connect() {
|
||
|
this.hideIconTarget.classList.add("hidden");
|
||
|
}
|
||
|
|
||
|
toggle() {
|
||
|
const input = this.inputTarget;
|
||
|
const type = input.type === "password" ? "text" : "password";
|
||
|
input.type = type;
|
||
|
|
||
|
this.showIconTarget.classList.toggle("hidden");
|
||
|
this.hideIconTarget.classList.toggle("hidden");
|
||
|
}
|
||
|
}
|