aark-react-modalify 1.2.0 → 1.2.1
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 +73 -603
- package/dist/aark-react-modalify.css +1 -1
- package/dist/index-no-styles.esm.js +14 -898
- package/package.json +18 -18
package/README.md
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
# AARK React Modalify 🚀
|
|
2
2
|
|
|
3
|
-
A lightweight,
|
|
3
|
+
A lightweight, flexible React modal and notification library with TypeScript support. Features automatic DOM mounting, customizable styling, and a simple imperative API for displaying modals, alerts, confirmations, and toast notifications.
|
|
4
4
|
|
|
5
5
|
## ✨ Features
|
|
6
6
|
|
|
7
7
|
- **Zero Dependencies**: Pure React implementation
|
|
8
8
|
- **TypeScript Support**: Full type safety out of the box
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
- **Class-based Architecture**: Clean, singleton-based API
|
|
12
|
-
- **Fully Customizable**: CSS variables for complete theme control
|
|
9
|
+
- **Dual API**: Component-based OR props-based configuration
|
|
10
|
+
- **Automatic CSS**: Styles included automatically or import separately
|
|
13
11
|
- **Portal Rendering**: Modals render outside your component tree
|
|
14
12
|
- **Accessibility**: Built-in keyboard navigation and focus management
|
|
15
|
-
- **
|
|
13
|
+
- **Customizable**: CSS variables for complete theme control
|
|
14
|
+
- **Multiple Positions**: Various positioning options for modals and notifications
|
|
16
15
|
- **Animation Support**: Smooth fade and slide animations
|
|
17
16
|
- **Hook Integration**: useModal hook for advanced use cases
|
|
18
|
-
- **No Provider Required**: Just import and use anywhere
|
|
19
|
-
- **Minified CSS**: Only 8.97 kB of optimized styles
|
|
20
17
|
|
|
21
18
|
## 📦 Installation
|
|
22
19
|
|
|
@@ -26,11 +23,10 @@ npm install aark-react-modalify
|
|
|
26
23
|
|
|
27
24
|
## 🚀 Quick Start
|
|
28
25
|
|
|
29
|
-
###
|
|
26
|
+
### Component-Based Approach
|
|
30
27
|
|
|
31
28
|
```jsx
|
|
32
29
|
import { aark } from "aark-react-modalify";
|
|
33
|
-
// ✅ CSS is automatically included - no separate import needed!
|
|
34
30
|
|
|
35
31
|
function App() {
|
|
36
32
|
const openModal = () => {
|
|
@@ -47,58 +43,11 @@ function App() {
|
|
|
47
43
|
);
|
|
48
44
|
};
|
|
49
45
|
|
|
50
|
-
return
|
|
51
|
-
<div>
|
|
52
|
-
<button onClick={openModal}>Open Modal</button>
|
|
53
|
-
</div>
|
|
54
|
-
);
|
|
46
|
+
return <button onClick={openModal}>Open Modal</button>;
|
|
55
47
|
}
|
|
56
48
|
```
|
|
57
49
|
|
|
58
|
-
###
|
|
59
|
-
|
|
60
|
-
If you prefer to manage CSS separately:
|
|
61
|
-
|
|
62
|
-
```jsx
|
|
63
|
-
import { aark } from "aark-react-modalify/no-styles";
|
|
64
|
-
import "aark-react-modalify/css";
|
|
65
|
-
|
|
66
|
-
// Rest of your code...
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## 🎯 Component-Based Approach
|
|
70
|
-
|
|
71
|
-
Perfect for complex, reusable modal content:
|
|
72
|
-
|
|
73
|
-
```jsx
|
|
74
|
-
import { aark } from "aark-react-modalify";
|
|
75
|
-
|
|
76
|
-
function App() {
|
|
77
|
-
const openCustomModal = () => {
|
|
78
|
-
aark.fire(
|
|
79
|
-
<div className="my-custom-modal">
|
|
80
|
-
<h2>Custom Modal</h2>
|
|
81
|
-
<form>
|
|
82
|
-
<input type="text" placeholder="Enter your name" />
|
|
83
|
-
<button type="submit">Submit</button>
|
|
84
|
-
</form>
|
|
85
|
-
<button onClick={() => aark.close()}>Cancel</button>
|
|
86
|
-
</div>,
|
|
87
|
-
{
|
|
88
|
-
position: "center",
|
|
89
|
-
showCloseIcon: true,
|
|
90
|
-
clickOutsideToClose: true,
|
|
91
|
-
}
|
|
92
|
-
);
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
return <button onClick={openCustomModal}>Open Custom Modal</button>;
|
|
96
|
-
}
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
## 🎯 Props-Based Approach
|
|
100
|
-
|
|
101
|
-
Perfect for quick alerts, confirmations, and notifications:
|
|
50
|
+
### Props-Based Approach
|
|
102
51
|
|
|
103
52
|
```jsx
|
|
104
53
|
import { aark } from "aark-react-modalify";
|
|
@@ -107,14 +56,12 @@ function App() {
|
|
|
107
56
|
const showConfirmation = () => {
|
|
108
57
|
aark.fire({
|
|
109
58
|
title: "Delete Item",
|
|
110
|
-
text: "Are you sure you want to delete this item?
|
|
59
|
+
text: "Are you sure you want to delete this item?",
|
|
111
60
|
type: "warning",
|
|
112
61
|
showCancelButton: true,
|
|
113
62
|
confirmText: "Yes, delete it!",
|
|
114
63
|
cancelText: "Cancel",
|
|
115
|
-
confirmButtonColor: "#d33",
|
|
116
64
|
onConfirm: () => {
|
|
117
|
-
console.log("Item deleted!");
|
|
118
65
|
aark.notification({
|
|
119
66
|
title: "Deleted!",
|
|
120
67
|
text: "The item has been deleted successfully.",
|
|
@@ -122,34 +69,18 @@ function App() {
|
|
|
122
69
|
timer: 3000,
|
|
123
70
|
});
|
|
124
71
|
},
|
|
125
|
-
onCancel: () => console.log("Deletion cancelled"),
|
|
126
72
|
});
|
|
127
73
|
};
|
|
128
74
|
|
|
129
|
-
|
|
130
|
-
aark.notification({
|
|
131
|
-
title: "Welcome!",
|
|
132
|
-
text: "Thanks for using AARK React Modalify!",
|
|
133
|
-
type: "info",
|
|
134
|
-
timer: 4000,
|
|
135
|
-
position: "top-right",
|
|
136
|
-
});
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
return (
|
|
140
|
-
<div>
|
|
141
|
-
<button onClick={showConfirmation}>Delete Item</button>
|
|
142
|
-
<button onClick={showNotification}>Show Notification</button>
|
|
143
|
-
</div>
|
|
144
|
-
);
|
|
75
|
+
return <button onClick={showConfirmation}>Delete Item</button>;
|
|
145
76
|
}
|
|
146
77
|
```
|
|
147
78
|
|
|
148
79
|
## 📚 API Reference
|
|
149
80
|
|
|
150
|
-
### Modal
|
|
81
|
+
### Modal Methods
|
|
151
82
|
|
|
152
|
-
#### `aark.fire(content, options?)`
|
|
83
|
+
#### `aark.fire(content, options?)` or `aark.fire(props)`
|
|
153
84
|
|
|
154
85
|
**Component-based:**
|
|
155
86
|
|
|
@@ -172,35 +103,50 @@ aark.fire({
|
|
|
172
103
|
});
|
|
173
104
|
```
|
|
174
105
|
|
|
175
|
-
|
|
106
|
+
### Notification Methods
|
|
176
107
|
|
|
177
|
-
|
|
178
|
-
| --------------------- | --------------- | ---------- | ------------------------ |
|
|
179
|
-
| `position` | `ModalPosition` | `"center"` | Modal position |
|
|
180
|
-
| `showCloseIcon` | `boolean` | `false` | Show close button |
|
|
181
|
-
| `clickOutsideToClose` | `boolean` | `true` | Close on backdrop click |
|
|
182
|
-
| `escapeKeyToClose` | `boolean` | `true` | Close on ESC key |
|
|
183
|
-
| `onOpen` | `() => void` | - | Called when modal opens |
|
|
184
|
-
| `onClose` | `() => void` | - | Called when modal closes |
|
|
108
|
+
#### `aark.notification(content, options?)` or `aark.notification(props)`
|
|
185
109
|
|
|
186
|
-
|
|
110
|
+
**Component-based:**
|
|
187
111
|
|
|
188
|
-
|
|
112
|
+
```jsx
|
|
113
|
+
aark.notification(<YourNotification />, options);
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Props-based:**
|
|
189
117
|
|
|
190
118
|
```jsx
|
|
191
119
|
aark.notification({
|
|
192
120
|
title: "Notification Title",
|
|
193
121
|
text: "Notification message",
|
|
194
|
-
type: "success",
|
|
195
|
-
timer: 3000,
|
|
122
|
+
type: "success",
|
|
123
|
+
timer: 3000,
|
|
196
124
|
position: "top-right",
|
|
197
|
-
showCloseButton: true,
|
|
198
|
-
onClick: () => {},
|
|
199
|
-
onClose: () => {},
|
|
200
125
|
});
|
|
201
126
|
```
|
|
202
127
|
|
|
203
|
-
|
|
128
|
+
### Other Methods
|
|
129
|
+
|
|
130
|
+
```jsx
|
|
131
|
+
aark.close(); // Close current modal
|
|
132
|
+
aark.closeAll(); // Close all modals and notifications
|
|
133
|
+
aark.isOpen(); // Check if any modal is open
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## ⚙️ Configuration Options
|
|
137
|
+
|
|
138
|
+
### Modal Options
|
|
139
|
+
|
|
140
|
+
| Option | Type | Default | Description |
|
|
141
|
+
| --------------------- | --------------- | ---------- | ------------------------ |
|
|
142
|
+
| `position` | `ModalPosition` | `"center"` | Modal position |
|
|
143
|
+
| `showCloseIcon` | `boolean` | `false` | Show close button |
|
|
144
|
+
| `clickOutsideToClose` | `boolean` | `true` | Close on backdrop click |
|
|
145
|
+
| `escapeKeyToClose` | `boolean` | `true` | Close on ESC key |
|
|
146
|
+
| `onOpen` | `() => void` | - | Called when modal opens |
|
|
147
|
+
| `onClose` | `() => void` | - | Called when modal closes |
|
|
148
|
+
|
|
149
|
+
### Notification Options
|
|
204
150
|
|
|
205
151
|
| Option | Type | Default | Description |
|
|
206
152
|
| ----------------- | ---------------------- | ------------- | --------------------- |
|
|
@@ -210,8 +156,6 @@ aark.notification({
|
|
|
210
156
|
| `timer` | `number` | `0` | Auto-close timer (ms) |
|
|
211
157
|
| `position` | `NotificationPosition` | `"top-right"` | Notification position |
|
|
212
158
|
| `showCloseButton` | `boolean` | `true` | Show close button |
|
|
213
|
-
| `onClick` | `() => void` | - | Click handler |
|
|
214
|
-
| `onClose` | `() => void` | - | Close handler |
|
|
215
159
|
|
|
216
160
|
### Position Types
|
|
217
161
|
|
|
@@ -234,72 +178,43 @@ type NotificationPosition =
|
|
|
234
178
|
| "bottom-right";
|
|
235
179
|
```
|
|
236
180
|
|
|
237
|
-
### Other Methods
|
|
238
|
-
|
|
239
|
-
```jsx
|
|
240
|
-
aark.close(); // Close current modal
|
|
241
|
-
aark.closeAll(); // Close all modals and notifications
|
|
242
|
-
aark.isOpen(); // Check if any modal is open
|
|
243
|
-
```
|
|
244
|
-
|
|
245
181
|
## 🎨 Customization
|
|
246
182
|
|
|
247
183
|
### CSS Variables
|
|
248
184
|
|
|
249
|
-
Customize the appearance using CSS variables:
|
|
250
|
-
|
|
251
185
|
```css
|
|
252
186
|
:root {
|
|
253
|
-
/* Modal Variables */
|
|
254
187
|
--aark-modal-overlay-bg: rgba(0, 0, 0, 0.5);
|
|
255
188
|
--aark-modal-bg: #fff;
|
|
256
189
|
--aark-modal-radius: 8px;
|
|
257
190
|
--aark-modal-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
|
|
258
191
|
--aark-modal-pad: 16px;
|
|
259
192
|
--aark-modal-z: 9999;
|
|
260
|
-
|
|
261
|
-
/* Notification Variables */
|
|
262
193
|
--aark-notification-bg: #fff;
|
|
263
194
|
--aark-notification-radius: 8px;
|
|
264
195
|
--aark-notification-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
265
196
|
--aark-notification-pad: 16px;
|
|
266
197
|
--aark-notification-z: 10000;
|
|
267
|
-
|
|
268
|
-
/* Shared Variables */
|
|
269
198
|
--aark-close-color: #666;
|
|
270
199
|
--aark-close-hover: #f5f5f5;
|
|
271
200
|
--aark-anim: 0.2s;
|
|
272
201
|
}
|
|
273
202
|
```
|
|
274
203
|
|
|
275
|
-
###
|
|
204
|
+
### CSS Import Options
|
|
276
205
|
|
|
277
|
-
|
|
278
|
-
[data-theme="dark"] {
|
|
279
|
-
--aark-modal-bg: #1f2937;
|
|
280
|
-
--aark-modal-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
|
|
281
|
-
--aark-notification-bg: #374151;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
[data-theme="dark"] .aark-standard-modal .aark-modal-title {
|
|
285
|
-
color: #ffffff;
|
|
286
|
-
}
|
|
206
|
+
**Option 1: Automatic (Default)**
|
|
287
207
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
208
|
+
```jsx
|
|
209
|
+
import { aark } from "aark-react-modalify";
|
|
210
|
+
// CSS is included automatically
|
|
291
211
|
```
|
|
292
212
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
```css
|
|
296
|
-
.aark-standard-modal .aark-modal-confirm-button {
|
|
297
|
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
298
|
-
}
|
|
213
|
+
**Option 2: Manual Import**
|
|
299
214
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
215
|
+
```jsx
|
|
216
|
+
import { aark } from "aark-react-modalify/no-styles";
|
|
217
|
+
import "aark-react-modalify/css";
|
|
303
218
|
```
|
|
304
219
|
|
|
305
220
|
## 🔧 Advanced Usage
|
|
@@ -341,284 +256,12 @@ setAarkModalTheme({
|
|
|
341
256
|
resetAarkModalTheme();
|
|
342
257
|
```
|
|
343
258
|
|
|
344
|
-
##
|
|
345
|
-
|
|
346
|
-
### Option 1: Automatic (Recommended)
|
|
347
|
-
|
|
348
|
-
```jsx
|
|
349
|
-
import { aark } from "aark-react-modalify";
|
|
350
|
-
// CSS is included automatically ✅
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
### Option 2: Manual Import
|
|
354
|
-
|
|
355
|
-
```jsx
|
|
356
|
-
import { aark } from "aark-react-modalify/no-styles";
|
|
357
|
-
import "aark-react-modalify/css";
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
### Option 3: Individual Style Files
|
|
361
|
-
|
|
362
|
-
```jsx
|
|
363
|
-
// For modal-only usage
|
|
364
|
-
import "aark-react-modalify/src/assets/styles/aark-modal-only.css";
|
|
365
|
-
|
|
366
|
-
// For notification-only usage
|
|
367
|
-
import "aark-react-modalify/src/assets/styles/aark-notification-only.css";
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
## 🌐 Framework Compatibility
|
|
371
|
-
|
|
372
|
-
Works seamlessly with:
|
|
373
|
-
|
|
374
|
-
- ✅ **Vite** - CSS automatically processed
|
|
375
|
-
- ✅ **Create React App** - Styles included in bundle
|
|
376
|
-
- ✅ **Next.js** - Works with both App and Pages router
|
|
377
|
-
- ✅ **Webpack** - CSS automatically bundled
|
|
378
|
-
- ✅ **Parcel** - Styles processed automatically
|
|
379
|
-
|
|
380
|
-
## 📊 Bundle Size
|
|
381
|
-
|
|
382
|
-
- **JavaScript**: ~16 kB (minified)
|
|
383
|
-
- **CSS**: 8.97 kB (minified)
|
|
384
|
-
- **Total**: ~25 kB
|
|
385
|
-
- **Gzipped**: ~8 kB (estimated)
|
|
386
|
-
|
|
387
|
-
## 🤝 Contributing
|
|
388
|
-
|
|
389
|
-
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
390
|
-
|
|
391
|
-
## 📄 License
|
|
392
|
-
|
|
393
|
-
MIT License - see the [LICENSE](LICENSE) file for details.
|
|
394
|
-
|
|
395
|
-
## 🆕 What's New in v1.1.0
|
|
396
|
-
|
|
397
|
-
- ✅ **Automatic CSS Import**: No need to import CSS separately
|
|
398
|
-
- ✅ **Optimized Bundle**: CSS minified to 8.97 kB
|
|
399
|
-
- ✅ **Better Tree Shaking**: Import only what you need
|
|
400
|
-
- ✅ **Enhanced TypeScript**: Improved type definitions
|
|
401
|
-
- ✅ **Framework Agnostic**: Works with any modern bundler
|
|
402
|
-
|
|
403
|
-
---
|
|
404
|
-
|
|
405
|
-
Made with ❤️ by [Mohammad Sumon](https://github.com/sumonsbgc)
|
|
406
|
-
|
|
407
|
-
## ✨ Features
|
|
408
|
-
|
|
409
|
-
- **Zero Dependencies**: Pure React implementation
|
|
410
|
-
- **TypeScript Support**: Full type safety out of the box
|
|
411
|
-
- **Dual API**: Use components OR simple props-based configuration
|
|
412
|
-
- **Class-based Architecture**: Clean, singleton-based API
|
|
413
|
-
- **Fully Customizable**: CSS variables for complete theme control
|
|
414
|
-
- **Portal Rendering**: Modals render outside your component tree
|
|
415
|
-
- **Accessibility**: Built-in keyboard navigation and focus management
|
|
416
|
-
- **Multiple Positions**: Center, top, bottom, left, right positioning
|
|
417
|
-
- **Animation Support**: Smooth fade and slide animations
|
|
418
|
-
- **Hook Integration**: useModal hook for advanced use cases
|
|
419
|
-
- **No Provider Required**: Just import and use anywhere
|
|
420
|
-
|
|
421
|
-
## 📦 Installation
|
|
422
|
-
|
|
423
|
-
```bash
|
|
424
|
-
npm install aark-react-modalify
|
|
425
|
-
```
|
|
426
|
-
|
|
427
|
-
## 🚀 Quick Start
|
|
428
|
-
|
|
429
|
-
### Component-Based Approach (Original)
|
|
430
|
-
|
|
431
|
-
```jsx
|
|
432
|
-
import { aark } from "aark-react-modalify";
|
|
433
|
-
|
|
434
|
-
function App() {
|
|
435
|
-
const openModal = () => {
|
|
436
|
-
aark.fire(
|
|
437
|
-
<div>
|
|
438
|
-
<h2>Hello World!</h2>
|
|
439
|
-
<p>This is a simple modal.</p>
|
|
440
|
-
<button onClick={() => aark.close()}>Close</button>
|
|
441
|
-
</div>,
|
|
442
|
-
{
|
|
443
|
-
position: "center",
|
|
444
|
-
showCloseIcon: true,
|
|
445
|
-
}
|
|
446
|
-
);
|
|
447
|
-
};
|
|
448
|
-
|
|
449
|
-
return (
|
|
450
|
-
<div>
|
|
451
|
-
<button onClick={openModal}>Open Modal</button>
|
|
452
|
-
</div>
|
|
453
|
-
);
|
|
454
|
-
}
|
|
455
|
-
```
|
|
456
|
-
|
|
457
|
-
### Props-Based Approach (New!)
|
|
458
|
-
|
|
459
|
-
```jsx
|
|
460
|
-
import { aark } from "aark-react-modalify";
|
|
461
|
-
|
|
462
|
-
function App() {
|
|
463
|
-
const openModal = () => {
|
|
464
|
-
aark.fire({
|
|
465
|
-
title: "Confirmation",
|
|
466
|
-
text: "Are you sure you want to proceed?",
|
|
467
|
-
type: "question",
|
|
468
|
-
showCancelButton: true,
|
|
469
|
-
confirmText: "Yes, proceed!",
|
|
470
|
-
cancelText: "Cancel",
|
|
471
|
-
onConfirm: () => console.log("Confirmed!"),
|
|
472
|
-
onCancel: () => console.log("Cancelled!"),
|
|
473
|
-
});
|
|
474
|
-
};
|
|
475
|
-
|
|
476
|
-
const openNotification = () => {
|
|
477
|
-
aark.notification({
|
|
478
|
-
title: "Success!",
|
|
479
|
-
text: "Your action was completed successfully.",
|
|
480
|
-
type: "success",
|
|
481
|
-
timer: 3000,
|
|
482
|
-
});
|
|
483
|
-
};
|
|
484
|
-
|
|
485
|
-
return (
|
|
486
|
-
<div>
|
|
487
|
-
<button onClick={openModal}>Open Props Modal</button>
|
|
488
|
-
<button onClick={openNotification}>Show Notification</button>
|
|
489
|
-
</div>
|
|
490
|
-
);
|
|
491
|
-
}
|
|
492
|
-
```
|
|
493
|
-
|
|
494
|
-
## 📋 API Methods
|
|
495
|
-
|
|
496
|
-
### `aark.fire(contentOrProps, options?)`
|
|
497
|
-
|
|
498
|
-
Display a modal with either component content or props configuration.
|
|
499
|
-
|
|
500
|
-
**Component-based usage:**
|
|
501
|
-
|
|
502
|
-
```jsx
|
|
503
|
-
aark.fire(<MyComponent />, { position: "center" });
|
|
504
|
-
```
|
|
505
|
-
|
|
506
|
-
**Props-based usage:**
|
|
507
|
-
|
|
508
|
-
```jsx
|
|
509
|
-
aark.fire({
|
|
510
|
-
title: "Alert",
|
|
511
|
-
text: "This is a simple alert",
|
|
512
|
-
type: "info",
|
|
513
|
-
});
|
|
514
|
-
```
|
|
515
|
-
|
|
516
|
-
### `aark.modal(contentOrProps, options?)`
|
|
517
|
-
|
|
518
|
-
Same as `aark.fire()` - display a modal.
|
|
519
|
-
|
|
520
|
-
### `aark.notification(contentOrProps, options?)`
|
|
521
|
-
|
|
522
|
-
Display a notification with either component content or props configuration.
|
|
523
|
-
|
|
524
|
-
**Component-based usage:**
|
|
525
|
-
|
|
526
|
-
```jsx
|
|
527
|
-
aark.notification(<MyNotification />, { position: "top-right" });
|
|
528
|
-
```
|
|
529
|
-
|
|
530
|
-
**Props-based usage:**
|
|
531
|
-
|
|
532
|
-
```jsx
|
|
533
|
-
aark.notification({
|
|
534
|
-
title: "New Message",
|
|
535
|
-
text: "You have a new message!",
|
|
536
|
-
type: "info",
|
|
537
|
-
timer: 5000,
|
|
538
|
-
});
|
|
539
|
-
```
|
|
540
|
-
|
|
541
|
-
### Other Methods
|
|
542
|
-
|
|
543
|
-
- `aark.close()` - Close the currently open modal/notification
|
|
544
|
-
- `aark.isOpen()` - Check if a modal is currently open
|
|
545
|
-
- `aark.closeAll()` - Close all open modals/notifications
|
|
546
|
-
|
|
547
|
-
## 🎨 Props-Based Configuration
|
|
548
|
-
|
|
549
|
-
### Modal Props
|
|
550
|
-
|
|
551
|
-
```typescript
|
|
552
|
-
interface ModalProps {
|
|
553
|
-
title?: string; // Modal title
|
|
554
|
-
text?: string; // Modal text content
|
|
555
|
-
type?: "success" | "error" | "warning" | "info" | "question";
|
|
556
|
-
cancelText?: string; // Cancel button text
|
|
557
|
-
confirmText?: string; // Confirm button text
|
|
558
|
-
onCancel?: () => void; // Cancel button callback
|
|
559
|
-
onConfirm?: () => void; // Confirm button callback
|
|
560
|
-
icon?: string | ReactNode; // Custom icon
|
|
561
|
-
html?: string | ReactNode; // HTML content (instead of text)
|
|
562
|
-
showCancelButton?: boolean; // Show cancel button
|
|
563
|
-
showConfirmButton?: boolean; // Show confirm button
|
|
564
|
-
allowOutsideClick?: boolean; // Allow closing by clicking outside
|
|
565
|
-
allowEscapeKey?: boolean; // Allow closing with Escape key
|
|
566
|
-
reverseButtons?: boolean; // Reverse button order
|
|
567
|
-
width?: string | number; // Modal width
|
|
568
|
-
padding?: string | number; // Modal padding
|
|
569
|
-
background?: string; // Modal background color
|
|
570
|
-
customClass?: {
|
|
571
|
-
// Custom CSS classes
|
|
572
|
-
container?: string;
|
|
573
|
-
popup?: string;
|
|
574
|
-
header?: string;
|
|
575
|
-
title?: string;
|
|
576
|
-
closeButton?: string;
|
|
577
|
-
icon?: string;
|
|
578
|
-
content?: string;
|
|
579
|
-
actions?: string;
|
|
580
|
-
confirmButton?: string;
|
|
581
|
-
cancelButton?: string;
|
|
582
|
-
footer?: string;
|
|
583
|
-
};
|
|
584
|
-
}
|
|
585
|
-
```
|
|
586
|
-
|
|
587
|
-
### Notification Props
|
|
588
|
-
|
|
589
|
-
```typescript
|
|
590
|
-
interface NotificationProps {
|
|
591
|
-
title?: string; // Notification title
|
|
592
|
-
text?: string; // Notification text content
|
|
593
|
-
type?: "success" | "error" | "warning" | "info" | "question";
|
|
594
|
-
icon?: string | ReactNode; // Custom icon
|
|
595
|
-
html?: string | ReactNode; // HTML content (instead of text)
|
|
596
|
-
timer?: number; // Auto-close timer (ms)
|
|
597
|
-
showCloseButton?: boolean; // Show close button
|
|
598
|
-
clickToClose?: boolean; // Close on click
|
|
599
|
-
width?: string | number; // Notification width
|
|
600
|
-
padding?: string | number; // Notification padding
|
|
601
|
-
background?: string; // Notification background color
|
|
602
|
-
customClass?: {
|
|
603
|
-
// Custom CSS classes
|
|
604
|
-
container?: string;
|
|
605
|
-
popup?: string;
|
|
606
|
-
header?: string;
|
|
607
|
-
title?: string;
|
|
608
|
-
closeButton?: string;
|
|
609
|
-
icon?: string;
|
|
610
|
-
content?: string;
|
|
611
|
-
footer?: string;
|
|
612
|
-
};
|
|
613
|
-
}
|
|
614
|
-
```
|
|
615
|
-
|
|
616
|
-
## 💡 Usage Examples
|
|
259
|
+
## 💡 Examples
|
|
617
260
|
|
|
618
261
|
### Success Modal
|
|
619
262
|
|
|
620
263
|
```jsx
|
|
621
|
-
aark.
|
|
264
|
+
aark.fire({
|
|
622
265
|
title: "Success!",
|
|
623
266
|
text: "Your data has been saved successfully.",
|
|
624
267
|
type: "success",
|
|
@@ -629,17 +272,14 @@ aark.modal({
|
|
|
629
272
|
### Confirmation Dialog
|
|
630
273
|
|
|
631
274
|
```jsx
|
|
632
|
-
aark.
|
|
275
|
+
aark.fire({
|
|
633
276
|
title: "Delete Item",
|
|
634
|
-
text: "
|
|
277
|
+
text: "This action cannot be undone.",
|
|
635
278
|
type: "warning",
|
|
636
279
|
showCancelButton: true,
|
|
637
280
|
confirmText: "Yes, delete it!",
|
|
638
281
|
cancelText: "Cancel",
|
|
639
|
-
onConfirm: () =>
|
|
640
|
-
// Delete logic here
|
|
641
|
-
console.log("Item deleted");
|
|
642
|
-
},
|
|
282
|
+
onConfirm: () => console.log("Item deleted"),
|
|
643
283
|
});
|
|
644
284
|
```
|
|
645
285
|
|
|
@@ -654,208 +294,38 @@ aark.notification({
|
|
|
654
294
|
});
|
|
655
295
|
```
|
|
656
296
|
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
```jsx
|
|
660
|
-
aark.modal({
|
|
661
|
-
title: "Custom Content",
|
|
662
|
-
html: `
|
|
663
|
-
<div>
|
|
664
|
-
<p>This is <strong>custom HTML</strong> content.</p>
|
|
665
|
-
<ul>
|
|
666
|
-
<li>Feature 1</li>
|
|
667
|
-
<li>Feature 2</li>
|
|
668
|
-
</ul>
|
|
669
|
-
</div>
|
|
670
|
-
`,
|
|
671
|
-
type: "info",
|
|
672
|
-
});
|
|
673
|
-
```
|
|
674
|
-
|
|
675
|
-
### Using Component-Based Approach (Original)
|
|
676
|
-
|
|
677
|
-
```jsx
|
|
678
|
-
// You can still use the original component-based approach
|
|
679
|
-
aark.modal(
|
|
680
|
-
<div style={{ padding: "2rem" }}>
|
|
681
|
-
<h2>Custom Component</h2>
|
|
682
|
-
<p>This is a custom React component!</p>
|
|
683
|
-
<button onClick={() => aark.close()}>Close</button>
|
|
684
|
-
</div>,
|
|
685
|
-
{
|
|
686
|
-
position: "center",
|
|
687
|
-
showCloseIcon: false,
|
|
688
|
-
}
|
|
689
|
-
);
|
|
690
|
-
```
|
|
691
|
-
|
|
692
|
-
## 🎨 Theme Customization
|
|
693
|
-
|
|
694
|
-
AARK React Modalify supports full theme customization through CSS variables:
|
|
695
|
-
|
|
696
|
-
```jsx
|
|
697
|
-
import { aark } from "aark-react-modalify";
|
|
698
|
-
|
|
699
|
-
// Set custom theme
|
|
700
|
-
aark.setTheme({
|
|
701
|
-
modalBackground: "#1a1a1a",
|
|
702
|
-
overlayBackground: "rgba(0, 0, 0, 0.8)",
|
|
703
|
-
closeButtonColor: "#ffffff",
|
|
704
|
-
closeButtonHoverBackground: "rgba(255, 255, 255, 0.1)",
|
|
705
|
-
modalBorderRadius: "12px",
|
|
706
|
-
animationDuration: "0.3s",
|
|
707
|
-
});
|
|
708
|
-
|
|
709
|
-
// Fire modal with custom theme
|
|
710
|
-
aark.fire({ title: "Themed Modal", text: "This modal uses custom theme!" });
|
|
711
|
-
|
|
712
|
-
// Reset to default theme
|
|
713
|
-
aark.resetTheme();
|
|
714
|
-
|
|
715
|
-
// Get current theme
|
|
716
|
-
const currentTheme = aark.getTheme();
|
|
717
|
-
```
|
|
718
|
-
|
|
719
|
-
## ⚙️ Modal Options (for component-based approach)
|
|
720
|
-
|
|
721
|
-
```typescript
|
|
722
|
-
interface ModalOptions {
|
|
723
|
-
position?:
|
|
724
|
-
| "center"
|
|
725
|
-
| "top-center"
|
|
726
|
-
| "top-right"
|
|
727
|
-
| "bottom-right"
|
|
728
|
-
| "bottom-center";
|
|
729
|
-
showCloseIcon?: boolean;
|
|
730
|
-
className?: string;
|
|
731
|
-
overlayClassName?: string;
|
|
732
|
-
preventEscClose?: boolean;
|
|
733
|
-
preventOverlayClose?: boolean;
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
interface NotificationOptions {
|
|
737
|
-
position?:
|
|
738
|
-
| "top-right"
|
|
739
|
-
| "top-center"
|
|
740
|
-
| "top-left"
|
|
741
|
-
| "bottom-right"
|
|
742
|
-
| "bottom-center"
|
|
743
|
-
| "bottom-left";
|
|
744
|
-
showCloseIcon?: boolean;
|
|
745
|
-
autoCloseTime?: number;
|
|
746
|
-
className?: string;
|
|
747
|
-
preventEscClose?: boolean;
|
|
748
|
-
}
|
|
749
|
-
```
|
|
750
|
-
|
|
751
|
-
## 🎨 Theme Properties
|
|
752
|
-
|
|
753
|
-
```typescript
|
|
754
|
-
interface AarkModalTheme {
|
|
755
|
-
// Overlay
|
|
756
|
-
overlayBackground?: string;
|
|
757
|
-
overlayBlur?: string;
|
|
758
|
-
|
|
759
|
-
// Modal
|
|
760
|
-
modalBackground?: string;
|
|
761
|
-
modalBorderRadius?: string;
|
|
762
|
-
modalShadow?: string;
|
|
763
|
-
modalPadding?: string;
|
|
764
|
-
modalZIndex?: number;
|
|
765
|
-
modalContentZIndex?: number;
|
|
766
|
-
|
|
767
|
-
// Close button
|
|
768
|
-
closeButtonColor?: string;
|
|
769
|
-
closeButtonHoverBackground?: string;
|
|
770
|
-
closeButtonHoverColor?: string;
|
|
771
|
-
closeButtonFocusOutline?: string;
|
|
772
|
-
|
|
773
|
-
// Animation
|
|
774
|
-
animationDuration?: string;
|
|
775
|
-
fadeDuration?: string;
|
|
776
|
-
|
|
777
|
-
// Custom styles
|
|
778
|
-
customOverlayBackground?: string;
|
|
779
|
-
customOverlayBlur?: string;
|
|
780
|
-
customModalGradientStart?: string;
|
|
781
|
-
customModalGradientEnd?: string;
|
|
782
|
-
customModalTextColor?: string;
|
|
783
|
-
customModalShadow?: string;
|
|
784
|
-
customModalCloseColor?: string;
|
|
785
|
-
customModalCloseHoverBackground?: string;
|
|
786
|
-
customModalCloseHoverColor?: string;
|
|
787
|
-
}
|
|
788
|
-
```
|
|
789
|
-
|
|
790
|
-
## 🔗 React Hook Integration
|
|
791
|
-
|
|
792
|
-
For advanced use cases, you can use the `useModal` hook:
|
|
297
|
+
## 🌐 Framework Compatibility
|
|
793
298
|
|
|
794
|
-
|
|
795
|
-
|
|
299
|
+
- ✅ **Vite** - CSS automatically processed
|
|
300
|
+
- ✅ **Create React App** - Styles included in bundle
|
|
301
|
+
- ✅ **Next.js** - Works with both App and Pages router
|
|
302
|
+
- ✅ **Webpack** - CSS automatically bundled
|
|
303
|
+
- ✅ **Parcel** - Styles processed automatically
|
|
796
304
|
|
|
797
|
-
|
|
798
|
-
const { modals, close } = useModal();
|
|
305
|
+
## 📊 Bundle Size
|
|
799
306
|
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
);
|
|
805
|
-
}
|
|
806
|
-
```
|
|
307
|
+
- **JavaScript**: ~16 kB (minified)
|
|
308
|
+
- **CSS**: ~9 kB (minified)
|
|
309
|
+
- **Total**: ~25 kB
|
|
310
|
+
- **Gzipped**: ~8 kB (estimated)
|
|
807
311
|
|
|
808
|
-
## 🆚
|
|
312
|
+
## 🆚 Component vs Props-Based
|
|
809
313
|
|
|
810
314
|
| Feature | Component-Based | Props-Based |
|
|
811
315
|
| --------------- | --------------------------- | --------------------------- |
|
|
812
316
|
| **Flexibility** | Complete control over JSX | Predefined templates |
|
|
813
317
|
| **Ease of Use** | Requires React knowledge | Simple object configuration |
|
|
814
318
|
| **Styling** | Full CSS control | Built-in styled templates |
|
|
815
|
-
| **Type Safety** | ReactNode typing | Structured props interface |
|
|
816
319
|
| **Best for** | Complex UIs, custom designs | Quick alerts, confirmations |
|
|
817
320
|
|
|
818
|
-
**When to use Component-Based:**
|
|
819
|
-
|
|
820
|
-
- Complex modal content
|
|
821
|
-
- Custom styling requirements
|
|
822
|
-
- Existing React components
|
|
823
|
-
- Advanced interactions
|
|
824
|
-
|
|
825
|
-
**When to use Props-Based:**
|
|
826
|
-
|
|
827
|
-
- Quick alerts and confirmations
|
|
828
|
-
- Consistent design system
|
|
829
|
-
- Simple notifications
|
|
830
|
-
- Rapid prototyping
|
|
831
|
-
|
|
832
|
-
## 🛠️ Development
|
|
833
|
-
|
|
834
|
-
```bash
|
|
835
|
-
# Install dependencies
|
|
836
|
-
npm install
|
|
837
|
-
|
|
838
|
-
# Start development server
|
|
839
|
-
npm run dev
|
|
840
|
-
|
|
841
|
-
# Build for production
|
|
842
|
-
npm run build
|
|
843
|
-
|
|
844
|
-
# Type checking
|
|
845
|
-
npm run type-check
|
|
846
|
-
|
|
847
|
-
# Linting
|
|
848
|
-
npm run lint
|
|
849
|
-
```
|
|
850
|
-
|
|
851
321
|
## 📄 License
|
|
852
322
|
|
|
853
|
-
|
|
323
|
+
MIT License - see the [LICENSE](LICENSE) file for details.
|
|
854
324
|
|
|
855
325
|
## 🤝 Contributing
|
|
856
326
|
|
|
857
327
|
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
858
328
|
|
|
859
|
-
|
|
329
|
+
---
|
|
860
330
|
|
|
861
|
-
|
|
331
|
+
Made with ❤️ by [Mohammad Sumon](https://github.com/sumonsbgc)
|