Sha256: 5b8ef9229c29701d20d47ebeb3a3bb92a72dad77981584b5dbf6c09c2497bf3b
Contents?: true
Size: 1.1 KB
Versions: 6
Compression:
Stored size: 1.1 KB
Contents
import { CocoComponent } from "@js/coco"; export default CocoComponent("appAlert", () => { return { alert: null, dismissed: false, forceMultiLine: false, dismissDuration: 300, init() { this.checkSingleLineWrap = Alpine.throttle( this.checkSingleLineWrap.bind(this), 200 ); }, dismiss() { if (this.$options.dismissable) { this.$dispatch("alert:dismiss", { alert: this, duration: this.dismissDuration, }); this.dismissed = true; setTimeout(() => this.remove(), this.dismissDuration); } }, remove() { this.$nextTick(() => this.$dispatch("alert:removed", { alert: this })); this.$root.remove(); }, checkSingleLineWrap({ height }) { this.forceMultiLine = false; if (height > 24 && this.$options.singleLine) { this.$nextTick(() => { this.forceMultiLine = true; }); } }, root: { "x-options": '["dismissable", "singleLine", "dismissAfterAction"]', ":class": "{'force-multi-line': forceMultiLine}", }, }; });
Version data entries
6 entries across 6 versions & 1 rubygems