You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Notify.js is a utility library helping to manage simple [snackbar notifications](https://material.io/develop/web/components/snackbars/). Checkout the [live demo](https://codewithkyle.github.io/notifyjs/) to see the library in action.
2
+
3
+
Notify.js is a utility library helping to manage simple [snackbar notifications](https://material.io/develop/web/components/snackbars/). Checkout the [live demo](https://components.codewithkyle.com/snackbars/dark-snackbar) to see the library in action.
Then it's as simple as creating a new instance of the class:
28
+
Notifications are queued and displayed in the order that they were requested. The queue can be skipped by settings the `force` flag to true.
19
29
20
30
```typescript
21
-
newNotify({
22
-
message: 'Required message string for the notification'
31
+
notificationManager.notify({
32
+
message: 'This message will close the current notification and will jump the queue',
33
+
force: true,
23
34
});
24
35
```
25
36
26
37
## Notification Options
27
38
28
39
### Duration
29
40
30
-
Notify.js allows custom notification duration. The minimum time allowed is 4000 (4 seconds) and the maximum is 10000 (10 seconds). When creating a notification that has an interaction the `Infinity` value can be provided to the timer if you want the notification to stick until the user interacts with it.
41
+
Notify.js allows custom notification duration. The minimum time allowed is 4 seconds. When creating a notification that has an interaction the `Infinity` value can be provided to the timer if you want the notification to stick until the user interacts with it.
31
42
32
43
```typescript
33
-
newNotify({
34
-
message: 'Required message string for the notification',
35
-
duration: 6000
44
+
notificationManager.notify({
45
+
message: 'The user will have to close this notification',
46
+
duration: Infinity,
47
+
closeable: true,
36
48
});
37
49
```
38
50
@@ -41,112 +53,31 @@ new Notify({
41
53
Notify.js also allows for user interactions via a button element. The action requires a custom label for the button along with a callback function that will be called when the `click` event is fired on the button.
42
54
43
55
```typescript
44
-
newNotify({
45
-
message: 'Required message string for the notification',
56
+
notificationManager.notify({
57
+
message: 'A new version of this application is available',
46
58
duration: Infinity,
47
-
action: {
48
-
label: 'Do Something',
49
-
callback: this.someCallbackFunction.bind(this)
50
-
}
59
+
closeable: true,
60
+
buttons: [
61
+
{
62
+
label: 'Update',
63
+
callback: () => { console.log('User clicked the update button') },
64
+
}
65
+
],
51
66
});
52
67
```
53
68
54
-
## CSS
69
+
## HTML Structure
55
70
56
-
This library doesn't provide/force any base styles or CSS. The notification element is composed of three elements:
71
+
The notification element is composed of the following HTML. This library doesn't provide/force any CSS, for a material design styled snackbar notification [click here](https://components.codewithkyle.com/snackbars/dark-snackbar).
57
72
58
73
```html
59
-
<user-notification>
74
+
<snackbar-component>
60
75
<p>Custom notification message</p>
61
-
<button>Action</button>
62
-
</user-notification>
63
-
```
64
-
65
-
Below is the CSS for the snackbar notification used on the [demo page](https://codewithkyle.github.io/notifyjs/), it is based on the snackbar component from [Material Design](https://material.io/develop/web/components/snackbars/).
0 commit comments