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 @@
- `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>`
## Events to dispatch
### Sending notifications
`vpu-notification-send` sends a notification to the web component
```javascript
event = new CustomEvent("vpu-notification-send", {
bubbles: true,
cancelable: true,
detail: {
"summary": "Item deleted",
"body": "Item foo was deleted!",
"type": "info",
"timeout": 5,
},
## Sending notifications
```javascript
import notification from './notification';
notification.send({
"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';
class NotificationDemo extends LitElement {
......@@ -46,18 +47,12 @@ class NotificationDemo extends LitElement {
}
send() {
const event = new CustomEvent("vpu-notification-send", {
bubbles: true,
cancelable: true,
detail: {
"summary": "Item deleted",
"body": "Item foo was deleted!",
"type": "info",
"timeout": 5,
},
notification.send({
"summary": "Item deleted",
"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