Skip to content

Commit 54f1e9f

Browse files
authored
Merge pull request #22 from codewithkyle/wip-v3
v3
2 parents ff99d98 + a93c743 commit 54f1e9f

File tree

12 files changed

+176
-274
lines changed

12 files changed

+176
-274
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ toast-component.js
1313
toast-component.js.map
1414
notify.min.mjs
1515
notify.mjs
16+
types.d.ts
17+
notifier.d.ts
18+
notify.d.ts
19+
snackbar-component.d.ts
20+
toast-component.d.ts
21+
notify.min.js

CHANGELOG.md

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

88
## [Unreleased]
99

10+
### Added
11+
12+
- type declaration files
13+
- new `append()` function
14+
- alternate CDN version
15+
16+
### Fixed
17+
18+
- autofocus bug ([#19](https://github.com/codewithkyle/notifyjs/issues/19))
19+
- action button bug ([#20](https://github.com/codewithkyle/notifyjs/issues/20))
20+
1021
## [2.1.1] - 2021-01-21
1122

1223
### Fixed

README.md

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

3-
Notify.js is a lightweight (2.5kb) utility library for managing simple [snackbar](https://material.io/develop/web/components/snackbars/) and [toaster](https://www.carbondesignsystem.com/components/notification/code/) notifications.
3+
Notify.js is a lightweight (2.4kb) utility library for managing simple [snackbar](https://material.io/develop/web/components/snackbars/) and [toaster](https://www.carbondesignsystem.com/components/notification/code/) notifications.
44

55
## Installation
66

@@ -13,7 +13,15 @@ npm i --save @codewithkyle/notifyjs
1313
Or use the CDN version:
1414

1515
```javascript
16-
import { Notifier, snackbar, toast } from "https://cdn.jsdelivr.net/npm/@codewithkyle/notifyjs@2.1.1/notify.min.mjs";
16+
import { Notifier, snackbar, toast, append } from "https://cdn.jsdelivr.net/npm/@codewithkyle/notifyjs@3.0.0/notify.min.mjs";
17+
```
18+
19+
```html
20+
<script src="https://cdn.jsdelivr.net/npm/@codewithkyle/notifyjs@3.0.0/notify.min.js"></script>
21+
<script>
22+
Notifier.snackbar({ message: "This is a snackbar notification." });
23+
Notifier.toast({ title: "CDN Example", message: "This is a toast notification." });
24+
</script>
1725
```
1826

1927
## Usage
@@ -83,6 +91,24 @@ snackbar({
8391
});
8492
```
8593

94+
Append custom toast notifications:
95+
96+
```typescript
97+
import { append } from "@codewithkyle/notifyjs";
98+
99+
class CustomToasterElement extends HTMLElement {
100+
constructor(message){
101+
super();
102+
this.innerText = message;
103+
setTimeout(() => {
104+
this.remove();
105+
}, 5000);
106+
}
107+
}
108+
109+
append(new CustomToasterElement());
110+
```
111+
86112
---
87113

88114
## Snackbar Notification
@@ -103,9 +129,9 @@ interface SnackbarNotification {
103129
classes?: Array<string> | string;
104130
autofocus?: boolean;
105131
}>;
106-
force?: boolean;
132+
force?: boolean; // defaults to true
107133
classes?: Array<string> | string;
108-
autofocus?: boolean;
134+
autofocus?: boolean; // defaults to true
109135
}
110136
```
111137

@@ -139,15 +165,15 @@ type ToasterNotification = {
139165
icon?: string; // svg or img
140166
duration?: number; // in seconds
141167
classes?: string[];
142-
autofocus?: boolean;
168+
autofocus?: boolean; // defaults to true
143169
buttons?: Array<{
144170
label: string;
145171
callback: Function;
146172
ariaLabel?: string;
147173
classes?: Array<string> | string;
148174
autofocus?: boolean;
149175
}>;
150-
timer?: "vertical" | "horizontal";
176+
timer?: "vertical" | "horizontal" | null; // defaults to null
151177
};
152178
```
153179

build/cleanup.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ const files = [
1212
"snackbar-component.js.map",
1313
"toast-component.js",
1414
"toast-component.js.map",
15+
"notifier.d.ts",
16+
"notify.d.ts",
17+
"snackbar-component.d.ts",
18+
"toast-component.d.ts",
19+
"types.d.ts",
20+
"notify.min.js",
1521
];
1622

1723
function normalizePath(file){

package-lock.json

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

package.json

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codewithkyle/notifyjs",
3-
"version": "2.1.1",
3+
"version": "3.0.0",
44
"description": "A simple JavaScript library for creating and managing toaster & snackbar notifications",
55
"main": "notify.js",
66
"files": [
@@ -12,14 +12,20 @@
1212
"snackbar-component.js.map",
1313
"toast-component.js",
1414
"toast-component.js.map",
15-
"notify.min.mjs"
15+
"notify.min.mjs",
16+
"notifier.d.ts",
17+
"notify.d.ts",
18+
"snackbar-component.d.ts",
19+
"toast-component.d.ts",
20+
"types.d.ts",
21+
"notify.min.js"
1622
],
1723
"scripts": {
1824
"cleanup": "node ./build/cleanup.js",
1925
"compile": "tsc",
2026
"test": "npm run compile && npm run bundle && cp ./notify.min.mjs ./test/notify.min.mjs && serve ./test",
21-
"bundle": "rollup notify.js --file notify.mjs --format es --compact && terser notify.mjs -o notify.min.mjs -c && rm notify.mjs",
22-
"prerelease": "npm run cleanup && npm run compile && npm run bundle"
27+
"bundle": "esbuild ./notify.js --outfile=notify.min.mjs --format=esm --minify --bundle && esbuild ./notify.js --outfile=notify.min.js --format=iife --minify-whitespace --global-name=Notifier --bundle",
28+
"prerelease": "npm run cleanup && npm run compile && npm run bundle && cp ./src/types.d.ts ./types.d.ts"
2329
},
2430
"keywords": [
2531
"snackbar",
@@ -31,9 +37,8 @@
3137
"author": "Kyle Andrews",
3238
"license": "MIT",
3339
"devDependencies": {
34-
"rollup": "^2.37.1",
40+
"esbuild": "^0.10.0",
3541
"serve": "^11.3.2",
36-
"terser": "^5.5.1",
37-
"typescript": "^4.1.3"
42+
"typescript": "^4.2.3"
3843
}
3944
}

0 commit comments

Comments
 (0)