Sha256: dfd3684c1da14c95a9e8e42d30f121ce8ec6b5198ba0ebf8095dac1cc67f0312
Contents?: true
Size: 821 Bytes
Versions: 33
Compression:
Stored size: 821 Bytes
Contents
import { Controller } from "stimulus" export default class extends Controller { static targets = [ "wrapper"] static classes = [ "hidden" ] // necessary because stimulus-reveal will mess with the [hidden] attribute on the wrapper static values = { showEventName: String, hideEventName: String, } toggle() { const eventName = this.isWrapperHidden? this.showEventNameValue: this.hideEventNameValue if (this.isWrapperHidden) { this.showWrapper() } this.wrapperTarget.dispatchEvent(new CustomEvent(eventName)) } get isWrapperHidden() { return this.wrapperTarget.classList.contains(this.hiddenClass) } showWrapper() { this.wrapperTarget.classList.remove(this.hiddenClass) } hideWrapper() { this.wrapperTarget.classList.add(this.hiddenClass) } }
Version data entries
33 entries across 33 versions & 1 rubygems