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
Copy file name to clipboardExpand all lines: README.md
+58-22Lines changed: 58 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Notify.js
2
2
3
-
Notify.js is a hyper-lightweight utility library helping to manage simple [snackbar](https://material.io/develop/web/components/snackbars/) and [toaster](https://www.carbondesignsystem.com/components/notification/code/) notifications.
3
+
Notify.js is a hyper-lightweight utility library for managing simple [snackbar](https://material.io/develop/web/components/snackbars/) and [toaster](https://www.carbondesignsystem.com/components/notification/code/) notifications.
1. [Snackbar HTML Structure](#snackbar-html-structure)
26
+
1. [Toast Notification](#toast-notification)
27
+
1. [Toast Interface](#toast-interface)
28
+
1. [Toast HTML Structure](#toast-html-structure)
29
+
15
30
There are two ways to use this package. You can create a Notification Manager or use the global manager. Each manager has a queue and new notifications are placed in the queue in the order that they're requested. The queue can be skipped by settings the `force` value to true.
16
31
17
32
### Notification Manager
@@ -53,12 +68,31 @@ notifier.toast({
53
68
title: "Toast notificaitons require a title",
54
69
message: "And they require a message",
55
70
});
71
+
72
+
// Adds an action button
73
+
notifier.snackbar({
74
+
message: "All snackbar notifications require a message",
75
+
buttons: [
76
+
{
77
+
label: "Update",
78
+
callback: () => {
79
+
console.log("User clicked the update button");
80
+
},
81
+
},
82
+
],
83
+
});
56
84
```
57
85
86
+
---
87
+
58
88
## Snackbar Notification
59
89
90
+
Snackbar notifications are great for quick one-off notifications.
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.
79
-
80
-
```typescript
81
-
notify({
82
-
message: "A new version of this application is available",
83
-
buttons: [
84
-
{
85
-
label: "Update",
86
-
callback: () => {
87
-
console.log("User clicked the update button");
88
-
},
89
-
},
90
-
],
91
-
});
92
-
```
93
-
94
-
### HTML Structure
112
+
### Snackbar HTML Structure
95
113
96
114
```html
97
115
<snackbar-component>
@@ -105,8 +123,14 @@ notify({
105
123
</snackbar-component>
106
124
```
107
125
126
+
---
127
+
108
128
## Toast Notification
109
129
130
+
Toaster notifications are great for application-like notification systems where users will need to recieve warnings, updates, successes, and errors.
131
+
132
+
### Toast Interface
133
+
110
134
```typescript
111
135
type ToasterNotification = {
112
136
title: string;
@@ -115,10 +139,19 @@ type ToasterNotification = {
0 commit comments