sutty-base-jekyll-theme/_packs/controllers/floating_alert_controller.js
2021-01-25 16:46:16 -03:00

18 lines
470 B
JavaScript

import { Controller } from 'stimulus'
export default class extends Controller {
static targets = [ 'content' ]
connect () {
window.addEventListener('toast', event => {
this.contentTarget.innerText = event.detail.content
this.element.classList.toggle('hide')
this.element.classList.toggle('show')
setTimeout(() => {
this.element.classList.toggle('hide')
this.element.classList.toggle('show')
}, 3000)
})
}
}