Sha256: 044303bf80d9ba2ef242beb26c3938fcb7c079715ef493f000dee8ce73834d51

Contents?: true

Size: 857 Bytes

Versions: 25

Compression:

Stored size: 857 Bytes

Contents

import { CocoComponent } from "@js/coco";

export default CocoComponent("appAlert", () => {
  return {
    alert: null,
    dismissed: false,
    forceMultiLine: false,
    dismissDuration: 300,

    dismiss() {
      if (this.$options.dismissable) {
        this.$dispatch("alert:dismiss", {
          alert: this,
          duration: this.dismissDuration,
        });

        this.dismissed = true;

        setTimeout(() => this.remove(), this.dismissDuration);
      }
    },

    remove() {
      this.$root.remove();
    },

    checkSingleLineWrap({ height }) {
      if (!this.forceMultiLine) {
        this.forceMultiLine = height > 24 && this.$options.singleLine;
      }
    },

    root: {
      "x-options": '["dismissable", "singleLine"]',
      "x-show": "!dismissed",
      ":class": "{'force-multi-line': forceMultiLine}",
    },
  };
});

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
coveragebook_components-0.7.10 app/components/coco/app/elements/alert/alert.js
coveragebook_components-0.7.9 app/components/coco/app/elements/alert/alert.js
coveragebook_components-0.7.8 app/components/coco/app/elements/alert/alert.js
coveragebook_components-0.7.7 app/components/coco/app/elements/alert/alert.js
coveragebook_components-0.7.6 app/components/coco/app/elements/alert/alert.js
coveragebook_components-0.7.5 app/components/coco/app/elements/alert/alert.js
coveragebook_components-0.7.4 app/components/coco/app/elements/alert/alert.js
coveragebook_components-0.7.3 app/components/coco/app/elements/alert/alert.js
coveragebook_components-0.7.2 app/components/coco/app/elements/alert/alert.js
coveragebook_components-0.7.1 app/components/coco/app/elements/alert/alert.js
coveragebook_components-0.7.0 app/components/coco/app/elements/alert/alert.js
coveragebook_components-0.6.5 app/components/coco/app/elements/alert/alert.js
coveragebook_components-0.6.4 app/components/coco/app/elements/alert/alert.js
coveragebook_components-0.6.3 app/components/coco/app/elements/alert/alert.js
coveragebook_components-0.6.2 app/components/coco/app/elements/alert/alert.js
coveragebook_components-0.6.1 app/components/coco/app/elements/alert/alert.js
coveragebook_components-0.6.0 app/components/coco/app/elements/alert/alert.js
coveragebook_components-0.5.7 app/components/coco/app/elements/alert/alert.js
coveragebook_components-0.5.6 app/components/coco/app/elements/alert/alert.js
coveragebook_components-0.5.5 app/components/coco/app/elements/alert/alert.js