wip: continue implementation
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
import { Controller} from '@hotwired/stimulus'
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ['field']
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { Controller } from '@hotwired/stimulus'
|
||||
|
||||
export default class extends Controller {
|
||||
|
||||
static classes = [ 'hidden' ]
|
||||
static targets = [ 'container' ]
|
||||
static values = { show: Array }
|
||||
|
||||
toggle(event) {
|
||||
let fieldType = event.target.type
|
||||
let formValue = event.target.value
|
||||
let showContainer
|
||||
if ('checkbox' !== fieldType && 'radio' !== fieldType) {
|
||||
showContainer = this.showValue.indexOf(formValue) !== -1
|
||||
} else {
|
||||
let toggleValue = event.target.dataset.selectToggleValue
|
||||
showContainer = true === event.target.checked && this.showValue.includes(toggleValue)
|
||||
}
|
||||
this.containerTarget.classList.toggle(this.hiddenClass, false === showContainer)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import { Controller } from '@hotwired/stimulus'
|
||||
|
||||
export default class extends Controller {
|
||||
|
||||
static classes = [ 'closed' ]
|
||||
static targets = [ 'toggle', 'icon' ]
|
||||
static values = {
|
||||
open: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this.target = this.hasToggleTarget ? this.toggleTarget : this.element
|
||||
}
|
||||
|
||||
toggle() {
|
||||
this.openValue = !this.openValue
|
||||
}
|
||||
|
||||
close() {
|
||||
this.openValue = false
|
||||
}
|
||||
|
||||
open() {
|
||||
this.openValue = true
|
||||
}
|
||||
|
||||
openValueChanged(open) {
|
||||
this.target.classList.toggle(this.closedClass, false === open)
|
||||
|
||||
if (false === this.hasIconTarget) {
|
||||
return
|
||||
}
|
||||
|
||||
this.iconTarget.classList.toggle('rotate-90', true === open)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user