protos-stimulus
Version:
Stimulus controllers for Protos
42 lines (34 loc) • 671 B
JavaScript
import { Controller } from "@hotwired/stimulus"
import tippy from "tippy.js"
export default class extends Controller {
static targets = [ "template", "trigger" ]
static values = {
options: {
type: Object,
default: {}
}
}
connect() {
const options = {
content: this.templateTarget.innerHTML,
allowHTML: true,
interactive: true
}
const merged = { ...options, ...this.optionsValue }
this.tippy = tippy(
this.triggerTarget,
merged
)
}
disconnect() {
if (this.tippy) {
this.tippy.destroy()
}
}
open() {
this.tippy.show()
}
close() {
this.tippy.hide()
}
}