onairos 0.1.268 → 0.1.271
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/dist/components/Notification.js +32 -0
- package/dist/onairos.bundle.js +1 -1
- package/dist/onairos.bundle.js.map +1 -1
- package/dist/onairos.js +53 -38
- package/dist/overlay/overlay.js +0 -75
- package/package.json +1 -1
- package/src/components/Notification.jsx +21 -0
- package/src/onairos.jsx +52 -41
- package/src/overlay/overlay.js +0 -88
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = Notification;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
+
function Notification(_ref) {
|
|
12
|
+
let {
|
|
13
|
+
message,
|
|
14
|
+
color = null,
|
|
15
|
+
again = false
|
|
16
|
+
} = _ref;
|
|
17
|
+
const [show, setShow] = (0, _react.useState)(true);
|
|
18
|
+
(0, _react.useEffect)(() => {
|
|
19
|
+
setShow(true); // Show notification again when `again` changes
|
|
20
|
+
const timer = setTimeout(() => {
|
|
21
|
+
setShow(false);
|
|
22
|
+
}, 5000);
|
|
23
|
+
|
|
24
|
+
// Clear timeout if the component unmounts or `again` changes
|
|
25
|
+
return () => clearTimeout(timer);
|
|
26
|
+
}, [again]); // Dependency array includes `again` so it resets when the prop changes
|
|
27
|
+
|
|
28
|
+
return show && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
29
|
+
className: `fixed top-0 left-1/2 transform -translate-x-1/2 text-white px-4 py-2 rounded-b-md shadow-lg z-50 text-center ${color == null ? 'bg-red-600' : `bg-${color}-600`}`,
|
|
30
|
+
children: message
|
|
31
|
+
});
|
|
32
|
+
}
|