2022-03-17 16:48:23 +00:00
|
|
|
import { CheckCircleIcon, ExclamationIcon, InformationCircleIcon, XCircleIcon } from "@heroicons/react/solid";
|
2021-09-06 13:51:15 +00:00
|
|
|
import classNames from "classnames";
|
|
|
|
import { ReactNode } from "react";
|
|
|
|
|
|
|
|
export interface AlertProps {
|
2021-09-29 11:33:40 +00:00
|
|
|
title?: ReactNode;
|
2021-09-06 13:51:15 +00:00
|
|
|
message?: ReactNode;
|
2021-10-12 09:35:44 +00:00
|
|
|
actions?: ReactNode;
|
2021-09-06 13:51:15 +00:00
|
|
|
className?: string;
|
2022-03-17 16:48:23 +00:00
|
|
|
severity: "success" | "warning" | "error" | "info";
|
2021-09-06 13:51:15 +00:00
|
|
|
}
|
|
|
|
export function Alert(props: AlertProps) {
|
|
|
|
const { severity } = props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className={classNames(
|
2022-02-09 00:05:13 +00:00
|
|
|
"rounded-sm border border-opacity-20 p-3",
|
2021-09-06 13:51:15 +00:00
|
|
|
props.className,
|
2022-02-09 00:05:13 +00:00
|
|
|
severity === "error" && "border-red-900 bg-red-50 text-red-800",
|
|
|
|
severity === "warning" && "border-yellow-700 bg-yellow-50 text-yellow-700",
|
2022-03-17 16:48:23 +00:00
|
|
|
severity === "info" && "border-sky-700 bg-sky-50 text-sky-700",
|
2021-09-06 13:51:15 +00:00
|
|
|
severity === "success" && "bg-gray-900 text-white"
|
|
|
|
)}>
|
|
|
|
<div className="flex">
|
|
|
|
<div className="flex-shrink-0">
|
|
|
|
{severity === "error" && (
|
|
|
|
<XCircleIcon className={classNames("h-5 w-5 text-red-400")} aria-hidden="true" />
|
|
|
|
)}
|
|
|
|
{severity === "warning" && (
|
2022-03-17 16:48:23 +00:00
|
|
|
<ExclamationIcon className={classNames("h-5 w-5 text-yellow-400")} aria-hidden="true" />
|
|
|
|
)}
|
|
|
|
{severity === "info" && (
|
|
|
|
<InformationCircleIcon className={classNames("h-5 w-5 text-sky-400")} aria-hidden="true" />
|
2021-09-06 13:51:15 +00:00
|
|
|
)}
|
|
|
|
{severity === "success" && (
|
|
|
|
<CheckCircleIcon className={classNames("h-5 w-5 text-gray-400")} aria-hidden="true" />
|
|
|
|
)}
|
|
|
|
</div>
|
2022-02-09 00:05:13 +00:00
|
|
|
<div className="ml-3 flex-grow">
|
2021-09-06 13:51:15 +00:00
|
|
|
<h3 className="text-sm font-medium">{props.title}</h3>
|
|
|
|
<div className="text-sm">{props.message}</div>
|
|
|
|
</div>
|
2021-10-12 09:35:44 +00:00
|
|
|
{props.actions && <div className="text-sm">{props.actions}</div>}
|
2021-09-06 13:51:15 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|