Skip to content
Snippets Groups Projects
Commit 959f4583 authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire: Committed by Reiter, Christoph
Browse files

Create notification library to send notifications

parent 54c8039b
No related branches found
No related tags found
No related merge requests found
...@@ -13,22 +13,16 @@ ...@@ -13,22 +13,16 @@
- `lang` (optional, default: `de`): set to `de` or `en` for German or English - `lang` (optional, default: `de`): set to `de` or `en` for German or English
- example `<vpu-notification lang="de" client-id="my-client-id"></vpu-notification>` - example `<vpu-notification lang="de" client-id="my-client-id"></vpu-notification>`
## Events to dispatch ## Sending notifications
### Sending notifications ```javascript
import notification from './notification';
`vpu-notification-send` sends a notification to the web component
notification.send({
```javascript "summary": "Item deleted",
event = new CustomEvent("vpu-notification-send", { "body": "Item foo was deleted!",
bubbles: true, "type": "info",
cancelable: true, "timeout": 5,
detail: {
"summary": "Item deleted",
"body": "Item foo was deleted!",
"type": "info",
"timeout": 5,
},
}); });
``` ```
......
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,
});
document.dispatchEvent(event);
},
};
import {i18n} from './i18n.js'; import {i18n} from './i18n';
import notification from './notification';
import {html, LitElement} from 'lit-element'; import {html, LitElement} from 'lit-element';
class NotificationDemo extends LitElement { class NotificationDemo extends LitElement {
...@@ -46,18 +47,12 @@ class NotificationDemo extends LitElement { ...@@ -46,18 +47,12 @@ class NotificationDemo extends LitElement {
} }
send() { send() {
const event = new CustomEvent("vpu-notification-send", { notification.send({
bubbles: true, "summary": "Item deleted",
cancelable: true, "body": "Item foo was deleted!",
detail: { "type": "info",
"summary": "Item deleted", "timeout": 5,
"body": "Item foo was deleted!",
"type": "info",
"timeout": 5,
},
}); });
document.dispatchEvent(event);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment