d9-toast 1.0.11 → 1.0.13
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 +18 -13
- package/dist/Toast.js +81 -65
- package/dist/ToastContext.js +11 -24
- package/dist/d9-toast.d.ts +32 -4
- package/dist/index.js +2 -4
- package/dist/toast.css +184 -6
- package/package.json +8 -12
package/README.md
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
# D9-Toast
|
|
2
2
|
|
|
3
|
-
Customizable toast notifications for React
|
|
3
|
+
Customizable toast notifications for React.
|
|
4
|
+
|
|
4
5
|
|
|
5
6
|
**Features:**
|
|
6
7
|
|
|
7
|
-
* Lightweight and fully customizable toast notifications.
|
|
8
|
-
* Built with React.
|
|
9
|
-
*
|
|
10
|
-
* Easy to import and use in any React project.
|
|
11
|
-
* Supports multiple types: success, error, info, warning.
|
|
12
|
-
* Fully responsive and modern UI.
|
|
8
|
+
* Lightweight and fully customizable toast notifications.
|
|
9
|
+
* Built with React.
|
|
10
|
+
* Pure CSS included — no additional setup required.
|
|
11
|
+
* Easy to import and use in any React project.
|
|
12
|
+
* Supports multiple types: success, error, info, warning, loading, submit.
|
|
13
|
+
* Fully responsive and modern UI.
|
|
14
|
+
* Users can optionally add Tailwind CSS classes via `className` for custom styling.
|
|
13
15
|
|
|
14
16
|
---
|
|
15
17
|
|
|
@@ -64,6 +66,7 @@ function App() {
|
|
|
64
66
|
actions: [
|
|
65
67
|
{ text: "Undo", callback: () => console.log("Undo clicked") },
|
|
66
68
|
],
|
|
69
|
+
className: "bg-green-500 text-white shadow-lg", // optional Tailwind/custom styling
|
|
67
70
|
});
|
|
68
71
|
};
|
|
69
72
|
|
|
@@ -92,6 +95,7 @@ export default App;
|
|
|
92
95
|
| `actions` | array | [] | Array of action objects `{ text: string, callback: function }` |
|
|
93
96
|
| `closable` | boolean | true | Show close button |
|
|
94
97
|
| `progress` | boolean | true | Show progress bar |
|
|
98
|
+
| `className` | string| " " | Optional extra CSS/Tailwind classes to customize the toast bar |
|
|
95
99
|
|
|
96
100
|
---
|
|
97
101
|
|
|
@@ -103,17 +107,18 @@ export default App;
|
|
|
103
107
|
npm run build
|
|
104
108
|
```
|
|
105
109
|
|
|
106
|
-
*
|
|
107
|
-
*
|
|
110
|
+
* Copies JS to `dist/`
|
|
111
|
+
* Copies CSS `(toast.css)` to `dist/`
|
|
108
112
|
|
|
109
|
-
###
|
|
113
|
+
### Styling
|
|
110
114
|
|
|
111
|
-
|
|
115
|
+
* Default styling is included in dist/toast.css
|
|
116
|
+
* Users can optionally override or extend styles using className
|
|
112
117
|
|
|
113
118
|
```jsx
|
|
114
|
-
import
|
|
119
|
+
import "d9-toast/dist/toast.css";
|
|
115
120
|
```
|
|
116
|
-
|
|
121
|
+
* Tailwind CSS is optional — you can pass Tailwind classes via className.
|
|
117
122
|
---
|
|
118
123
|
|
|
119
124
|
## License
|
package/dist/Toast.js
CHANGED
|
@@ -5,8 +5,9 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
5
5
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
6
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
7
|
import React, { useEffect, useRef, useState } from "react";
|
|
8
|
+
import "./toast.css";
|
|
8
9
|
import Icons from "./Icons";
|
|
9
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
10
11
|
var Toast = function Toast(_ref) {
|
|
11
12
|
var id = _ref.id,
|
|
12
13
|
message = _ref.message,
|
|
@@ -14,6 +15,8 @@ var Toast = function Toast(_ref) {
|
|
|
14
15
|
type = _ref$type === void 0 ? "info" : _ref$type,
|
|
15
16
|
_ref$theme = _ref.theme,
|
|
16
17
|
theme = _ref$theme === void 0 ? "light" : _ref$theme,
|
|
18
|
+
_ref$className = _ref.className,
|
|
19
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
17
20
|
_ref$duration = _ref.duration,
|
|
18
21
|
duration = _ref$duration === void 0 ? 5000 : _ref$duration,
|
|
19
22
|
_ref$actions = _ref.actions,
|
|
@@ -28,19 +31,25 @@ var Toast = function Toast(_ref) {
|
|
|
28
31
|
pauseOnHover = _ref$pauseOnHover === void 0 ? true : _ref$pauseOnHover,
|
|
29
32
|
_ref$pauseOnFocusLoss = _ref.pauseOnFocusLoss,
|
|
30
33
|
pauseOnFocusLoss = _ref$pauseOnFocusLoss === void 0 ? true : _ref$pauseOnFocusLoss;
|
|
31
|
-
var intervalRef = useRef(null);
|
|
32
|
-
var start = useRef(Date.now());
|
|
33
|
-
var remaining = useRef(duration);
|
|
34
|
+
var intervalRef = useRef(null); // stores the interval ID
|
|
35
|
+
var start = useRef(Date.now()); // stores the moment timer started
|
|
36
|
+
var remaining = useRef(duration); // how much time is left
|
|
34
37
|
var _useState = useState(100),
|
|
35
38
|
_useState2 = _slicedToArray(_useState, 2),
|
|
36
39
|
progressWidth = _useState2[0],
|
|
37
|
-
setProgressWidth = _useState2[1];
|
|
40
|
+
setProgressWidth = _useState2[1]; // progress bar %
|
|
38
41
|
var _useState3 = useState(false),
|
|
39
42
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
40
43
|
isPaused = _useState4[0],
|
|
41
|
-
setPaused = _useState4[1];
|
|
44
|
+
setPaused = _useState4[1]; // For timer pause
|
|
45
|
+
|
|
46
|
+
// Start auto-close timer.
|
|
42
47
|
useEffect(function () {
|
|
43
|
-
if (duration !== 0)
|
|
48
|
+
if (duration !== 0) {
|
|
49
|
+
startTimer();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// pause/resume when window focus changes.
|
|
44
53
|
var handleBlur = function handleBlur() {
|
|
45
54
|
return pauseOnFocusLoss && pauseTimer();
|
|
46
55
|
};
|
|
@@ -59,86 +68,93 @@ var Toast = function Toast(_ref) {
|
|
|
59
68
|
}
|
|
60
69
|
};
|
|
61
70
|
}, [duration, pauseOnFocusLoss]);
|
|
71
|
+
|
|
72
|
+
// --- Helpers Fun ---
|
|
73
|
+
// for start
|
|
62
74
|
var startTimer = function startTimer() {
|
|
63
75
|
intervalRef.current = setInterval(function () {
|
|
76
|
+
// time to passed...
|
|
64
77
|
var elapsed = Date.now() - start.current;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
78
|
+
// time to left...
|
|
79
|
+
var timeToLeft = remaining.current - elapsed;
|
|
80
|
+
// set shrink bar...
|
|
81
|
+
setProgressWidth(timeToLeft / duration * 100);
|
|
82
|
+
if (timeToLeft <= 0) {
|
|
83
|
+
// stop timer...
|
|
68
84
|
clearInterval(intervalRef.current);
|
|
85
|
+
// remove toast.
|
|
69
86
|
remove();
|
|
70
87
|
}
|
|
71
|
-
},
|
|
88
|
+
}, 100);
|
|
72
89
|
};
|
|
90
|
+
|
|
91
|
+
// for pause
|
|
73
92
|
var pauseTimer = function pauseTimer() {
|
|
74
93
|
if (isPaused) return;
|
|
75
94
|
clearInterval(intervalRef.current);
|
|
76
95
|
remaining.current = remaining.current - (Date.now() - start.current);
|
|
77
96
|
setPaused(true);
|
|
78
97
|
};
|
|
98
|
+
|
|
99
|
+
// for resume
|
|
79
100
|
var resumeTimer = function resumeTimer() {
|
|
80
101
|
if (!isPaused) return;
|
|
81
102
|
start.current = Date.now();
|
|
82
103
|
setPaused(false);
|
|
83
104
|
startTimer();
|
|
84
105
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
106
|
+
|
|
107
|
+
// Styles
|
|
108
|
+
var animation = "".concat(position.startsWith("top") && "upToDown" || position.startsWith("bottom") && "downToUp" || position.endsWith("top") && "upToDown" || position.endsWith("bottom") && "downToUp", " 0.3s ease-in");
|
|
109
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
110
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
111
|
+
style: {
|
|
112
|
+
animation: animation
|
|
113
|
+
},
|
|
114
|
+
className: "toast ".concat(theme, " ").concat(className),
|
|
115
|
+
onMouseEnter: pauseOnHover ? pauseTimer : undefined,
|
|
116
|
+
onMouseLeave: pauseOnHover ? resumeTimer : undefined,
|
|
117
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
118
|
+
className: "toastHeader ".concat(type),
|
|
119
|
+
children: [/*#__PURE__*/_jsxs("span", {
|
|
120
|
+
children: [/*#__PURE__*/_jsx(Icons, {
|
|
121
|
+
name: type
|
|
122
|
+
}), " ", type.toUpperCase()]
|
|
123
|
+
}), closable && /*#__PURE__*/_jsx("button", {
|
|
124
|
+
onClick: remove,
|
|
125
|
+
children: /*#__PURE__*/_jsx(Icons, {
|
|
126
|
+
name: "X"
|
|
127
|
+
})
|
|
128
|
+
})]
|
|
129
|
+
}), /*#__PURE__*/_jsx("p", {
|
|
130
|
+
style: {
|
|
131
|
+
padding: "4px"
|
|
132
|
+
},
|
|
133
|
+
children: message
|
|
134
|
+
}), actions.length > 0 && /*#__PURE__*/_jsx("div", {
|
|
135
|
+
className: "toastActions",
|
|
136
|
+
children: actions.map(function (a, idx) {
|
|
137
|
+
return /*#__PURE__*/_jsx("button", {
|
|
138
|
+
onClick: function onClick() {
|
|
139
|
+
var _a$callback;
|
|
140
|
+
return (_a$callback = a.callback) === null || _a$callback === void 0 ? void 0 : _a$callback.call(a, {
|
|
141
|
+
id: id
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
style: {
|
|
145
|
+
borderColor: "".concat(theme === "dark" ? "#f9fafb33" : "#161d2333")
|
|
146
|
+
},
|
|
147
|
+
children: a.text
|
|
148
|
+
}, idx);
|
|
112
149
|
})
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
className: "toast-message",
|
|
116
|
-
children: message
|
|
117
|
-
}), actions.length > 0 && /*#__PURE__*/_jsx("div", {
|
|
118
|
-
className: "flex justify-end gap-2 mt-1",
|
|
119
|
-
children: actions.map(function (a, i) {
|
|
120
|
-
return /*#__PURE__*/_jsx("button", {
|
|
121
|
-
onClick: function onClick() {
|
|
122
|
-
var _a$callback;
|
|
123
|
-
return (_a$callback = a.callback) === null || _a$callback === void 0 ? void 0 : _a$callback.call(a, {
|
|
124
|
-
id: id
|
|
125
|
-
});
|
|
126
|
-
},
|
|
127
|
-
className: "px-3 py-1 rounded ".concat(colors[type], " cursor-pointer"),
|
|
128
|
-
children: a.text
|
|
129
|
-
}, i);
|
|
130
|
-
})
|
|
131
|
-
}), progress && duration !== 0 && /*#__PURE__*/_jsx("div", {
|
|
132
|
-
className: "h-1 w-full bg-gray-300 rounded absolute bottom-0 left-0 overflow-hidden",
|
|
133
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
134
|
-
className: "h-1 ".concat(colors[type], " transition-all"),
|
|
150
|
+
}), progress && duration !== 0 && /*#__PURE__*/_jsx("div", {
|
|
151
|
+
className: "toast-progress ",
|
|
135
152
|
style: {
|
|
136
|
-
width: "".concat(progressWidth, "%")
|
|
153
|
+
width: "".concat(progressWidth, "%"),
|
|
154
|
+
backgroundColor: "".concat(theme === "dark" ? "#536175" : "#161d2333")
|
|
137
155
|
}
|
|
138
|
-
})
|
|
139
|
-
})
|
|
140
|
-
children: "\n @keyframes slideDown { from { transform: translateY(-100%); opacity: 0; } to { transform: translateY(0); opacity:1; } }\n @keyframes slideUp { from { transform: translateY(100%); opacity:0; } to { transform: translateY(0); opacity:1; } }\n @keyframes fadeIn { from { opacity: 0; } to { opacity:1; } }\n "
|
|
141
|
-
})]
|
|
156
|
+
})]
|
|
157
|
+
})
|
|
142
158
|
});
|
|
143
159
|
};
|
|
144
160
|
export default Toast;
|
package/dist/ToastContext.js
CHANGED
|
@@ -16,13 +16,12 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
16
16
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
17
17
|
import React, { createContext, useCallback, useContext, useState } from "react";
|
|
18
18
|
import Toast from "./Toast";
|
|
19
|
+
import "./toast.css";
|
|
19
20
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
21
|
var ToastContext = /*#__PURE__*/createContext();
|
|
21
22
|
export var useToast = function useToast() {
|
|
22
23
|
return useContext(ToastContext);
|
|
23
24
|
};
|
|
24
|
-
var id = 0; // unique toast id
|
|
25
|
-
|
|
26
25
|
export var ToastProvider = function ToastProvider(_ref) {
|
|
27
26
|
var children = _ref.children,
|
|
28
27
|
_ref$position = _ref.position,
|
|
@@ -31,30 +30,16 @@ export var ToastProvider = function ToastProvider(_ref) {
|
|
|
31
30
|
_useState2 = _slicedToArray(_useState, 2),
|
|
32
31
|
toasts = _useState2[0],
|
|
33
32
|
setToasts = _useState2[1];
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
case "top-left":
|
|
39
|
-
return "top-4 left-4 flex-col";
|
|
40
|
-
case "bottom-right":
|
|
41
|
-
return "bottom-4 right-4 flex-col-reverse";
|
|
42
|
-
case "bottom-left":
|
|
43
|
-
return "bottom-4 left-4 flex-col-reverse";
|
|
44
|
-
case "center":
|
|
45
|
-
return "top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 flex-col";
|
|
46
|
-
case "center-top":
|
|
47
|
-
return "top-4 left-1/2 -translate-x-1/2 flex-col";
|
|
48
|
-
case "center-bottom":
|
|
49
|
-
return "bottom-4 left-1/2 -translate-x-1/2 flex-col-reverse";
|
|
50
|
-
default:
|
|
51
|
-
return "top-4 right-4 flex-col";
|
|
52
|
-
}
|
|
33
|
+
|
|
34
|
+
// Generate unique ID safely
|
|
35
|
+
var generateId = function generateId() {
|
|
36
|
+
return Date.now() + Math.random();
|
|
53
37
|
};
|
|
38
|
+
|
|
39
|
+
// Show toast
|
|
54
40
|
var showToast = useCallback(function (toast) {
|
|
55
|
-
id++;
|
|
56
41
|
var newToast = _objectSpread({
|
|
57
|
-
id:
|
|
42
|
+
id: generateId()
|
|
58
43
|
}, toast);
|
|
59
44
|
setToasts(function (prev) {
|
|
60
45
|
return [].concat(_toConsumableArray(prev), [newToast]);
|
|
@@ -65,6 +50,8 @@ export var ToastProvider = function ToastProvider(_ref) {
|
|
|
65
50
|
}, toast.duration || 5000);
|
|
66
51
|
}
|
|
67
52
|
}, []);
|
|
53
|
+
|
|
54
|
+
// Remove toast
|
|
68
55
|
var removeToast = useCallback(function (id) {
|
|
69
56
|
setToasts(function (prev) {
|
|
70
57
|
return prev.filter(function (t) {
|
|
@@ -78,7 +65,7 @@ export var ToastProvider = function ToastProvider(_ref) {
|
|
|
78
65
|
removeToast: removeToast
|
|
79
66
|
},
|
|
80
67
|
children: [children, /*#__PURE__*/_jsx("div", {
|
|
81
|
-
className: "
|
|
68
|
+
className: "toastContainer ".concat(position),
|
|
82
69
|
children: toasts.map(function (toast) {
|
|
83
70
|
return /*#__PURE__*/_jsx(Toast, _objectSpread(_objectSpread({}, toast), {}, {
|
|
84
71
|
position: position,
|
package/dist/d9-toast.d.ts
CHANGED
|
@@ -1,20 +1,48 @@
|
|
|
1
1
|
declare module "d9-toast" {
|
|
2
2
|
import React from "react";
|
|
3
3
|
|
|
4
|
-
export type ToastType =
|
|
4
|
+
export type ToastType =
|
|
5
|
+
| "success"
|
|
6
|
+
| "error"
|
|
7
|
+
| "info"
|
|
8
|
+
| "warning"
|
|
9
|
+
| "loading"
|
|
10
|
+
| "submit";
|
|
11
|
+
|
|
12
|
+
export interface ToastAction {
|
|
13
|
+
text: string;
|
|
14
|
+
callback?: (toast: { id: number }) => void;
|
|
15
|
+
}
|
|
5
16
|
|
|
6
17
|
export interface ToastOptions {
|
|
7
18
|
message: string;
|
|
8
19
|
type?: ToastType;
|
|
9
20
|
duration?: number;
|
|
10
|
-
actions?:
|
|
21
|
+
actions?: ToastAction[];
|
|
11
22
|
theme?: "light" | "dark";
|
|
12
23
|
progress?: boolean;
|
|
13
24
|
closable?: boolean;
|
|
14
25
|
pauseOnHover?: boolean;
|
|
15
26
|
pauseOnFocusLoss?: boolean;
|
|
27
|
+
className?: string;
|
|
16
28
|
}
|
|
17
29
|
|
|
18
|
-
export
|
|
19
|
-
|
|
30
|
+
export interface ToastProviderProps {
|
|
31
|
+
children: React.ReactNode;
|
|
32
|
+
position?:
|
|
33
|
+
| "top-right"
|
|
34
|
+
| "top-left"
|
|
35
|
+
| "bottom-right"
|
|
36
|
+
| "bottom-left"
|
|
37
|
+
| "center"
|
|
38
|
+
| "center-top"
|
|
39
|
+
| "center-bottom";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const ToastProvider: React.FC<ToastProviderProps>;
|
|
43
|
+
|
|
44
|
+
export const useToast: () => {
|
|
45
|
+
showToast: (toast: ToastOptions) => void;
|
|
46
|
+
removeToast: (id: number) => void;
|
|
47
|
+
};
|
|
20
48
|
}
|
package/dist/index.js
CHANGED
package/dist/toast.css
CHANGED
|
@@ -1,9 +1,187 @@
|
|
|
1
|
-
.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
.toastContainer {
|
|
2
|
+
position: fixed;
|
|
3
|
+
z-index: 999;
|
|
4
|
+
display: flex;
|
|
5
|
+
gap: 12px;
|
|
6
|
+
}
|
|
7
|
+
.toastContainer.top-right {
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
top: 16px;
|
|
10
|
+
right: 16px;
|
|
11
|
+
}
|
|
12
|
+
.toastContainer.top-left {
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
top: 16px;
|
|
15
|
+
left: 16px;
|
|
16
|
+
}
|
|
17
|
+
.toastContainer.bottom-right {
|
|
18
|
+
flex-direction: column-reverse;
|
|
19
|
+
bottom: 16px;
|
|
20
|
+
right: 16px;
|
|
21
|
+
}
|
|
22
|
+
.toastContainer.bottom-left {
|
|
23
|
+
flex-direction: column-reverse;
|
|
24
|
+
bottom: 16px;
|
|
25
|
+
left: 16px;
|
|
26
|
+
}
|
|
27
|
+
.toastContainer.center {
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
top: 50%;
|
|
30
|
+
left: 50%;
|
|
31
|
+
transform: translate(-50%, -50%);
|
|
32
|
+
}
|
|
33
|
+
.toastContainer.center-top {
|
|
34
|
+
top: 16px;
|
|
35
|
+
left: 50%;
|
|
36
|
+
transform: translateX(-50%);
|
|
37
|
+
}
|
|
38
|
+
.toastContainer.center-bottom {
|
|
39
|
+
bottom: 16px;
|
|
40
|
+
left: 50%;
|
|
41
|
+
transform: translateX(-50%);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.toast {
|
|
45
|
+
position: relative;
|
|
46
|
+
width: 320px;
|
|
47
|
+
display: flex;
|
|
48
|
+
flex-direction: column;
|
|
49
|
+
gap: 8px;
|
|
50
|
+
padding: 6px;
|
|
51
|
+
border-radius: 8px;
|
|
52
|
+
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
|
53
|
+
font-family: system-ui, sans-serif;
|
|
54
|
+
transition: all 0.3s ease-in-out;
|
|
55
|
+
}
|
|
56
|
+
.toast.light {
|
|
57
|
+
background-color: #f9fafb;
|
|
58
|
+
color: #030712;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.toast.dark {
|
|
62
|
+
background-color: #030712;
|
|
63
|
+
color: #f9fafb;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.toastHeader {
|
|
67
|
+
display: flex;
|
|
68
|
+
justify-content: space-between;
|
|
69
|
+
align-items: center;
|
|
70
|
+
padding: 2px 4px;
|
|
71
|
+
border-radius: 6px;
|
|
72
|
+
box-shadow: inset 0 1px rgb(0 0 0 / 0.05);
|
|
73
|
+
}
|
|
74
|
+
.toastHeader span {
|
|
75
|
+
display: flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
gap: 8px;
|
|
78
|
+
font-size: 1rem;
|
|
79
|
+
font-weight: 500;
|
|
80
|
+
}
|
|
81
|
+
.toastHeader button:hover {
|
|
82
|
+
cursor: pointer;
|
|
83
|
+
color: oklch(57.7% 0.245 27.325);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.toastHeader.success {
|
|
87
|
+
color: oklch(62.7% 0.194 149.214);
|
|
88
|
+
background-color: oklch(63.187% 0.18673 147.227 / 0.2);
|
|
89
|
+
}
|
|
90
|
+
.toastHeader.error {
|
|
91
|
+
color: oklch(57.7% 0.245 27.325);
|
|
92
|
+
background-color: oklch(58.305% 0.23863 28.392 / 0.2);
|
|
93
|
+
}
|
|
94
|
+
.toastHeader.info {
|
|
95
|
+
color: oklch(54.6% 0.245 262.881);
|
|
96
|
+
background-color: oklch(54.6% 0.245 262.881 / 0.1);
|
|
97
|
+
}
|
|
98
|
+
.toastHeader.warning {
|
|
99
|
+
color: oklch(68.1% 0.162 75.834);
|
|
100
|
+
background-color: oklch(68.1% 0.162 75.834 / 0.1);
|
|
101
|
+
}
|
|
102
|
+
.toastHeader.loading,
|
|
103
|
+
.toastHeader.submit {
|
|
104
|
+
color: oklch(48.847% 0.03665 257.306);
|
|
105
|
+
background-color: oklch(44.6% 0.03 256.802 / 0.2);
|
|
106
|
+
}
|
|
107
|
+
.toastActions {
|
|
108
|
+
display: flex;
|
|
109
|
+
justify-content: flex-end;
|
|
110
|
+
gap: 15px;
|
|
111
|
+
margin-right: 5px;
|
|
112
|
+
margin-bottom: 8px;
|
|
113
|
+
}
|
|
114
|
+
.toastActions button {
|
|
115
|
+
padding: 4px 12px;
|
|
116
|
+
font-size: 14px;
|
|
117
|
+
border-radius: 6px;
|
|
118
|
+
border: 1px solid;
|
|
119
|
+
cursor: pointer;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.toast-progress {
|
|
123
|
+
position: absolute;
|
|
124
|
+
bottom: 0;
|
|
125
|
+
left: 0;
|
|
126
|
+
height: 0.25rem;
|
|
127
|
+
transition: width 0.1s linear;
|
|
128
|
+
border-radius: 0 0 0.25rem 0.25rem;
|
|
129
|
+
overflow: hidden;
|
|
130
|
+
}
|
|
131
|
+
.toast-progress::before {
|
|
132
|
+
content: "";
|
|
133
|
+
width: 100%;
|
|
134
|
+
height: 0.25rem;
|
|
135
|
+
background-color: currentColor;
|
|
136
|
+
opacity: 0.5;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.toast-progress.success {
|
|
140
|
+
background-color: oklch(62.7% 0.194 149.214);
|
|
141
|
+
}
|
|
142
|
+
.toast-progress.error {
|
|
143
|
+
background-color: oklch(57.7% 0.245 27.325);
|
|
144
|
+
}
|
|
145
|
+
.toast-progress.info {
|
|
146
|
+
background-color: oklch(54.6% 0.245 262.881);
|
|
147
|
+
}
|
|
148
|
+
.toast-progress.warning {
|
|
149
|
+
background-color: oklch(68.1% 0.162 75.834);
|
|
150
|
+
}
|
|
151
|
+
.toast-progress.loading,
|
|
152
|
+
.toast-progress.submit {
|
|
153
|
+
background-color: oklch(48.847% 0.03665 257.306);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
@keyframes downToUp {
|
|
157
|
+
from {
|
|
158
|
+
transform: translateY(100%);
|
|
159
|
+
opacity: 0;
|
|
160
|
+
}
|
|
161
|
+
to {
|
|
162
|
+
transform: translateY(0);
|
|
163
|
+
opacity: 1;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
@keyframes upToDown {
|
|
168
|
+
from {
|
|
169
|
+
transform: translateY(-100%);
|
|
170
|
+
opacity: 0;
|
|
171
|
+
}
|
|
172
|
+
to {
|
|
173
|
+
transform: translateY(0);
|
|
174
|
+
opacity: 1;
|
|
175
|
+
}
|
|
5
176
|
}
|
|
6
177
|
|
|
7
|
-
|
|
8
|
-
|
|
178
|
+
@media screen and (max-width: 325px) {
|
|
179
|
+
.toastContainer.top-right,
|
|
180
|
+
.toastContainer.bottom-right {
|
|
181
|
+
right: 0px;
|
|
182
|
+
}
|
|
183
|
+
.toastContainer.top-left,
|
|
184
|
+
.toastContainer.bottom-left {
|
|
185
|
+
left: 0px;
|
|
186
|
+
}
|
|
9
187
|
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "d9-toast",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "Customizable toast notifications for React",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
|
+
"sideEffects": [
|
|
11
|
+
"./dist/toast.css"
|
|
12
|
+
],
|
|
13
|
+
"types": "dist/d9-toast.d.ts",
|
|
10
14
|
"scripts": {
|
|
11
|
-
"build:css": "tailwindcss -i ./src/toast.css -o ./dist/toast.css --minify",
|
|
12
15
|
"build:js": "npx babel src --out-dir dist --copy-files",
|
|
13
|
-
"build": "npm run build:
|
|
16
|
+
"build": "npm run build:js"
|
|
14
17
|
},
|
|
15
18
|
"peerDependencies": {
|
|
16
19
|
"react": ">=17",
|
|
@@ -20,8 +23,7 @@
|
|
|
20
23
|
"react",
|
|
21
24
|
"toast",
|
|
22
25
|
"notifications",
|
|
23
|
-
"ui"
|
|
24
|
-
"tailwind"
|
|
26
|
+
"ui"
|
|
25
27
|
],
|
|
26
28
|
"license": "MIT",
|
|
27
29
|
"author": "Athul PS",
|
|
@@ -29,12 +31,6 @@
|
|
|
29
31
|
"@babel/cli": "^7.28.3",
|
|
30
32
|
"@babel/core": "^7.28.4",
|
|
31
33
|
"@babel/preset-env": "^7.28.3",
|
|
32
|
-
"@babel/preset-react": "^7.27.1"
|
|
33
|
-
"autoprefixer": "^10.4.21",
|
|
34
|
-
"postcss": "^8.5.6",
|
|
35
|
-
"tailwindcss": "^4.1.14"
|
|
36
|
-
},
|
|
37
|
-
"dependencies": {
|
|
38
|
-
"@tailwindcss/cli": "^4.1.14"
|
|
34
|
+
"@babel/preset-react": "^7.27.1"
|
|
39
35
|
}
|
|
40
36
|
}
|