@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.
@@ -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;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, toast } from "react-hot-toast";
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, 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,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/components",
3
- "version": "1.3.124",
3
+ "version": "1.3.126",
4
4
  "main": "./dist/bundle.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Lucas Gonçalves",
@@ -1,17 +1,40 @@
1
1
  import { ToastProps, ToastProviderProps } from "@arkyn/types";
2
- import { Toaster, toast } from "react-hot-toast";
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(data: ToastProps) {
9
- toast.custom((ars) => <Toast {...data} />);
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
  );