@arkyn/components 1.3.124 → 1.3.126
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/bundle.js +1888 -1865
- package/dist/bundle.umd.cjs +51 -51
- package/dist/provider/ToastProvider.d.ts.map +1 -1
- package/dist/provider/ToastProvider.js +27 -5
- package/package.json +1 -1
- package/src/provider/ToastProvider.tsx +27 -4
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ToastProvider.d.ts","sourceRoot":"","sources":["../../src/provider/ToastProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAM9D,iBAAS,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,kBAAkB,
|
1
|
+
{"version":3,"file":"ToastProvider.d.ts","sourceRoot":"","sources":["../../src/provider/ToastProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAM9D,iBAAS,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,kBAAkB,2CAkCtD;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
@@ -1,11 +1,33 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
-
import { Toaster
|
2
|
+
import toast, { Toaster } from "react-hot-toast";
|
3
3
|
import { ToastContext } from "../context/ToastContext";
|
4
|
-
import { Toast } from "../components/Toast";
|
5
4
|
function ToastProvider({ children }) {
|
6
|
-
function showToast(
|
7
|
-
|
5
|
+
function showToast({ message, title, type, size }) {
|
6
|
+
switch (type) {
|
7
|
+
case "success":
|
8
|
+
toast.success(message, {
|
9
|
+
style: {
|
10
|
+
border: "1px solid rgba(var(--toast-success), 1)",
|
11
|
+
background: "rgba(var(--toast-success), 0.2)",
|
12
|
+
color: "var(--text-heading)",
|
13
|
+
},
|
14
|
+
iconTheme: {
|
15
|
+
primary: "rgba(var(--toast-success), 1)",
|
16
|
+
secondary: "#fff",
|
17
|
+
},
|
18
|
+
});
|
19
|
+
break;
|
20
|
+
case "danger":
|
21
|
+
toast.error(message);
|
22
|
+
break;
|
23
|
+
case "info":
|
24
|
+
toast(message);
|
25
|
+
break;
|
26
|
+
case "warning":
|
27
|
+
toast(message);
|
28
|
+
break;
|
29
|
+
}
|
8
30
|
}
|
9
|
-
return (_jsxs(ToastContext.Provider, { value: { showToast }, children: [_jsx(Toaster, {}), children] }));
|
31
|
+
return (_jsxs(ToastContext.Provider, { value: { showToast }, children: [_jsx(Toaster, { position: "bottom-right" }), children] }));
|
10
32
|
}
|
11
33
|
export { ToastProvider };
|
package/package.json
CHANGED
@@ -1,17 +1,40 @@
|
|
1
1
|
import { ToastProps, ToastProviderProps } from "@arkyn/types";
|
2
|
-
import { Toaster
|
2
|
+
import toast, { Toaster } from "react-hot-toast";
|
3
3
|
|
4
4
|
import { ToastContext } from "../context/ToastContext";
|
5
5
|
import { Toast } from "../components/Toast";
|
6
6
|
|
7
7
|
function ToastProvider({ children }: ToastProviderProps) {
|
8
|
-
function showToast(
|
9
|
-
|
8
|
+
function showToast({ message, title, type, size }: ToastProps) {
|
9
|
+
switch (type) {
|
10
|
+
case "success":
|
11
|
+
toast.success(message, {
|
12
|
+
style: {
|
13
|
+
border: "1px solid rgba(var(--toast-success), 1)",
|
14
|
+
background: "rgba(var(--toast-success), 0.2)",
|
15
|
+
color: "var(--text-heading)",
|
16
|
+
},
|
17
|
+
iconTheme: {
|
18
|
+
primary: "rgba(var(--toast-success), 1)",
|
19
|
+
secondary: "#fff",
|
20
|
+
},
|
21
|
+
});
|
22
|
+
break;
|
23
|
+
case "danger":
|
24
|
+
toast.error(message);
|
25
|
+
break;
|
26
|
+
case "info":
|
27
|
+
toast(message);
|
28
|
+
break;
|
29
|
+
case "warning":
|
30
|
+
toast(message);
|
31
|
+
break;
|
32
|
+
}
|
10
33
|
}
|
11
34
|
|
12
35
|
return (
|
13
36
|
<ToastContext.Provider value={{ showToast }}>
|
14
|
-
<Toaster />
|
37
|
+
<Toaster position="bottom-right" />
|
15
38
|
{children}
|
16
39
|
</ToastContext.Provider>
|
17
40
|
);
|