@4i/modal-manager 1.0.10 → 1.0.102
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/package.json +1 -1
- package/readme.md +17 -4
package/package.json
CHANGED
package/readme.md
CHANGED
@@ -15,6 +15,16 @@ npm install @4i/modal-manager
|
|
15
15
|
|
16
16
|
## Usage
|
17
17
|
|
18
|
+
#### Instance methods:
|
19
|
+
|
20
|
+
##### .call(action, props)
|
21
|
+
|
22
|
+
Call a modal by its action name and pass props to it.
|
23
|
+
|
24
|
+
##### .close()
|
25
|
+
|
26
|
+
Close all modals.
|
27
|
+
|
18
28
|
#### Define Modal Actions:
|
19
29
|
|
20
30
|
In your project, define modal actions as keys in the modalAction object. Each key represents a specific modal or UI element.
|
@@ -53,8 +63,6 @@ modal.call(modalAction.MODAL_PROMPT, {
|
|
53
63
|
|
54
64
|
If desired, you can inherit from the Manager class to create your own classes for handling custom notifications, popups, and more. And then pass your custom class to the CustomProvider component using ModalProvider as an example
|
55
65
|
|
56
|
-
````javascript
|
57
|
-
|
58
66
|
```javascript
|
59
67
|
import { Manager } from "@4i/modal-manager";
|
60
68
|
|
@@ -63,7 +71,7 @@ class CustomManager extends Manager {
|
|
63
71
|
}
|
64
72
|
|
65
73
|
const customManager = new CustomManager();
|
66
|
-
|
74
|
+
```
|
67
75
|
|
68
76
|
### index.js
|
69
77
|
|
@@ -133,14 +141,19 @@ export default App;
|
|
133
141
|
|
134
142
|
```javascript
|
135
143
|
import React from "react";
|
144
|
+
import { modal } from "@4i/modal-manager";
|
136
145
|
|
137
146
|
// Get props
|
138
147
|
const ModalPrompts = ({ title, content }) => {
|
148
|
+
const handleClose = () => {
|
149
|
+
modal.close();
|
150
|
+
};
|
151
|
+
|
139
152
|
return (
|
140
153
|
<div className="w-[400px] h-[300px] bg-slate-50 p-[24px] flex flex-col justify-center items-center">
|
141
154
|
<h1>{title}</h1>
|
142
155
|
<p>{content}</p>
|
143
|
-
<button>Close</button>
|
156
|
+
<button onClick={handleClose}>Close</button>
|
144
157
|
</div>
|
145
158
|
);
|
146
159
|
};
|