2022-11-15 19:33:59 +00:00
|
|
|
import { XIcon } from "@heroicons/react/solid";
|
|
|
|
import classNames from "classnames";
|
|
|
|
import noop from "lodash/noop";
|
|
|
|
import { ReactNode } from "react";
|
|
|
|
|
2023-01-23 23:08:01 +00:00
|
|
|
import { FiAlertTriangle, FiInfo } from "@calcom/ui/components/icon";
|
2022-12-19 17:37:20 +00:00
|
|
|
|
2022-11-15 19:33:59 +00:00
|
|
|
export type TopBannerProps = {
|
|
|
|
text: string;
|
|
|
|
variant?: keyof typeof variantClassName;
|
|
|
|
actions?: ReactNode;
|
|
|
|
onClose?: () => void;
|
|
|
|
};
|
|
|
|
|
|
|
|
const variantClassName = {
|
|
|
|
default: "bg-gradient-primary",
|
|
|
|
warning: "bg-orange-400",
|
|
|
|
error: "bg-red-400",
|
|
|
|
};
|
|
|
|
|
|
|
|
export function TopBanner(props: TopBannerProps) {
|
|
|
|
const { variant = "default", text, actions, onClose } = props;
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
data-testid="banner"
|
|
|
|
className={classNames(
|
2022-12-19 17:37:20 +00:00
|
|
|
"flex min-h-[40px] w-full items-start justify-between gap-8 py-2 px-4 text-center lg:items-center",
|
2022-11-15 19:33:59 +00:00
|
|
|
variantClassName[variant]
|
|
|
|
)}>
|
2022-12-08 18:42:55 +00:00
|
|
|
<div className="flex flex-1 flex-col items-start justify-center gap-2 p-1 lg:flex-row lg:items-center">
|
|
|
|
<p className="flex flex-col items-start justify-center gap-2 text-left font-sans text-sm font-medium leading-4 text-gray-900 lg:flex-row lg:items-center">
|
2022-12-19 17:37:20 +00:00
|
|
|
{variant === "error" && (
|
2023-01-23 23:08:01 +00:00
|
|
|
<FiAlertTriangle className="h-4 w-4 stroke-[2.5px] text-black" aria-hidden="true" />
|
2022-12-19 17:37:20 +00:00
|
|
|
)}
|
|
|
|
{variant === "warning" && (
|
2023-01-23 23:08:01 +00:00
|
|
|
<FiInfo className="h-4 w-4 stroke-[2.5px] text-black" aria-hidden="true" />
|
2022-11-15 19:33:59 +00:00
|
|
|
)}
|
|
|
|
{text}
|
|
|
|
</p>
|
2022-12-19 17:37:20 +00:00
|
|
|
{actions && <div className="text-sm font-medium">{actions}</div>}
|
2022-11-15 19:33:59 +00:00
|
|
|
</div>
|
|
|
|
{typeof onClose === "function" && (
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
onClick={noop}
|
|
|
|
className="hover:bg-gray-20 flex items-center rounded-lg p-1.5 text-sm text-gray-400">
|
|
|
|
<XIcon className="h-4 w-4 text-black" />
|
|
|
|
</button>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|