discourse/app/assets/javascripts/float-kit/addon/lib/d-toast-instance.js
Joffrey JAFFEUX 17c92b4b2a
UX: shows the bookmark menu improvements
This commit adds a new option `@modalForMobile` for `<DMenu />` which allows to display a `<DModal />` when expanding a menu on mobile.

This commit also adds a `@views` options to toasts which is an array accepting `['mobile',  'desktop']` and will control if the toast is show on desktop and/or mobile.

Finally this commit allows to hide the progressBar even if the toast is set to `@autoClose=true`. This is controlled through the `@showProgressBar` option.
2024-04-08 08:18:50 +02:00

28 lines
639 B
JavaScript

import { setOwner } from "@ember/application";
import { action } from "@ember/object";
import { service } from "@ember/service";
import uniqueId from "discourse/helpers/unique-id";
import { TOAST } from "float-kit/lib/constants";
export default class DToastInstance {
@service site;
@service toasts;
options = null;
id = uniqueId();
constructor(owner, options = {}) {
setOwner(this, owner);
this.options = { ...TOAST.options, ...options };
}
@action
close() {
this.toasts.close(this);
}
get isValidForView() {
return this.options.views.includes(this.site.desktopView ? "desktop" : "mobile");
}
}