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
+59-17Lines changed: 59 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,41 +10,74 @@ Download Notify.js via NPM:
10
10
npm i --save @codewithkyle/notifyjs
11
11
```
12
12
13
-
Once the package is installed import the package:
13
+
## Usage
14
+
15
+
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.
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.
75
+
The duration value can be set to `Infinity` if a users interaction is required. Otherwise enter the number of seconds the notification should be displayed for.
42
76
43
77
```typescript
44
-
notificationManager.notify({
45
-
message: "The user will have to close this notification",
46
-
duration: Infinity,
47
-
closeable: true,
78
+
notify({
79
+
message: "This notification will last 3 seconds",
80
+
duration: 3,
48
81
});
49
82
```
50
83
@@ -53,10 +86,8 @@ notificationManager.notify({
53
86
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.
54
87
55
88
```typescript
56
-
notificationManager.notify({
89
+
notify({
57
90
message: "A new version of this application is available",
58
-
duration: Infinity,
59
-
closeable: true,
60
91
buttons: [
61
92
{
62
93
label: "Update",
@@ -68,6 +99,17 @@ notificationManager.notify({
68
99
});
69
100
```
70
101
102
+
### Closeable
103
+
104
+
Notifications can be closeable by setting the `closeable` value to true.
105
+
106
+
```typescript
107
+
notify({
108
+
message: "The user will have to close this notification",
0 commit comments