Skip to content

Commit 1a2c70f

Browse files
authored
Merge pull request #9 from codewithkyle/v2.0.0
NotifyJS v1.2.0
2 parents 8c40900 + 64112d5 commit 1a2c70f

File tree

6 files changed

+210
-58
lines changed

6 files changed

+210
-58
lines changed

CHANGELOG.md

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

88
## [Unreleased]
99

10+
## [1.2.0] - 2020-04-04
11+
12+
### Added
13+
14+
- toaster notification `toast()` creation [#5](https://github.com/codewithkyle/notifyjs/issues/5)
15+
- renames existing notification funciton to `snackbar()`
16+
1017
## [1.1.0] - 2020-02-11
1118

1219
### Added
@@ -72,7 +79,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7279

7380
- Entire existing codebase due to rewrite
7481

75-
[unreleased]: https://github.com/codewithkyle/notifyjs/compare/v1.1.0...HEAD
82+
[unreleased]: https://github.com/codewithkyle/notifyjs/compare/v1.2.0...HEAD
83+
[1.2.0]: https://github.com/codewithkyle/notifyjs/compare/v1.1.0...v1.2.0
7684
[1.1.0]: https://github.com/codewithkyle/notifyjs/compare/v1.0.3...v1.1.0
7785
[1.0.3]: https://github.com/codewithkyle/notifyjs/compare/v1.0.2...v1.0.3
7886
[1.0.2]: https://github.com/codewithkyle/notifyjs/compare/v1.0.1...v1.0.2

README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ customManager.notify({
5252
});
5353
```
5454

55-
## Notification Options
55+
## Snackbar Notification
5656

5757
```typescript
5858
interface NotificationOptions {
@@ -110,7 +110,7 @@ notify({
110110
});
111111
```
112112

113-
## HTML Structure
113+
### HTML Structure
114114

115115
```html
116116
<snackbar-component>
@@ -124,6 +124,38 @@ notify({
124124
</snackbar-component>
125125
```
126126

127+
## Toast Notification
128+
129+
```typescript
130+
type ToasterNotification = {
131+
title: string;
132+
message: string;
133+
closeable?: boolean;
134+
icon?: string; // svg
135+
duration?: number; // in seconds
136+
classes?: string[];
137+
};
138+
```
139+
140+
### HTML Structure
141+
142+
```html
143+
<toaster-component>
144+
<toast-component>
145+
<i>
146+
<svg />
147+
</i>
148+
<copy-wrapper>
149+
<h3>Title</h3>
150+
<p>Custom notification message</p>
151+
</copy-wrapper>
152+
<button>
153+
<svg />
154+
</button>
155+
</toast-component>
156+
</toaster-component>
157+
```
158+
127159
## Stylesheets
128160

129161
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-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@codewithkyle/notifyjs",
3-
"version": "1.1.0",
4-
"description": "A simple JavaScript library for creating and managing snackbar notifications",
3+
"version": "1.2.0",
4+
"description": "A simple JavaScript library for creating and managing toaster & snackbar notifications",
55
"main": "notify.js",
66
"types": "notify.d.ts",
77
"files": [
@@ -25,10 +25,7 @@
2525
"license": "MIT",
2626
"devDependencies": {
2727
"serve": "^11.3.0",
28-
"typescript": "^3.7.4"
29-
},
30-
"publishConfig": {
31-
"registry": "https://npm.pkg.github.com/"
28+
"typescript": "^3.8.3"
3229
},
3330
"dependencies": {}
3431
}

src/Notify.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import { NotificationManager } from "./notification-manager";
22

33
const globalManager = new NotificationManager();
44

5+
/**
6+
* @deprecated Use `snackbar()` instead
7+
*/
58
const notify: (notification: {
69
message: string;
710
duration?: number;
@@ -16,4 +19,28 @@ const notify: (notification: {
1619
classes?: Array<string> | string;
1720
}) => void = globalManager.notify.bind(globalManager);
1821

19-
export { NotificationManager, notify };
22+
const snackbar: (notification: {
23+
message: string;
24+
duration?: number;
25+
closeable?: boolean;
26+
buttons?: Array<{
27+
label: string;
28+
callback: Function;
29+
ariaLabel?: string;
30+
classes?: Array<string> | string;
31+
}>;
32+
force?: boolean;
33+
classes?: Array<string> | string;
34+
}) => void = globalManager.snackbar.bind(globalManager);
35+
36+
const toast: (notification: {
37+
title: string;
38+
message: string;
39+
closeable?: boolean;
40+
icon?: string;
41+
duration?: number;
42+
classes?: string[];
43+
element?: HTMLElement;
44+
}) => void = globalManager.toast.bind(globalManager);
45+
46+
export { NotificationManager, notify, toast, snackbar };

0 commit comments

Comments
 (0)