2022-01-09 21:34:50 -05:00
|
|
|
import { Fragment } from "react";
|
|
|
|
import { Transition } from "@headlessui/react";
|
2022-01-14 22:05:57 -05:00
|
|
|
import classNames from "classnames";
|
2022-01-09 21:34:50 -05:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
isOpen: boolean;
|
|
|
|
message: string;
|
2022-01-14 22:05:57 -05:00
|
|
|
variant?: "success" | "warning";
|
2022-01-09 21:34:50 -05:00
|
|
|
};
|
|
|
|
|
2022-01-14 22:05:57 -05:00
|
|
|
export const Alert = ({ isOpen, message, variant = "warning" }: Props) => {
|
|
|
|
const classes = classNames(
|
|
|
|
"fixed top-2.5 left-1/2 transform -translate-x-1/2 max-w-sm w-full shadow-lg rounded-lg pointer-events-auto ring-1 ring-black ring-opacity-5 overflow-hidden",
|
|
|
|
{
|
|
|
|
"bg-rose-200": variant === "warning",
|
|
|
|
"bg-green-200": variant === "success",
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2022-01-09 21:34:50 -05:00
|
|
|
return (
|
|
|
|
<Transition
|
|
|
|
show={isOpen}
|
|
|
|
as={Fragment}
|
|
|
|
enter="ease-out duration-300 transition"
|
|
|
|
enterFrom="opacity-0"
|
|
|
|
enterTo="opacity-100"
|
|
|
|
leave="transition ease-in duration-100"
|
|
|
|
leaveFrom="opacity-100"
|
|
|
|
leaveTo="opacity-0"
|
|
|
|
>
|
2022-01-14 22:05:57 -05:00
|
|
|
<div className={classes}>
|
2022-01-09 21:34:50 -05:00
|
|
|
<div className="p-4">
|
|
|
|
<p className="text-sm text-center font-medium text-gray-900">
|
|
|
|
{message}
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Transition>
|
|
|
|
);
|
|
|
|
};
|