@sriramvenkatesan/react-toast-popup 1.1.3 → 1.1.5

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.
Files changed (2) hide show
  1. package/README.md +129 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,129 @@
1
+ # React Toast Popup
2
+
3
+ React Toast Popup is a simple and customizable toast notification component for React applications.
4
+
5
+
6
+ ## Installation
7
+
8
+ You can install React Toast Popup via npm:
9
+
10
+ ```jsx
11
+ npm install react-toast-popup
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ To use React Toast Popup in your React application, follow these steps:
17
+
18
+ Import the useNotification hook and necessary styles in your component:
19
+
20
+ ```jsx
21
+ import useNotification from "react-toast-popup";
22
+ ```
23
+
24
+ Initialize the useNotification hook with your preferred position:
25
+
26
+ ```jsx
27
+ const { NotificationComponent, triggerNotification } =
28
+ useNotification("top-left");
29
+ ```
30
+
31
+ #### Postions
32
+
33
+ - "bottom-left"
34
+ - "bottom-right"
35
+ - "top-left"
36
+ - "top-right"
37
+
38
+ Use NotificationComponent in your JSX to display notifications:
39
+
40
+ ```jsx
41
+ return (
42
+ <div className="App">
43
+ {NotificationComponent}
44
+ {/* Your other JSX content */}
45
+ </div>
46
+ );
47
+ ```
48
+
49
+ Trigger notifications using the triggerNotification function:
50
+
51
+ ```jsx
52
+ triggerNotification({
53
+ type: "success",
54
+ message: "This is a success message!",
55
+ duration: 3000,
56
+ });
57
+ ```
58
+
59
+ #### Animations
60
+
61
+ You can specify an animation type for the notifications. The available animations are:
62
+
63
+ - "fade"
64
+ - "pop"
65
+ - "slide"
66
+
67
+ ```jsx
68
+ triggerNotification({
69
+ type: "success",
70
+ message: "This is a success message with a pop animation!",
71
+ duration: 3000,
72
+ animation: "pop",
73
+ });
74
+ ```
75
+
76
+ ## API
77
+
78
+ ```jsx
79
+ useNotification(position: PositionType)
80
+ ```
81
+
82
+ This hook returns an object with the following properties:
83
+
84
+ - `NotificationComponent`: React element representing the notification container.
85
+ - `triggerNotification(notificationProps: NotificationProps)`: Function to trigger a notification with the specified properties.
86
+
87
+ `NotificationProps`
88
+ The triggerNotification function accepts an object of type NotificationProps, which includes:
89
+
90
+ - type: Type of the notification (success, info, warning, error).
91
+ - message: Message to display in the notification.
92
+ - duration: Duration in milliseconds for which the notification should be displayed.
93
+ - animation (optional): Animation type for the notification (fade, pop, slide).
94
+
95
+ ## Example
96
+
97
+ Here's a basic example of how to use React Toast Popup:
98
+
99
+ ```jsx
100
+ import React from "react";
101
+ import useNotification from "react-toast-popup";
102
+
103
+ function App() {
104
+ const { NotificationComponent, triggerNotification } =
105
+ useNotification("top-left");
106
+
107
+ const handleButtonClick = () => {
108
+ triggerNotification({
109
+ type: "success",
110
+ message: "This is a success message!",
111
+ duration: 3000,
112
+ });
113
+ };
114
+
115
+ return (
116
+ <div className="App">
117
+ {NotificationComponent}
118
+ <h1>Toast Component</h1>
119
+ <button onClick={handleButtonClick}>Show Success</button>
120
+ </div>
121
+ );
122
+ }
123
+
124
+ export default App;
125
+ ```
126
+
127
+ ## License
128
+
129
+ This project is licensed under the MIT License - see the LICENSE file for details.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sriramvenkatesan/react-toast-popup",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "description": "React Toast Popup is a simple and customizable toast notification component for React applications.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -44,4 +44,4 @@
44
44
  "react-icons": "^5.2.1",
45
45
  "uuid": "^10.0.0"
46
46
  }
47
- }
47
+ }