@arkyn/components 1.3.125 → 1.3.127

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,2CAWtD;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"ToastProvider.d.ts","sourceRoot":"","sources":["../../src/provider/ToastProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAK9D,iBAAS,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,kBAAkB,2CAsEtD;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -1,11 +1,69 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
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(data) {
7
- toast.custom((ars) => _jsx(Toast, { ...data }));
5
+ function showToast({ message, type, size }) {
6
+ switch (type) {
7
+ case "success":
8
+ toast.success(message, {
9
+ style: {
10
+ padding: "8px 16px",
11
+ border: "1px solid rgba(var(--toast-success), 1)",
12
+ background: "rgba(var(--toast-success), 0.2)",
13
+ color: "var(--text-heading)",
14
+ },
15
+ iconTheme: {
16
+ primary: "rgba(var(--toast-success), 1)",
17
+ secondary: "#fff",
18
+ },
19
+ });
20
+ break;
21
+ case "danger":
22
+ toast.error(message, {
23
+ style: {
24
+ padding: "8px 16px",
25
+ border: "1px solid rgba(var(--toast-danger), 1)",
26
+ background: "rgba(var(--toast-danger), 0.2)",
27
+ color: "var(--text-heading)",
28
+ },
29
+ iconTheme: {
30
+ primary: "rgba(var(--toast-danger), 1)",
31
+ secondary: "#fff",
32
+ },
33
+ });
34
+ break;
35
+ case "info":
36
+ toast(message, {
37
+ icon: "ℹ️",
38
+ style: {
39
+ padding: "8px 16px",
40
+ border: "1px solid rgba(var(--toast-info), 1)",
41
+ background: "rgba(var(--toast-info), 0.2)",
42
+ color: "var(--text-heading)",
43
+ },
44
+ iconTheme: {
45
+ primary: "rgba(var(--toast-info), 1)",
46
+ secondary: "#fff",
47
+ },
48
+ });
49
+ break;
50
+ case "warning":
51
+ toast(message, {
52
+ icon: "⚠️",
53
+ style: {
54
+ padding: "8px 16px",
55
+ border: "1px solid rgba(var(--toast-warning), 1)",
56
+ background: "rgba(var(--toast-warning), 0.2)",
57
+ color: "var(--text-heading)",
58
+ },
59
+ iconTheme: {
60
+ primary: "rgba(var(--toast-warning), 1)",
61
+ secondary: "#fff",
62
+ },
63
+ });
64
+ break;
65
+ }
8
66
  }
9
- return (_jsxs(ToastContext.Provider, { value: { showToast }, children: [_jsx(Toaster, {}), children] }));
67
+ return (_jsxs(ToastContext.Provider, { value: { showToast }, children: [_jsx(Toaster, { position: "bottom-right" }), children] }));
10
68
  }
11
69
  export { ToastProvider };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/components",
3
- "version": "1.3.125",
3
+ "version": "1.3.127",
4
4
  "main": "./dist/bundle.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Lucas Gonçalves",
@@ -2,16 +2,74 @@ import { ToastProps, ToastProviderProps } from "@arkyn/types";
2
2
  import toast, { Toaster } from "react-hot-toast";
3
3
 
4
4
  import { ToastContext } from "../context/ToastContext";
5
- import { Toast } from "../components/Toast";
6
5
 
7
6
  function ToastProvider({ children }: ToastProviderProps) {
8
- function showToast(data: ToastProps) {
9
- toast.custom((ars) => <Toast {...data} />);
7
+ function showToast({ message, type, size }: ToastProps) {
8
+ switch (type) {
9
+ case "success":
10
+ toast.success(message, {
11
+ style: {
12
+ padding: "8px 16px",
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
+ style: {
26
+ padding: "8px 16px",
27
+ border: "1px solid rgba(var(--toast-danger), 1)",
28
+ background: "rgba(var(--toast-danger), 0.2)",
29
+ color: "var(--text-heading)",
30
+ },
31
+ iconTheme: {
32
+ primary: "rgba(var(--toast-danger), 1)",
33
+ secondary: "#fff",
34
+ },
35
+ });
36
+ break;
37
+ case "info":
38
+ toast(message, {
39
+ icon: "ℹ️",
40
+ style: {
41
+ padding: "8px 16px",
42
+ border: "1px solid rgba(var(--toast-info), 1)",
43
+ background: "rgba(var(--toast-info), 0.2)",
44
+ color: "var(--text-heading)",
45
+ },
46
+ iconTheme: {
47
+ primary: "rgba(var(--toast-info), 1)",
48
+ secondary: "#fff",
49
+ },
50
+ });
51
+ break;
52
+ case "warning":
53
+ toast(message, {
54
+ icon: "⚠️",
55
+ style: {
56
+ padding: "8px 16px",
57
+ border: "1px solid rgba(var(--toast-warning), 1)",
58
+ background: "rgba(var(--toast-warning), 0.2)",
59
+ color: "var(--text-heading)",
60
+ },
61
+ iconTheme: {
62
+ primary: "rgba(var(--toast-warning), 1)",
63
+ secondary: "#fff",
64
+ },
65
+ });
66
+ break;
67
+ }
10
68
  }
11
69
 
12
70
  return (
13
71
  <ToastContext.Provider value={{ showToast }}>
14
- <Toaster />
72
+ <Toaster position="bottom-right" />
15
73
  {children}
16
74
  </ToastContext.Provider>
17
75
  );