npm_lib_toast 1.1.3 → 1.1.4

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