32 lines
751 B
JavaScript
32 lines
751 B
JavaScript
import { Controller } from "@hotwired/stimulus"
|
|
|
|
export default class extends Controller {
|
|
static targets = ['close', 'modal'];
|
|
|
|
current(id) {
|
|
return this.modalTargets.find(m => m.getAttribute('data-id') === id);
|
|
}
|
|
|
|
homeOpen(event) {
|
|
const id = event.currentTarget.getAttribute('data-id');
|
|
const current = this.current(id);
|
|
|
|
current.classList.add('is-active');
|
|
}
|
|
|
|
homeClose(event) {
|
|
const id = event.currentTarget.getAttribute('data-id');
|
|
const current = this.current(id);
|
|
|
|
current.classList.remove('is-active');
|
|
}
|
|
|
|
open() {
|
|
this.modalTarget.classList.add('is-active');
|
|
}
|
|
|
|
close() {
|
|
this.modalTarget.classList.remove('is-active');
|
|
}
|
|
}
|