react-smooth-stack-notifications 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -0
- package/dist/NotificationContainer.d.ts +10 -0
- package/dist/NotificationContainer.d.ts.map +1 -0
- package/dist/NotificationContext.d.ts +22 -0
- package/dist/NotificationContext.d.ts.map +1 -0
- package/dist/NotificationItem.d.ts +11 -0
- package/dist/NotificationItem.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +11106 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +11127 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +50 -0
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# React Smooth Notifications
|
|
2
|
+
|
|
3
|
+
A very smooth, stack-like notification system for React applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @yourname/react-smooth-notifications
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
1. Wrap your app with NotificationProvider:
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { NotificationProvider } from '@yourname/react-smooth-notifications';
|
|
17
|
+
|
|
18
|
+
function App() {
|
|
19
|
+
return (
|
|
20
|
+
<NotificationProvider>
|
|
21
|
+
{/* Your app */}
|
|
22
|
+
</NotificationProvider>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
2. Use the hook in your components:
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import { useNotification } from '@yourname/react-smooth-notifications';
|
|
31
|
+
|
|
32
|
+
function MyComponent() {
|
|
33
|
+
const { success, error, warning, info } = useNotification();
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div>
|
|
37
|
+
<button onClick={() => success('Operation completed!')}>
|
|
38
|
+
Success
|
|
39
|
+
</button>
|
|
40
|
+
<button onClick={() => error('Something went wrong!')}>
|
|
41
|
+
Error
|
|
42
|
+
</button>
|
|
43
|
+
<button onClick={() => warning('Be careful!')}>
|
|
44
|
+
Warning
|
|
45
|
+
</button>
|
|
46
|
+
<button onClick={() => info('Here is some info')}>
|
|
47
|
+
Info
|
|
48
|
+
</button>
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## API
|
|
55
|
+
|
|
56
|
+
- `success(message, duration?)` - Show success notification
|
|
57
|
+
- `error(message, duration?)` - Show error notification
|
|
58
|
+
- `warning(message, duration?)` - Show warning notification
|
|
59
|
+
- `info(message, duration?)` - Show info notification
|
|
60
|
+
|
|
61
|
+
Default duration is 3000ms (3 seconds).
|
|
62
|
+
|
|
63
|
+
## Features
|
|
64
|
+
|
|
65
|
+
- 🎨 Beautiful gradient backgrounds
|
|
66
|
+
- 🌊 Smooth animations with cubic-bezier easing
|
|
67
|
+
- 📚 Stack-like behavior with scaling effect
|
|
68
|
+
- 🎯 Auto-dismiss with customizable duration
|
|
69
|
+
- ❌ Manual dismiss by clicking close button
|
|
70
|
+
- 🎭 4 notification types: success, error, warning, info
|
|
71
|
+
- 📱 Responsive design
|
|
72
|
+
- ⚡ Lightweight and performant
|
|
73
|
+
|
|
74
|
+
## Build
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm install
|
|
78
|
+
npm run build
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Publish to NPM
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npm login
|
|
85
|
+
npm publish --access public
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
MIT
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Notification } from './types';
|
|
3
|
+
import './styles.css';
|
|
4
|
+
interface NotificationContainerProps {
|
|
5
|
+
notifications: Notification[];
|
|
6
|
+
onRemove: (id: string) => void;
|
|
7
|
+
}
|
|
8
|
+
declare const NotificationContainer: React.FC<NotificationContainerProps>;
|
|
9
|
+
export default NotificationContainer;
|
|
10
|
+
//# sourceMappingURL=NotificationContainer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationContainer.d.ts","sourceRoot":"","sources":["../src/NotificationContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,cAAc,CAAC;AAEtB,UAAU,0BAA0B;IAClC,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAED,QAAA,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAgB/D,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NotificationType } from './types';
|
|
3
|
+
interface NotificationOptions {
|
|
4
|
+
bgColor?: string;
|
|
5
|
+
textColor?: string;
|
|
6
|
+
type?: NotificationType;
|
|
7
|
+
duration?: number;
|
|
8
|
+
}
|
|
9
|
+
interface NotificationContextType {
|
|
10
|
+
showNotification: (message: string, options?: NotificationOptions) => void;
|
|
11
|
+
success: (message: string, options?: NotificationOptions) => void;
|
|
12
|
+
error: (message: string, options?: NotificationOptions) => void;
|
|
13
|
+
warning: (message: string, options?: NotificationOptions) => void;
|
|
14
|
+
info: (message: string, options?: NotificationOptions) => void;
|
|
15
|
+
alert: (message: string, options?: NotificationOptions) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare const useNotification: () => NotificationContextType;
|
|
18
|
+
export declare const NotificationProvider: React.FC<{
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
}>;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=NotificationContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationContext.d.ts","sourceRoot":"","sources":["../src/NotificationContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8C,MAAM,OAAO,CAAC;AACnE,OAAO,EAAgB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGzD,UAAU,mBAAmB;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,uBAAuB;IAC/B,gBAAgB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC3E,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAClE,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAChE,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAClE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC/D,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACjE;AAID,eAAO,MAAM,eAAe,+BAM3B,CAAC;AAIF,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CA+DxE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Notification } from './types';
|
|
3
|
+
interface NotificationItemProps {
|
|
4
|
+
notification: Notification;
|
|
5
|
+
onRemove: (id: string) => void;
|
|
6
|
+
index: number;
|
|
7
|
+
totalCount: number;
|
|
8
|
+
}
|
|
9
|
+
declare const NotificationItem: React.FC<NotificationItemProps>;
|
|
10
|
+
export default NotificationItem;
|
|
11
|
+
//# sourceMappingURL=NotificationItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationItem.d.ts","sourceRoot":"","sources":["../src/NotificationItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,UAAU,qBAAqB;IAC7B,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CA2ErD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC9E,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC"}
|