diff --git a/app/components/progress-bar.hbs b/app/components/progress-bar.hbs index 1ed2eb9..ced0b62 100644 --- a/app/components/progress-bar.hbs +++ b/app/components/progress-bar.hbs @@ -1,3 +1,9 @@ -
-
+
+
diff --git a/app/components/task-toast.hbs b/app/components/task-toast.hbs index 226d98c..f21b865 100644 --- a/app/components/task-toast.hbs +++ b/app/components/task-toast.hbs @@ -1,4 +1,4 @@ - +
{{#if this.icon}}
diff --git a/app/components/task-toast.js b/app/components/task-toast.js index 748ab51..ff3a782 100644 --- a/app/components/task-toast.js +++ b/app/components/task-toast.js @@ -9,6 +9,7 @@ export default class TaskToastComponent extends Component { @service meilisearch; @tracked task; + @tracked autoClose; constructor(owner, args) { super(owner, args); @@ -31,16 +32,41 @@ export default class TaskToastComponent extends Component { } } + get status() { + if (this.isEnqueued) { + return 'info'; + } else if (this.isFailed) { + return 'danger'; + } else if (this.isSucceeded) { + return 'success'; + } else { + return null; + } + } + get color() { - switch (this.taskStatus) { - case 'enqueued': - return 'text-info'; - case 'succeeded': - return 'text-success'; - case 'failed': - return 'text-danger'; - default: - return null; + // Current classes need for taiwind builder + if (this.isEnqueued) { + return 'text-info'; + } else if (this.isFailed) { + return 'text-danger'; + } else if (this.isSucceeded) { + return 'text-success'; + } else { + return null; + } + } + + get bg() { + // Current classes need for taiwind builder + if (this.isEnqueued) { + return 'bg-info'; + } else if (this.isFailed) { + return 'bg-danger'; + } else if (this.isSucceeded) { + return 'bg-success'; + } else { + return null; } } @@ -75,6 +101,7 @@ export default class TaskToastComponent extends Component { if (this.isSucceeded) { this.clearInterval(); + this.autoClose = true; } }); } diff --git a/app/components/toast.hbs b/app/components/toast.hbs index 4a519aa..afa82a2 100644 --- a/app/components/toast.hbs +++ b/app/components/toast.hbs @@ -9,8 +9,12 @@
{{yield (hash triggerOnClose=this.triggerOnClose)}}
- {{!-- {{#if this.autoCloseDuration}} --}} - - {{!-- {{/if}} --}} + {{#if @autoClose}} + + {{/if}}
{{/in-element}} diff --git a/app/components/toast.js b/app/components/toast.js index 13db2ac..8ea3b3f 100644 --- a/app/components/toast.js +++ b/app/components/toast.js @@ -13,10 +13,6 @@ export default class ToastComponent extends Component { @tracked width; @tracked height; - get autoCloseValue() { - return this.args?.autoCloseDuration ?? 3000; - } - get autoCloseDuration() { return this.args?.autoCloseDuration ?? 3000; } diff --git a/app/modifiers/animate.js b/app/modifiers/animate.js new file mode 100644 index 0000000..d033b91 --- /dev/null +++ b/app/modifiers/animate.js @@ -0,0 +1,15 @@ +import { modifier } from 'ember-modifier'; + +export default modifier( + (element, [keyframes, timing], { onFinish, onCancel }) => { + const animation = element.animate(keyframes, timing); + + animation.finished + .then(() => onFinish?.()) + .catch((error) => onCancel?.(error)); + + return () => { + animation.cancel(); + }; + } +); diff --git a/package.json b/package.json index b3599c3..5eacaa5 100644 --- a/package.json +++ b/package.json @@ -71,6 +71,7 @@ "ember-headlessui": "^0.13.0", "ember-load-initializers": "^2.1.2", "ember-mdi": "2.0.0-beta.1", + "ember-modifier": "4.0.0-beta.1", "ember-qunit": "^5.1.5", "ember-resolver": "^8.0.3", "ember-resources": "^4.7.1",