Sha256: 5da4cddfdda3bf7258b124e1afc16e5383e6aa541709f0f0f9bd86c75eecaef9

Contents?: true

Size: 502 Bytes

Versions: 1

Compression:

Stored size: 502 Bytes

Contents

import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
  static targets = [ "input", "image" ]
  static values  = { showImage: String, hideImage: String }

  reveal() {
    this.inputTarget.type = this.#inputType
    this.imageTarget.src  = this.#imageSrc
  }

  get #inputType() {
    return this.inputTarget.type === "text" ? "password" : "text"
  }

  get #imageSrc() {
    return this.inputTarget.type === "text" ? this.hideImageValue : this.showImageValue
  }
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
css-zero-0.0.36 lib/generators/css_zero/add/templates/app/javascript/controllers/reveal_button_controller.js