Skip to content

Commit 765c1ad

Browse files
authored
Merge pull request #10 from codewithkyle/v2.0.0
V2.0.0
2 parents 70cd8f4 + d2919f7 commit 765c1ad

14 files changed

+401
-746
lines changed

.gitignore

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@ node_modules
33

44
# Compiled files
55
# -----------
6-
notification-manager.d.ts
7-
notification-manager.js
8-
notification-manager.js.map
9-
notify.d.ts
106
notify.js
11-
notify.js.map
7+
notify.js.map
8+
notify.d.ts
9+
notifier.js
10+
notifier.js.map
11+
notifier.d.ts
12+
snackbar-component.js
13+
snackbar-component.js.map
14+
snackbar-component.d.ts
15+
toast-component.js
16+
toast-component.js.map
17+
toast-component.d.ts

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- refactored elements into web components
13+
1014
## [1.2.2] - 2020-04-17
1115

1216
### Fixed

README.md

Lines changed: 24 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Notify.js
22

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.
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.
44

55
## Installation
66

@@ -14,41 +14,44 @@ npm i --save @codewithkyle/notifyjs
1414

1515
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.
1616

17-
### Global Manager
17+
### Notification Manager
1818

19-
Import the global `notify()` function:
19+
Import the manager:
2020

2121
```typescript
22-
import { notify } from "@codewithkyle/notifyjs";
22+
import { Notifier } from "@codewithkyle/notifyjs";
23+
const notifier = new Notifier();
2324
```
2425

25-
Submit a notification to the global manager:
26+
Create a snackbar or toast notification:
2627

2728
```typescript
28-
notify({
29-
message: "All notifications require a message",
29+
notifier.snackbar({
30+
message: "All snackbar notifications require a message",
31+
});
32+
notifier.toast({
33+
title: "Toast notificaitons require a title",
34+
message: "And they require a message",
3035
});
3136
```
3237

33-
### Custom Manager
34-
35-
Import the `NotificationManager` class:
36-
37-
```typescript
38-
import { NotificationManager } from "@codewithkyle/notifyjs";
39-
```
38+
### Global Manager
4039

41-
Create a new instance of the class:
40+
Import the notification type:
4241

4342
```typescript
44-
const customManager = new NotificationManager();
43+
import { snackbar, toast } from "@codewithkyle/notifyjs";
4544
```
4645

47-
Call the `notify()` method:
46+
Create a notification:
4847

4948
```typescript
50-
customManager.notify({
51-
message: "All notifications require a message",
49+
notifier.snackbar({
50+
message: "All snackbar notifications require a message",
51+
});
52+
notifier.toast({
53+
title: "Toast notificaitons require a title",
54+
message: "And they require a message",
5255
});
5356
```
5457

@@ -57,7 +60,7 @@ customManager.notify({
5760
```typescript
5861
interface NotificationOptions {
5962
message: string;
60-
duration?: number;
63+
duration?: number; // in seconds
6164
closeable?: boolean;
6265
buttons?: Array<{
6366
label: string;
@@ -70,17 +73,6 @@ interface NotificationOptions {
7073
}
7174
```
7275

73-
### Duration
74-
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.
76-
77-
```typescript
78-
notify({
79-
message: "This notification will last 3 seconds",
80-
duration: 3,
81-
});
82-
```
83-
8476
### User Interaction
8577

8678
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.
@@ -99,17 +91,6 @@ notify({
9991
});
10092
```
10193

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",
109-
closeable: true,
110-
});
111-
```
112-
11394
### HTML Structure
11495

11596
```html
@@ -131,7 +112,7 @@ type ToasterNotification = {
131112
title: string;
132113
message: string;
133114
closeable?: boolean;
134-
icon?: string; // svg
115+
icon?: string; // svg or img
135116
duration?: number; // in seconds
136117
classes?: string[];
137118
};
@@ -155,7 +136,3 @@ type ToasterNotification = {
155136
</toast-component>
156137
</toaster-component>
157138
```
158-
159-
## Stylesheets
160-
161-
This library doesn't provide/force any CSS, for a material design styled snackbar notification [click here](https://github.com/codewithkyle/notifyjs/blob/master/test/snackbar.css).

package.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
{
22
"name": "@codewithkyle/notifyjs",
3-
"version": "1.2.2",
3+
"version": "2.0.0",
44
"description": "A simple JavaScript library for creating and managing toaster & snackbar notifications",
55
"main": "notify.js",
66
"types": "notify.d.ts",
77
"files": [
88
"notify.js",
99
"notify.js.map",
1010
"notify.d.ts",
11-
"notification-manager.js",
12-
"notification-manager.js.map",
13-
"notification-manager.d.ts"
11+
"notifier.js",
12+
"notifier.js.map",
13+
"notifier.d.ts",
14+
"snackbar-component.js",
15+
"snackbar-component.js.map",
16+
"snackbar-component.d.ts",
17+
"toast-component.js",
18+
"toast-component.js.map",
19+
"toast-component.d.ts"
1420
],
1521
"scripts": {
1622
"compile": "tsc",
@@ -19,6 +25,8 @@
1925
"keywords": [
2026
"snackbar",
2127
"notification",
28+
"toaster",
29+
"web-components",
2230
"lightweight"
2331
],
2432
"author": "Kyle Andrews",

src/Notify.ts

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)