Skip to content

Commit ca0d31f

Browse files
authored
Merge pull request #16 from codewithkyle/v2.1.0
V2.1.0
2 parents b9b4d61 + 076cd40 commit ca0d31f

File tree

11 files changed

+1272
-682
lines changed

11 files changed

+1272
-682
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ snackbar-component.js
1111
snackbar-component.js.map
1212
toast-component.js
1313
toast-component.js.map
14+
notify.min.mjs
15+
notify.mjs

CHANGELOG.md

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

88
## [Unreleased]
99

10+
## [2.1.0] - 2020-11-09
11+
12+
### Added
13+
14+
- ability to autofocus buttons ([#14](https://github.com/codewithkyle/notifyjs/issues/14))
15+
- CDN compatible version (ES Module)
16+
- role attributes to snackbar and toast notifications
17+
- toast notificaitons can contain buttons ([#15](https://github.com/codewithkyle/notifyjs/issues/15))
18+
- toast notification timers ([#13](https://github.com/codewithkyle/notifyjs/issues/13))
19+
- updated readme
20+
21+
### Fixed
22+
23+
- toast notifications now stack with oldest notifications appearing at the bottom (better UX/expected notification behavior)
24+
1025
## [2.0.3] - 2020-09-16
1126

1227
### Fixed
@@ -115,7 +130,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
115130

116131
- Entire existing codebase due to rewrite
117132

118-
[unreleased]: https://github.com/codewithkyle/notifyjs/compare/v2.0.1...HEAD
133+
[unreleased]: https://github.com/codewithkyle/notifyjs/compare/v2.1.0...HEAD
134+
[2.1.0]: https://github.com/codewithkyle/notifyjs/compare/v2.0.3...v2.1.0
135+
[2.0.3]: https://github.com/codewithkyle/notifyjs/compare/v2.0.1...v2.0.3
119136
[2.0.1]: https://github.com/codewithkyle/notifyjs/compare/v2.0.0...v2.0.1
120137
[2.0.0]: https://github.com/codewithkyle/notifyjs/compare/v1.2.0...v2.0.0
121138
[1.2.0]: https://github.com/codewithkyle/notifyjs/compare/v1.1.0...v1.2.0

README.md

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

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

55
## Installation
66

@@ -10,8 +10,23 @@ Download Notify.js via NPM:
1010
npm i --save @codewithkyle/notifyjs
1111
```
1212

13+
Or use the CDN version:
14+
15+
```javascript
16+
import { Notifier, snackbar, toast } from "https://cdn.jsdelivr.net/npm/@codewithkyle/notifyjs@2.1.0/notify.min.mjs;
17+
```
18+
1319
## Usage
1420
21+
1. [Notification Manager](#notification-manager)
22+
1. [Global Notifications](#global-manager)
23+
1. [Snackbar Notification](#snackbar-notification)
24+
1. [Snackbar Interface](#snackbar-interface)
25+
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+
1530
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.
1631
1732
### Notification Manager
@@ -53,12 +68,31 @@ notifier.toast({
5368
title: "Toast notificaitons require a title",
5469
message: "And they require a message",
5570
});
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+
});
5684
```
5785
86+
---
87+
5888
## Snackbar Notification
5989
90+
Snackbar notifications are great for quick one-off notifications.
91+
92+
### Snackbar Interface
93+
6094
```typescript
61-
interface NotificationOptions {
95+
interface SnackbarNotification {
6296
message: string;
6397
duration?: number; // in seconds
6498
closeable?: boolean;
@@ -67,31 +101,15 @@ interface NotificationOptions {
67101
callback: Function;
68102
ariaLabel?: string;
69103
classes?: Array<string> | string;
104+
autofocus?: boolean;
70105
}>;
71106
force?: boolean;
72107
classes?: Array<string> | string;
108+
autofocus?: boolean;
73109
}
74110
```
75111
76-
### User Interaction
77-
78-
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
95113
96114
```html
97115
<snackbar-component>
@@ -105,8 +123,14 @@ notify({
105123
</snackbar-component>
106124
```
107125
126+
---
127+
108128
## Toast Notification
109129
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+
110134
```typescript
111135
type ToasterNotification = {
112136
title: string;
@@ -115,10 +139,19 @@ type ToasterNotification = {
115139
icon?: string; // svg or img
116140
duration?: number; // in seconds
117141
classes?: string[];
142+
autofocus?: boolean;
143+
buttons?: Array<{
144+
label: string;
145+
callback: Function;
146+
ariaLabel?: string;
147+
classes?: Array<string> | string;
148+
autofocus?: boolean;
149+
}>;
150+
timer?: "vertical" | "horizontal";
118151
};
119152
```
120153
121-
### HTML Structure
154+
### Toast HTML Structure
122155
123156
```html
124157
<toaster-component>
@@ -129,6 +162,9 @@ type ToasterNotification = {
129162
<copy-wrapper>
130163
<h3>Title</h3>
131164
<p>Custom notification message</p>
165+
<toast-actions>
166+
<button>Action</button>
167+
</toast-actions>
132168
</copy-wrapper>
133169
<button>
134170
<svg />

0 commit comments

Comments
 (0)