gbs-add-block 0.0.43 → 0.0.44
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
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# GBS Building Blocks 2.0 (v0.0.
|
|
1
|
+
# GBS Building Blocks 2.0 (v0.0.44)
|
|
2
2
|
|
|
3
3
|
Latest and upgraded version of GBS building blocks with headless UI and removed dependencies.
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ Latest and upgraded version of GBS building blocks with headless UI and removed
|
|
|
6
6
|
|
|
7
7
|
For detailed documentation on usage and props, Please visit: [Building Block Documentation v2.0](https://blackmax-designs.gitbook.io/building-block-v2.0)
|
|
8
8
|
|
|
9
|
-
## What's New 🎉 (Ver 0.0.
|
|
9
|
+
## What's New 🎉 (Ver 0.0.44)
|
|
10
10
|
|
|
11
11
|
- Refactored Code for Better Readability and removed dependency for Toast
|
|
12
12
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useEffect } from "react";
|
|
2
2
|
import { Toast } from "./types";
|
|
3
3
|
import { useToastStore } from "./toastStore";
|
|
4
|
+
import ToastIcon from "./ToastIcon";
|
|
4
5
|
|
|
5
6
|
interface ToastProps {
|
|
6
7
|
toast: Toast;
|
|
@@ -13,11 +14,11 @@ const bgColors = {
|
|
|
13
14
|
warning: "bg-yellow-50 hover:bg-yellow-100",
|
|
14
15
|
} as const;
|
|
15
16
|
|
|
16
|
-
const
|
|
17
|
-
default: "
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
warning: "
|
|
17
|
+
const toastAnimation = {
|
|
18
|
+
default: "",
|
|
19
|
+
error: "animate-shake animate-once animate-duration-200",
|
|
20
|
+
success: "animate-jump-in animate-once animate-duration-200",
|
|
21
|
+
warning: "animate-jump-in animate-once animate-duration-200",
|
|
21
22
|
} as const;
|
|
22
23
|
|
|
23
24
|
const CloseButton = ({ onDismiss }: { onDismiss: () => void }) => (
|
|
@@ -41,57 +42,6 @@ const CloseButton = ({ onDismiss }: { onDismiss: () => void }) => (
|
|
|
41
42
|
</button>
|
|
42
43
|
);
|
|
43
44
|
|
|
44
|
-
const ToastIcon = ({ type }: { type: Toast["type"] }) => {
|
|
45
|
-
if (!type) return null;
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<div className={`h-5 w-5 ${iconColors[type]}`}>
|
|
49
|
-
{type === "success" && (
|
|
50
|
-
<svg
|
|
51
|
-
viewBox="0 0 24 24"
|
|
52
|
-
fill="none"
|
|
53
|
-
stroke="currentColor"
|
|
54
|
-
strokeWidth="2"
|
|
55
|
-
>
|
|
56
|
-
<path
|
|
57
|
-
strokeLinecap="round"
|
|
58
|
-
strokeLinejoin="round"
|
|
59
|
-
d="M5 13l4 4L19 7"
|
|
60
|
-
/>
|
|
61
|
-
</svg>
|
|
62
|
-
)}
|
|
63
|
-
{type === "error" && (
|
|
64
|
-
<svg
|
|
65
|
-
viewBox="0 0 24 24"
|
|
66
|
-
fill="none"
|
|
67
|
-
stroke="currentColor"
|
|
68
|
-
strokeWidth="2"
|
|
69
|
-
>
|
|
70
|
-
<path
|
|
71
|
-
strokeLinecap="round"
|
|
72
|
-
strokeLinejoin="round"
|
|
73
|
-
d="M6 18L18 6M6 6l12 12"
|
|
74
|
-
/>
|
|
75
|
-
</svg>
|
|
76
|
-
)}
|
|
77
|
-
{type === "warning" && (
|
|
78
|
-
<svg
|
|
79
|
-
viewBox="0 0 24 24"
|
|
80
|
-
fill="none"
|
|
81
|
-
stroke="currentColor"
|
|
82
|
-
strokeWidth="2"
|
|
83
|
-
>
|
|
84
|
-
<path
|
|
85
|
-
strokeLinecap="round"
|
|
86
|
-
strokeLinejoin="round"
|
|
87
|
-
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
|
|
88
|
-
/>
|
|
89
|
-
</svg>
|
|
90
|
-
)}
|
|
91
|
-
</div>
|
|
92
|
-
);
|
|
93
|
-
};
|
|
94
|
-
|
|
95
45
|
export function ToastComponent({ toast }: ToastProps) {
|
|
96
46
|
const { dismiss } = useToastStore();
|
|
97
47
|
const handleDismiss = () => dismiss(toast.id);
|
|
@@ -121,9 +71,10 @@ export function ToastComponent({ toast }: ToastProps) {
|
|
|
121
71
|
<div
|
|
122
72
|
className={`
|
|
123
73
|
${bgColors[toast.type || "default"]}
|
|
74
|
+
${toastAnimation[toast.type || "default"]}
|
|
124
75
|
transform transition-all duration-300 ease-in-out
|
|
125
76
|
pointer-events-auto relative flex w-full items-center justify-between
|
|
126
|
-
overflow-hidden rounded-
|
|
77
|
+
overflow-hidden rounded-full border px-4 py-3 shadow-lg
|
|
127
78
|
`}
|
|
128
79
|
role="alert"
|
|
129
80
|
>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Toast } from "./types";
|
|
2
|
+
|
|
3
|
+
const ToastIcon = ({ type }: { type: Toast["type"] }) => {
|
|
4
|
+
if (!type) return null;
|
|
5
|
+
|
|
6
|
+
const iconColors = {
|
|
7
|
+
default: "text-gray-800",
|
|
8
|
+
success: "text-green-600",
|
|
9
|
+
error: "text-red-600",
|
|
10
|
+
warning: "text-yellow-600",
|
|
11
|
+
} as const;
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div className={`h-5 w-5 ${iconColors[type]}`}>
|
|
15
|
+
{type === "success" && (
|
|
16
|
+
<svg
|
|
17
|
+
viewBox="0 0 24 24"
|
|
18
|
+
fill="none"
|
|
19
|
+
stroke="currentColor"
|
|
20
|
+
strokeWidth="2"
|
|
21
|
+
>
|
|
22
|
+
<path
|
|
23
|
+
strokeLinecap="round"
|
|
24
|
+
strokeLinejoin="round"
|
|
25
|
+
d="M5 13l4 4L19 7"
|
|
26
|
+
/>
|
|
27
|
+
</svg>
|
|
28
|
+
)}
|
|
29
|
+
{type === "error" && (
|
|
30
|
+
<svg
|
|
31
|
+
viewBox="0 0 24 24"
|
|
32
|
+
fill="none"
|
|
33
|
+
stroke="currentColor"
|
|
34
|
+
strokeWidth="2"
|
|
35
|
+
>
|
|
36
|
+
<path
|
|
37
|
+
strokeLinecap="round"
|
|
38
|
+
strokeLinejoin="round"
|
|
39
|
+
d="M6 18L18 6M6 6l12 12"
|
|
40
|
+
/>
|
|
41
|
+
</svg>
|
|
42
|
+
)}
|
|
43
|
+
{type === "warning" && (
|
|
44
|
+
<svg
|
|
45
|
+
viewBox="0 0 24 24"
|
|
46
|
+
fill="none"
|
|
47
|
+
stroke="currentColor"
|
|
48
|
+
strokeWidth="2"
|
|
49
|
+
>
|
|
50
|
+
<path
|
|
51
|
+
strokeLinecap="round"
|
|
52
|
+
strokeLinejoin="round"
|
|
53
|
+
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
|
|
54
|
+
/>
|
|
55
|
+
</svg>
|
|
56
|
+
)}
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default ToastIcon;
|