d9-toast 1.0.0 → 1.0.2
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 +121 -0
- package/dist/ToastContext.js +0 -1
- package/package.json +2 -2
- package/src/index.js +0 -2
package/README.md
CHANGED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# D9-Toast
|
|
2
|
+
|
|
3
|
+
Customizable toast notifications for React with TailwindCSS support.
|
|
4
|
+
|
|
5
|
+
**Features:**
|
|
6
|
+
|
|
7
|
+
* Lightweight and fully customizable toast notifications.
|
|
8
|
+
* Built with React.
|
|
9
|
+
* Tailwind CSS included—no setup required.
|
|
10
|
+
* Easy to import and use in any React project.
|
|
11
|
+
* Supports multiple types: success, error, info, warning.
|
|
12
|
+
* Fully responsive and modern UI.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install d9-toast
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
or
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
yarn add d9-toast
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
### 1. Wrap your app with `ToastProvider`
|
|
33
|
+
|
|
34
|
+
```jsx
|
|
35
|
+
import React from "react";
|
|
36
|
+
import { ToastProvider } from "d9-toast";
|
|
37
|
+
import App from "./App";
|
|
38
|
+
|
|
39
|
+
function Root() {
|
|
40
|
+
return (
|
|
41
|
+
<ToastProvider position="top-right">
|
|
42
|
+
<App />
|
|
43
|
+
</ToastProvider>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default Root;
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 2. Trigger a toast using `useToast`
|
|
51
|
+
|
|
52
|
+
```jsx
|
|
53
|
+
import React from "react";
|
|
54
|
+
import { useToast } from "d9-toast";
|
|
55
|
+
|
|
56
|
+
function App() {
|
|
57
|
+
const toast = useToast();
|
|
58
|
+
|
|
59
|
+
const showToast = () => {
|
|
60
|
+
toast({
|
|
61
|
+
message: "Hello World!",
|
|
62
|
+
type: "success", // success | error | info | warning | loading | submit
|
|
63
|
+
duration: 3000,
|
|
64
|
+
actions: [
|
|
65
|
+
{ text: "Undo", callback: () => console.log("Undo clicked") },
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return <button onClick={showToast}>Show Toast</button>;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export default App;
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 3. ToastProvider Props
|
|
77
|
+
|
|
78
|
+
| Prop | Type | Default | Description |
|
|
79
|
+
| ------------------ | ------- | ----------- | ------------------------------------------------------------------------------- |
|
|
80
|
+
| `position` | string | `top-right` | Position of all toasts (`top-left`, `top-right`, `bottom-left`, `bottom-right`) |
|
|
81
|
+
| `theme` | string | `light` | Default theme for all toasts (`light` or `dark`) |
|
|
82
|
+
| `pauseOnHover` | boolean | `true` | Pause toast timer on hover |
|
|
83
|
+
| `pauseOnFocusLoss` | boolean | `true` | Pause toast timer when window loses focus |
|
|
84
|
+
|
|
85
|
+
### 4. Toast Options
|
|
86
|
+
|
|
87
|
+
| Option | Type | Default | Description |
|
|
88
|
+
| ---------- | ------- | ------- | -------------------------------------------------------------------------- |
|
|
89
|
+
| `message` | string | - | The message to display |
|
|
90
|
+
| `type` | string | `info` | Type of toast (`success`, `error`, `info`, `warning`, `loading`, `submit`) |
|
|
91
|
+
| `duration` | number | 5000 | Auto-close duration in ms (0 for infinite) |
|
|
92
|
+
| `actions` | array | [] | Array of action objects `{ text: string, callback: function }` |
|
|
93
|
+
| `closable` | boolean | true | Show close button |
|
|
94
|
+
| `progress` | boolean | true | Show progress bar |
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Development
|
|
99
|
+
|
|
100
|
+
### Build
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
npm run build
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
* Generates CSS in `dist/toast.css` using TailwindCSS
|
|
107
|
+
* Generates JS in `dist/` using Babel
|
|
108
|
+
|
|
109
|
+
### Tailwind Support
|
|
110
|
+
|
|
111
|
+
Make sure your project has Tailwind installed. If not, include the `toast.css` from `dist/` in your project:
|
|
112
|
+
|
|
113
|
+
```jsx
|
|
114
|
+
import 'd9-toast/dist/toast.css';
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
MIT
|
package/dist/ToastContext.js
CHANGED
|
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.useToast = exports.ToastProvider = void 0;
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _Toast = _interopRequireDefault(require("./Toast.js"));
|
|
10
|
-
var _Icons = _interopRequireDefault(require("./Icons.js"));
|
|
11
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
11
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
13
12
|
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
package/package.json
CHANGED
package/src/index.js
DELETED