Sha256: bb2d6f0730dc7500cf8c059407b377f2197877e8e2170d8e78e3f59906f34dde
Contents?: true
Size: 1012 Bytes
Versions: 4
Compression:
Stored size: 1012 Bytes
Contents
import { Controller } from "@hotwired/stimulus"; export default class UIToastController extends Controller { static targets = ["item"]; connect() { setTimeout(() => { this.openAll(); }, 1000); this.closeAll(); } openAll() { const toastElements = document.querySelectorAll("[data-ui--toast-target='item']"); toastElements.forEach((toastElement) => { toastElement.dataset.state = "open"; toastElement.classList.remove("hidden"); }); } closeAll() { const toastElements = document.querySelectorAll("[data-ui--toast-target='item']"); toastElements.forEach((toastElement) => { setTimeout(() => { toastElement.dataset.state = "closed"; toastElement.classList.add("hidden"); }, toastElement.dataset.duration); }); } test() { const $this = this; this.closeAll(); setTimeout(() => { $this.openAll(); setTimeout(() => { $this.closeAll(); }, 3000); }, 1000); } close() {} }
Version data entries
4 entries across 4 versions & 1 rubygems