Skip to content

Commit

Permalink
fix(config): remove usage of ember-get-config
Browse files Browse the repository at this point in the history
  • Loading branch information
anehx committed Feb 4, 2022
1 parent 98a8461 commit fcddb14
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 133 deletions.
30 changes: 16 additions & 14 deletions addon/services/notification.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
import { getOwner } from "@ember/application";
import Service from "@ember/service";
import config from "ember-get-config";
import UIkit from "uikit";

function notification(status) {
return function () {
return {
value(message, options = {}) {
return this._notification(message, Object.assign(options, { status }));
const config =
getOwner(this).resolveRegistration("config:environment")[
"ember-uikit"
]?.notification ?? {};

const n = UIkit.notification({
...config,
...options,
status,
message,
});

return n?.$el
? new Promise((resolve) => UIkit.util.on(n.$el, "close", resolve))
: Promise.resolve();
},
};
};
}

export default class NotificationService extends Service {
_notification(message, options) {
const n = UIkit.notification(
Object.assign(config["ember-uikit"]?.notification ?? {}, options, {
message,
})
);

return n?.$el
? new Promise((resolve) => UIkit.util.on(n.$el, "close", resolve))
: Promise.resolve();
}

@notification("default") default;
@notification("primary") primary;
@notification("success") success;
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"ember-cli-babel": "^7.26.11",
"ember-cli-htmlbars": "^6.0.1",
"ember-focus-trap": "^1.0.1",
"ember-get-config": "^1.0.2",
"ember-modifier": "^3.1.0",
"ember-toggle": "^9.0.3",
"uikit": "^3.10.1"
Expand Down
Loading

0 comments on commit fcddb14

Please sign in to comment.