@zauru-sdk/components 1.0.11
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/.eslintrc.cjs +83 -0
- package/CHANGELOG.md +8 -0
- package/LICENCE.md +11 -0
- package/dist/Alerts/Alert.d.ts +9 -0
- package/dist/Alerts/Alert.js +97 -0
- package/dist/Alerts/ErrorBoundaryAlert/ErrorBoundaryAlert.d.ts +6 -0
- package/dist/Alerts/ErrorBoundaryAlert/ErrorBoundaryAlert.js +5 -0
- package/dist/Alerts/StaticAlert.d.ts +11 -0
- package/dist/Alerts/StaticAlert.js +28 -0
- package/dist/Icons/Icons.d.ts +47 -0
- package/dist/Icons/Icons.js +110 -0
- package/dist/Icons/StylesConstants.d.ts +26 -0
- package/dist/Icons/StylesConstants.js +34 -0
- package/dist/NavBar/NavBar.d.ts +2 -0
- package/dist/NavBar/NavBar.js +32 -0
- package/dist/NavBar/NavBar.types.d.ts +50 -0
- package/dist/NavBar/NavBar.types.js +1 -0
- package/dist/NavBar/NavBar.utils.d.ts +58 -0
- package/dist/NavBar/NavBar.utils.js +58 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +1 -0
- package/package.json +49 -0
- package/src/Alerts/Alert.tsx +149 -0
- package/src/Alerts/ErrorBoundaryAlert/ErrorBoundaryAlert.tsx +66 -0
- package/src/Alerts/StaticAlert.tsx +121 -0
- package/src/Icons/Icons.tsx +782 -0
- package/src/Icons/StylesConstants.tsx +66 -0
- package/src/NavBar/NavBar.tsx +223 -0
- package/src/NavBar/NavBar.types.ts +64 -0
- package/src/NavBar/NavBar.utils.ts +58 -0
- package/src/index.ts +0 -0
- package/tsconfig.json +26 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export type NavBarItemsSchema = {
|
|
2
|
+
name: string;
|
|
3
|
+
link: string;
|
|
4
|
+
loggedIn: boolean;
|
|
5
|
+
icon?: any;
|
|
6
|
+
color?: "green";
|
|
7
|
+
childrens?: Exclude<NavBarItemsSchema, "loggedIn">[];
|
|
8
|
+
};
|
|
9
|
+
export type NavBarProps = {
|
|
10
|
+
title: string;
|
|
11
|
+
loggedIn: boolean;
|
|
12
|
+
items: Array<NavBarItemsSchema>;
|
|
13
|
+
selectedColor: "pink" | "purple" | "slate" | "green" | "yellow" | "red" | "sky";
|
|
14
|
+
LinkComponent?: any;
|
|
15
|
+
};
|
|
16
|
+
export type NavBarStateProps = {
|
|
17
|
+
NavBarOpen: boolean;
|
|
18
|
+
setNavBarOpen?: any;
|
|
19
|
+
};
|
|
20
|
+
export type ColorInterface = {
|
|
21
|
+
bg900: string;
|
|
22
|
+
bg700: string;
|
|
23
|
+
bg600: string;
|
|
24
|
+
bg500: string;
|
|
25
|
+
ring600: string;
|
|
26
|
+
ring500: string;
|
|
27
|
+
};
|
|
28
|
+
export type NavItemProps = {
|
|
29
|
+
name: string;
|
|
30
|
+
link: string;
|
|
31
|
+
icon?: any;
|
|
32
|
+
color: ColorInterface;
|
|
33
|
+
specialColor?: ColorInterface;
|
|
34
|
+
childrens?: Exclude<NavItemProps, "index" | "color">[];
|
|
35
|
+
};
|
|
36
|
+
export type EntityNameType = {
|
|
37
|
+
entityName: string;
|
|
38
|
+
};
|
|
39
|
+
export type EntityProps = {
|
|
40
|
+
name?: string;
|
|
41
|
+
color: ColorInterface;
|
|
42
|
+
options: any[];
|
|
43
|
+
};
|
|
44
|
+
export type DropDownLinkButtonType = {
|
|
45
|
+
text: string;
|
|
46
|
+
path: string;
|
|
47
|
+
icon?: any;
|
|
48
|
+
buttonHover?: string;
|
|
49
|
+
LinkComponent?: any;
|
|
50
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export declare const COLORS: {
|
|
2
|
+
sky: {
|
|
3
|
+
bg900: string;
|
|
4
|
+
bg700: string;
|
|
5
|
+
bg600: string;
|
|
6
|
+
bg500: string;
|
|
7
|
+
ring600: string;
|
|
8
|
+
ring500: string;
|
|
9
|
+
};
|
|
10
|
+
purple: {
|
|
11
|
+
bg900: string;
|
|
12
|
+
bg700: string;
|
|
13
|
+
bg600: string;
|
|
14
|
+
bg500: string;
|
|
15
|
+
ring600: string;
|
|
16
|
+
ring500: string;
|
|
17
|
+
};
|
|
18
|
+
pink: {
|
|
19
|
+
bg900: string;
|
|
20
|
+
bg700: string;
|
|
21
|
+
bg600: string;
|
|
22
|
+
bg500: string;
|
|
23
|
+
ring600: string;
|
|
24
|
+
ring500: string;
|
|
25
|
+
};
|
|
26
|
+
slate: {
|
|
27
|
+
bg900: string;
|
|
28
|
+
bg700: string;
|
|
29
|
+
bg600: string;
|
|
30
|
+
bg500: string;
|
|
31
|
+
ring600: string;
|
|
32
|
+
ring500: string;
|
|
33
|
+
};
|
|
34
|
+
green: {
|
|
35
|
+
bg900: string;
|
|
36
|
+
bg700: string;
|
|
37
|
+
bg600: string;
|
|
38
|
+
bg500: string;
|
|
39
|
+
ring600: string;
|
|
40
|
+
ring500: string;
|
|
41
|
+
};
|
|
42
|
+
yellow: {
|
|
43
|
+
bg900: string;
|
|
44
|
+
bg700: string;
|
|
45
|
+
bg600: string;
|
|
46
|
+
bg500: string;
|
|
47
|
+
ring600: string;
|
|
48
|
+
ring500: string;
|
|
49
|
+
};
|
|
50
|
+
red: {
|
|
51
|
+
bg900: string;
|
|
52
|
+
bg700: string;
|
|
53
|
+
bg600: string;
|
|
54
|
+
bg500: string;
|
|
55
|
+
ring600: string;
|
|
56
|
+
ring500: string;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export const COLORS = {
|
|
2
|
+
sky: {
|
|
3
|
+
bg900: "bg-sky-900",
|
|
4
|
+
bg700: "bg-sky-700",
|
|
5
|
+
bg600: "bg-sky-600",
|
|
6
|
+
bg500: "bg-sky-500",
|
|
7
|
+
ring600: "ring-sky-600",
|
|
8
|
+
ring500: "ring-sky-500",
|
|
9
|
+
},
|
|
10
|
+
purple: {
|
|
11
|
+
bg900: "bg-purple-900",
|
|
12
|
+
bg700: "bg-purple-700",
|
|
13
|
+
bg600: "bg-purple-600",
|
|
14
|
+
bg500: "bg-purple-500",
|
|
15
|
+
ring600: "ring-purple-600",
|
|
16
|
+
ring500: "ring-purple-500",
|
|
17
|
+
},
|
|
18
|
+
pink: {
|
|
19
|
+
bg900: "bg-pink-900",
|
|
20
|
+
bg700: "bg-pink-700",
|
|
21
|
+
bg600: "bg-pink-600",
|
|
22
|
+
bg500: "bg-pink-500",
|
|
23
|
+
ring600: "ring-pink-600",
|
|
24
|
+
ring500: "ring-pink-500",
|
|
25
|
+
},
|
|
26
|
+
slate: {
|
|
27
|
+
bg900: "bg-slate-900",
|
|
28
|
+
bg700: "bg-slate-700",
|
|
29
|
+
bg600: "bg-slate-600",
|
|
30
|
+
bg500: "bg-slate-500",
|
|
31
|
+
ring600: "ring-slate-600",
|
|
32
|
+
ring500: "ring-slate-500",
|
|
33
|
+
},
|
|
34
|
+
green: {
|
|
35
|
+
bg900: "bg-green-900",
|
|
36
|
+
bg700: "bg-green-700",
|
|
37
|
+
bg600: "bg-green-600",
|
|
38
|
+
bg500: "bg-green-500",
|
|
39
|
+
ring600: "ring-green-600",
|
|
40
|
+
ring500: "ring-green-500",
|
|
41
|
+
},
|
|
42
|
+
yellow: {
|
|
43
|
+
bg900: "bg-yellow-900",
|
|
44
|
+
bg700: "bg-yellow-700",
|
|
45
|
+
bg600: "bg-yellow-600",
|
|
46
|
+
bg500: "bg-yellow-500",
|
|
47
|
+
ring600: "ring-yellow-600",
|
|
48
|
+
ring500: "ring-yellow-500",
|
|
49
|
+
},
|
|
50
|
+
red: {
|
|
51
|
+
bg900: "bg-red-900",
|
|
52
|
+
bg700: "bg-red-700",
|
|
53
|
+
bg600: "bg-red-600",
|
|
54
|
+
bg500: "bg-red-500",
|
|
55
|
+
ring600: "ring-red-600",
|
|
56
|
+
ring500: "ring-red-500",
|
|
57
|
+
},
|
|
58
|
+
};
|
package/dist/index.d.ts
ADDED
|
File without changes
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zauru-sdk/components",
|
|
3
|
+
"version": "1.0.11",
|
|
4
|
+
"description": "Componentes reutilizables en las WebApps de Zauru.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
|
+
},
|
|
15
|
+
"author": "Oscar Cuéllar",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/react": "^18.2.20",
|
|
19
|
+
"@types/react-dom": "^18.2.7",
|
|
20
|
+
"eslint": "^8.38.0",
|
|
21
|
+
"eslint-config-prettier": "^9.0.0",
|
|
22
|
+
"eslint-import-resolver-typescript": "^3.6.1",
|
|
23
|
+
"eslint-plugin-import": "^2.28.1",
|
|
24
|
+
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
25
|
+
"eslint-plugin-react": "^7.33.2",
|
|
26
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
27
|
+
"react-data-table-component": "^7.4.7",
|
|
28
|
+
"tailwindcss": "^3.4.1",
|
|
29
|
+
"typescript": "^5.1.6"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@reduxjs/toolkit": "^2.2.1",
|
|
33
|
+
"@remix-run/react": "^2.8.1",
|
|
34
|
+
"@zauru-sdk/graphql": "^1.0.9",
|
|
35
|
+
"@zauru-sdk/services": "^1.0.10",
|
|
36
|
+
"@zauru-sdk/types": "^1.0.10",
|
|
37
|
+
"@zauru-sdk/utils": "^1.0.10",
|
|
38
|
+
"framer-motion": "^11.0.8",
|
|
39
|
+
"react": "^18.2.0",
|
|
40
|
+
"react-dom": "^18.2.0",
|
|
41
|
+
"react-is": "^18.2.0",
|
|
42
|
+
"react-select": "^5.8.0",
|
|
43
|
+
"styled-components": "^5.3.5"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=18.0.0"
|
|
47
|
+
},
|
|
48
|
+
"gitHead": "d296471a4450a74c505269079769dabfab983749"
|
|
49
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect } from "react";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
import { ExitSvg } from "../Icons/Icons";
|
|
4
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
5
|
+
|
|
6
|
+
type AlertType = "success" | "error" | "info" | "warning";
|
|
7
|
+
|
|
8
|
+
export type AlertProps = {
|
|
9
|
+
type: AlertType;
|
|
10
|
+
title: string;
|
|
11
|
+
description: string;
|
|
12
|
+
onClose?: () => void;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const Alert: React.FC<AlertProps> = ({ type, title, description, onClose }) => {
|
|
16
|
+
const [, setLifetime] = useState(4000);
|
|
17
|
+
const [progress, setProgress] = useState(0);
|
|
18
|
+
const intervalRef = useRef<any>(null);
|
|
19
|
+
|
|
20
|
+
const getColor = () => {
|
|
21
|
+
switch (type) {
|
|
22
|
+
case "success":
|
|
23
|
+
return "bg-green-100 text-green-800";
|
|
24
|
+
case "error":
|
|
25
|
+
return "bg-red-100 text-red-800";
|
|
26
|
+
case "info":
|
|
27
|
+
return "bg-blue-100 text-blue-800";
|
|
28
|
+
case "warning":
|
|
29
|
+
return "bg-yellow-100 text-yellow-800";
|
|
30
|
+
default:
|
|
31
|
+
return "bg-gray-100 text-gray-800";
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const startTimer = () => {
|
|
37
|
+
intervalRef.current = setInterval(() => {
|
|
38
|
+
setLifetime((lifetime) => {
|
|
39
|
+
if (lifetime <= 0) {
|
|
40
|
+
onClose && onClose();
|
|
41
|
+
clearInterval(intervalRef.current);
|
|
42
|
+
return 0;
|
|
43
|
+
} else {
|
|
44
|
+
setProgress((4000 - lifetime) / 4000);
|
|
45
|
+
return lifetime - 50;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}, 50);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const pauseTimer = () => {
|
|
52
|
+
clearInterval(intervalRef.current);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
startTimer();
|
|
56
|
+
return () => {
|
|
57
|
+
pauseTimer();
|
|
58
|
+
};
|
|
59
|
+
}, [onClose]);
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<motion.div
|
|
63
|
+
initial={{ y: -50, opacity: 0 }}
|
|
64
|
+
animate={{ y: 0, opacity: 1 }}
|
|
65
|
+
exit={{ y: -50, opacity: 0 }}
|
|
66
|
+
className={`fixed top-0 right-0 w-80 mt-10 mr-10 rounded-md shadow-lg ${getColor()} p-4 transition-transform duration-300`}
|
|
67
|
+
style={{
|
|
68
|
+
zIndex: 1000,
|
|
69
|
+
transform: `translateY(calc(var(--alert-offset, 0)))`,
|
|
70
|
+
}}
|
|
71
|
+
onMouseEnter={() => clearInterval(intervalRef.current)}
|
|
72
|
+
onMouseLeave={() => {
|
|
73
|
+
intervalRef.current = setInterval(() => {
|
|
74
|
+
setLifetime((lifetime) => {
|
|
75
|
+
if (lifetime <= 0) {
|
|
76
|
+
onClose && onClose();
|
|
77
|
+
clearInterval(intervalRef.current);
|
|
78
|
+
return 0;
|
|
79
|
+
} else {
|
|
80
|
+
setProgress((4000 - lifetime) / 4000);
|
|
81
|
+
return lifetime - 50;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}, 50);
|
|
85
|
+
}}
|
|
86
|
+
>
|
|
87
|
+
<div className="flex items-center justify-between">
|
|
88
|
+
<h3 className="font-semibold">{title}</h3>
|
|
89
|
+
<button
|
|
90
|
+
className="text-gray-400 hover:text-gray-500 focus:outline-none focus:text-gray-500 transition duration-150 ease-in-out"
|
|
91
|
+
onClick={() => {
|
|
92
|
+
setLifetime(0);
|
|
93
|
+
onClose && onClose();
|
|
94
|
+
}}
|
|
95
|
+
>
|
|
96
|
+
<ExitSvg />
|
|
97
|
+
</button>
|
|
98
|
+
</div>
|
|
99
|
+
<div className="mt-2">
|
|
100
|
+
<p className="text-sm overflow-wrap break-words">{description}</p>
|
|
101
|
+
</div>
|
|
102
|
+
<div className="relative h-1 mt-4 bg-gray-200 rounded">
|
|
103
|
+
<div
|
|
104
|
+
className={`absolute left-0 top-0 h-full ${getColor()} rounded`}
|
|
105
|
+
style={{ width: `${progress * 100}%` }}
|
|
106
|
+
></div>
|
|
107
|
+
</div>
|
|
108
|
+
</motion.div>
|
|
109
|
+
);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
let activeAlerts: HTMLElement[] = [];
|
|
113
|
+
|
|
114
|
+
export const showAlert = (alertProps: AlertProps) => {
|
|
115
|
+
if (typeof document === "undefined") {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const container = document.createElement("div");
|
|
119
|
+
document.body.appendChild(container);
|
|
120
|
+
|
|
121
|
+
const onClose = () => {
|
|
122
|
+
root.unmount();
|
|
123
|
+
container.remove();
|
|
124
|
+
activeAlerts = activeAlerts.filter((alert) => alert !== container);
|
|
125
|
+
updateAlertOffsets();
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const asyncOnClose = () => {
|
|
129
|
+
setTimeout(() => {
|
|
130
|
+
onClose();
|
|
131
|
+
}, 0);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
activeAlerts.push(container);
|
|
135
|
+
updateAlertOffsets();
|
|
136
|
+
|
|
137
|
+
const root = createRoot(container);
|
|
138
|
+
root.render(
|
|
139
|
+
<AnimatePresence>
|
|
140
|
+
<Alert {...alertProps} onClose={asyncOnClose} />
|
|
141
|
+
</AnimatePresence>
|
|
142
|
+
);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const updateAlertOffsets = () => {
|
|
146
|
+
activeAlerts.forEach((alertContainer, index) => {
|
|
147
|
+
alertContainer.style.setProperty("--alert-offset", `${index * 100}px`);
|
|
148
|
+
});
|
|
149
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
//<reference> https://tailwindtemplates.io/templates?category=alert
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
type Props = { title: string; description: string };
|
|
5
|
+
|
|
6
|
+
export const ErrorBoundaryAlert = (props: Props) => {
|
|
7
|
+
const { title, description } = props;
|
|
8
|
+
return (
|
|
9
|
+
<div className="rounded-full top-20 mx-auto p-3">
|
|
10
|
+
<div className="p-4 text-red-900 bg-red-100 border border-red-200 rounded-md">
|
|
11
|
+
<div className="flex justify-between flex-wrap">
|
|
12
|
+
<div className="w-0 flex-1 flex">
|
|
13
|
+
<div className="mr-3 pt-1">
|
|
14
|
+
<svg
|
|
15
|
+
width="26"
|
|
16
|
+
height="26"
|
|
17
|
+
viewBox="0 0 24 24"
|
|
18
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
19
|
+
fill="currentColor"
|
|
20
|
+
>
|
|
21
|
+
<path d="M13.6086 3.247l8.1916 15.8c.0999.2.1998.5.1998.8 0 1-.7992 1.8-1.7982 1.8H3.7188c-.2997 0-.4995-.1-.7992-.2-.7992-.5-1.1988-1.5-.6993-2.4 5.3067-10.1184 8.0706-15.385 8.2915-15.8.3314-.6222.8681-.8886 1.4817-.897.6135-.008 1.273.2807 1.6151.897zM12 18.95c.718 0 1.3-.582 1.3-1.3 0-.718-.582-1.3-1.3-1.3-.718 0-1.3.582-1.3 1.3 0 .718.582 1.3 1.3 1.3zm-.8895-10.203v5.4c0 .5.4.9.9.9s.9-.4.9-.9v-5.3c0-.5-.4-.9-.9-.9s-.9.4-.9.8z"></path>
|
|
22
|
+
</svg>
|
|
23
|
+
</div>
|
|
24
|
+
<div>
|
|
25
|
+
<h4 className="text-md leading-6 font-medium">
|
|
26
|
+
{title?.toString()}
|
|
27
|
+
</h4>
|
|
28
|
+
<p className="text-sm">{description?.toString()}</p>
|
|
29
|
+
{/* ============== BOTONES ============= */}
|
|
30
|
+
{/* <div className="flex mt-3">
|
|
31
|
+
<button
|
|
32
|
+
type="button"
|
|
33
|
+
className="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-600 text-base font-medium text-white hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 sm:w-auto sm:text-sm"
|
|
34
|
+
>
|
|
35
|
+
Primary button
|
|
36
|
+
</button>
|
|
37
|
+
<button
|
|
38
|
+
type="button"
|
|
39
|
+
className="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 ml-2 bg-red-200 text-base font-medium hover:bg-red-300 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-400 sm:w-auto sm:text-sm"
|
|
40
|
+
>
|
|
41
|
+
Secondary button
|
|
42
|
+
</button>
|
|
43
|
+
</div> */}
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
<div>
|
|
47
|
+
<button
|
|
48
|
+
type="button"
|
|
49
|
+
className="rounded-md focus:outline-none focus:ring-2 focus:ring-red-500"
|
|
50
|
+
>
|
|
51
|
+
<svg
|
|
52
|
+
width="24"
|
|
53
|
+
height="24"
|
|
54
|
+
viewBox="0 0 24 24"
|
|
55
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
56
|
+
fill="currentColor"
|
|
57
|
+
>
|
|
58
|
+
<path d="M17.6555 6.3331a.9.9 0 0 1 .001 1.2728l-4.1032 4.1085a.4.4 0 0 0 0 .5653l4.1031 4.1088a.9002.9002 0 0 1 .0797 1.1807l-.0806.092a.9.9 0 0 1-1.2728-.0009l-4.1006-4.1068a.4.4 0 0 0-.5662 0l-4.099 4.1068a.9.9 0 1 1-1.2738-1.2718l4.1027-4.1089a.4.4 0 0 0 0-.5652L6.343 7.6059a.9002.9002 0 0 1-.0796-1.1807l.0806-.092a.9.9 0 0 1 1.2728.0009l4.099 4.1055a.4.4 0 0 0 .5662 0l4.1006-4.1055a.9.9 0 0 1 1.2728-.001z"></path>
|
|
59
|
+
</svg>
|
|
60
|
+
</button>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
//<reference> https://tailwindtemplates.io/templates?category=StaticAlert
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
className?: string;
|
|
6
|
+
title: string;
|
|
7
|
+
description: any;
|
|
8
|
+
showCloseButton?: boolean;
|
|
9
|
+
onClose?: () => void;
|
|
10
|
+
type?: "success" | "info";
|
|
11
|
+
loading?: boolean;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const getConfig = (type: string) => {
|
|
15
|
+
switch (type) {
|
|
16
|
+
case "info":
|
|
17
|
+
return {
|
|
18
|
+
containerClassName:
|
|
19
|
+
"text-blue-900 bg-blue-100 border border-blue-200 rounded-md",
|
|
20
|
+
buttonClassName:
|
|
21
|
+
"rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",
|
|
22
|
+
path: (
|
|
23
|
+
<path d="M14.1667 17h-3.3334c-.5 0-.8333-.3146-.8333-.7865 0-.472.3333-.7865.8333-.7865H11.5c.0833 0 .1667-.0787.1667-.1573v-3.5394c0-.0786-.0834-.1573-.1667-.1573h-.6667c-.5 0-.8333-.3146-.8333-.7865S10.3333 10 10.8333 10h.8334c.9166 0 1.6666.7079 1.6666 1.573v3.7753c0 .0787.0834.1573.1667.1573h.6667c.5 0 .8333.3146.8333.7865 0 .472-.3333.7079-.8333.7079zM12.3 6c.6933 0 1.3.6067 1.3 1.3s-.52 1.3-1.3 1.3S11 7.9933 11 7.3 11.6067 6 12.3 6zM12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2"></path>
|
|
24
|
+
),
|
|
25
|
+
};
|
|
26
|
+
case "success":
|
|
27
|
+
return {
|
|
28
|
+
containerClassName:
|
|
29
|
+
"text-green-900 bg-green-100 border border-green-200 rounded-md",
|
|
30
|
+
buttonClassName:
|
|
31
|
+
"rounded-md focus:outline-none focus:ring-2 focus:ring-green-500",
|
|
32
|
+
path: (
|
|
33
|
+
<path d="M8.445 12.6675A.9.9 0 0 0 7.1424 13.91l2.5726 2.7448c.3679.3856.9884.3689 1.335-.036l5.591-7.0366a.9.9 0 0 0-1.3674-1.1705l-4.6548 5.9132a.4.4 0 0 1-.607.0252l-1.567-1.6826zM1.9995 12c0-5.5 4.5-10 10-10s10 4.5 10 10-4.5 10-10 10-10-4.5-10-10z"></path>
|
|
34
|
+
),
|
|
35
|
+
};
|
|
36
|
+
default:
|
|
37
|
+
return {
|
|
38
|
+
containerClassName:
|
|
39
|
+
"text-blue-900 bg-blue-100 border border-blue-200 rounded-md",
|
|
40
|
+
buttonClassName:
|
|
41
|
+
"rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",
|
|
42
|
+
path: (
|
|
43
|
+
<path d="M14.1667 17h-3.3334c-.5 0-.8333-.3146-.8333-.7865 0-.472.3333-.7865.8333-.7865H11.5c.0833 0 .1667-.0787.1667-.1573v-3.5394c0-.0786-.0834-.1573-.1667-.1573h-.6667c-.5 0-.8333-.3146-.8333-.7865S10.3333 10 10.8333 10h.8334c.9166 0 1.6666.7079 1.6666 1.573v3.7753c0 .0787.0834.1573.1667.1573h.6667c.5 0 .8333.3146.8333.7865 0 .472-.3333.7079-.8333.7079zM12.3 6c.6933 0 1.3.6067 1.3 1.3s-.52 1.3-1.3 1.3S11 7.9933 11 7.3 11.6067 6 12.3 6zM12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2"></path>
|
|
44
|
+
),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const StaticAlert = (props: Props) => {
|
|
50
|
+
const {
|
|
51
|
+
className,
|
|
52
|
+
title,
|
|
53
|
+
description,
|
|
54
|
+
onClose,
|
|
55
|
+
type = "info",
|
|
56
|
+
loading = false,
|
|
57
|
+
} = props;
|
|
58
|
+
|
|
59
|
+
const config = getConfig(type);
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<div
|
|
63
|
+
className={`${className} ${config.containerClassName} ${
|
|
64
|
+
loading ? " hidden" : ""
|
|
65
|
+
}`}
|
|
66
|
+
>
|
|
67
|
+
<div className="flex justify-between flex-wrap">
|
|
68
|
+
<div className="w-0 flex-1 flex">
|
|
69
|
+
<div className="mr-3 pt-1">
|
|
70
|
+
<svg
|
|
71
|
+
width="26"
|
|
72
|
+
height="26"
|
|
73
|
+
viewBox="0 0 24 24"
|
|
74
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
75
|
+
fill="currentColor"
|
|
76
|
+
>
|
|
77
|
+
{config.path}
|
|
78
|
+
</svg>
|
|
79
|
+
</div>
|
|
80
|
+
<div>
|
|
81
|
+
<h4 className="text-md leading-6 font-medium">{title}</h4>
|
|
82
|
+
<div className="text-sm">{description}</div>
|
|
83
|
+
{/* <div className="flex mt-3">
|
|
84
|
+
<button
|
|
85
|
+
type="button"
|
|
86
|
+
className="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-${color}-700 text-base font-medium text-white hover:bg-${color}-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-${color}-500 sm:w-auto sm:text-sm"
|
|
87
|
+
>
|
|
88
|
+
Primary button
|
|
89
|
+
</button>
|
|
90
|
+
<button
|
|
91
|
+
type="button"
|
|
92
|
+
className="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 ml-2 bg-${color}-200 text-base font-medium hover:bg-${color}-300 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-${color}-400 sm:w-auto sm:text-sm"
|
|
93
|
+
>
|
|
94
|
+
Secondary button
|
|
95
|
+
</button>
|
|
96
|
+
</div> */}
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
{onClose && (
|
|
100
|
+
<div>
|
|
101
|
+
<button
|
|
102
|
+
type="button"
|
|
103
|
+
className={`${config.buttonClassName}`}
|
|
104
|
+
onClick={onClose}
|
|
105
|
+
>
|
|
106
|
+
<svg
|
|
107
|
+
width="24"
|
|
108
|
+
height="24"
|
|
109
|
+
viewBox="0 0 24 24"
|
|
110
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
111
|
+
fill="currentColor"
|
|
112
|
+
>
|
|
113
|
+
<path d="M17.6555 6.3331a.9.9 0 0 1 .001 1.2728l-4.1032 4.1085a.4.4 0 0 0 0 .5653l4.1031 4.1088a.9002.9002 0 0 1 .0797 1.1807l-.0806.092a.9.9 0 0 1-1.2728-.0009l-4.1006-4.1068a.4.4 0 0 0-.5662 0l-4.099 4.1068a.9.9 0 1 1-1.2738-1.2718l4.1027-4.1089a.4.4 0 0 0 0-.5652L6.343 7.6059a.9002.9002 0 0 1-.0796-1.1807l.0806-.092a.9.9 0 0 1 1.2728.0009l4.099 4.1055a.4.4 0 0 0 .5662 0l4.1006-4.1055a.9.9 0 0 1 1.2728-.001z"></path>
|
|
114
|
+
</svg>
|
|
115
|
+
</button>
|
|
116
|
+
</div>
|
|
117
|
+
)}
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
};
|