Sha256: 0b1fda80be6d6bb89804d9697c81b486e42ff0b94073da968b30c3054b9b8e0c
Contents?: true
Size: 831 Bytes
Versions: 22
Compression:
Stored size: 831 Bytes
Contents
import { Controller } from "@hotwired/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
22 entries across 22 versions & 1 rubygems