diff --git a/packages/notification/src/index.js b/packages/notification/src/index.js index 33206ad78b6f6a0513e1a6067b8551a5f1ca6a58..d1562574607e23688dbd393b0dd84ffdaad3f69a 100644 --- a/packages/notification/src/index.js +++ b/packages/notification/src/index.js @@ -1,4 +1,4 @@ import './vpu-notification'; -import send from './notification'; +import { send } from './notification'; export { send }; diff --git a/packages/notification/src/notification.js b/packages/notification/src/notification.js index a6a663948569838f6c4091e502bd3667700c6054..ac18c03014027b4dc49a423431bb25a0cd4a51ea 100644 --- a/packages/notification/src/notification.js +++ b/packages/notification/src/notification.js @@ -1,26 +1,25 @@ +/** + * Sends a notification via the event + * + * example options: + * + * { + * "summary": "Item deleted", + * "body": "Item foo was deleted!", + * "type": "info", + * "timeout": 5, + * } + * + * @param options + */ +function send(options) { + const event = new CustomEvent("vpu-notification-send", { + bubbles: true, + cancelable: true, + detail: options, + }); -module.exports = { - /** - * Sends a notification via the event - * - * example options: - * - * { - * "summary": "Item deleted", - * "body": "Item foo was deleted!", - * "type": "info", - * "timeout": 5, - * } - * - * @param options - */ - send: (options) => { - const event = new CustomEvent("vpu-notification-send", { - bubbles: true, - cancelable: true, - detail: options, - }); + window.dispatchEvent(event); +} - window.dispatchEvent(event); - }, -}; +export { send }; diff --git a/packages/notification/src/vpu-notification-demo.js b/packages/notification/src/vpu-notification-demo.js index d2b595ac2723b131bd6dd774caa5896ff463518b..dfece94b2143c86db499457704742dd335e9f7e2 100644 --- a/packages/notification/src/vpu-notification-demo.js +++ b/packages/notification/src/vpu-notification-demo.js @@ -1,5 +1,5 @@ import {i18n} from './i18n'; -import notification from './notification'; +import {send as notify} from './notification'; import {html, LitElement} from 'lit-element'; import './vpu-notification'; @@ -49,7 +49,7 @@ class NotificationDemo extends LitElement { send() { const types = ["primary", "link", "info", "success", "danger", "warning"]; - notification.send({ + notify({ "summary": "Item deleted", "body": `Item ${Math.random().toString(36).substring(7)} foo was deleted!`, "type": types[Math.floor(Math.random() * types.length)],