Sha256: 1e6ddbb02ed1840ba515d3e044d32ed2fdf24fb0a8745d7eaca6b38a1d8b4c61
Contents?: true
Size: 594 Bytes
Versions: 27
Compression:
Stored size: 594 Bytes
Contents
import { Controller } from "@hotwired/stimulus" export default class extends Controller { static get targets() { return [ "knob", "container", "checkbox" ] } connect() { this.renderKnob() } toggle() { this.checkboxTarget.checked = !this.checked this.renderKnob() } renderKnob() { this.containerTarget.classList.toggle('bg-gray-200', !this.checked) this.containerTarget.classList.toggle('bg-green-500', this.checked) this.knobTarget.classList.toggle('translate-x-6', this.checked) } get checked() { return this.checkboxTarget.checked } }
Version data entries
27 entries across 27 versions & 1 rubygems