Elffuss BraidHub

kikocis/continue public

6072b6346135 · 1.1 KiBRawPermalink
1import {
2 CheckCircleIcon,
3 ExclamationCircleIcon,
4 ExclamationTriangleIcon,
5 InformationCircleIcon,
6} from "@heroicons/react/24/solid";
7import { ReactNode } from "react";
8import { vscBackground } from "..";
9
10type AlertTypes = "info" | "success" | "warning" | "error";
11
12export interface AlertProps {
13 children?: ReactNode;
14 type?: AlertTypes;
15}
16
17type AlertConfig = {
18 [key in AlertTypes]: {
19 Icon: any;
20 };
21};
22
23const ALERT_CONFIGS: AlertConfig = {
24 info: {
25 Icon: InformationCircleIcon,
26 },
27 success: {
28 Icon: CheckCircleIcon,
29 },
30 warning: {
31 Icon: ExclamationTriangleIcon,
32 },
33 error: {
34 Icon: ExclamationCircleIcon,
35 },
36};
37
38function Alert({ children, type = "info" }: AlertProps) {
39 const { Icon } = ALERT_CONFIGS[type];
40
41 return (
42 <div className="bg-editor-foreground rounded-lg border-l-4 p-4 opacity-70 shadow-none">
43 <div className="flex items-start">
44 <Icon
45 className="h-6 min-h-5 w-6 min-w-5"
46 style={{ color: vscBackground }}
47 />
48
49 <div className="ml-3" style={{ color: vscBackground }}>
50 {children}
51 </div>
52 </div>
53 </div>
54 );
55}
56
57export default Alert;