sendou.ink/app/components/Alert.tsx
2022-01-04 19:31:32 +02:00

26 lines
673 B
TypeScript

import clsx from "clsx";
import { AlertIcon } from "./icons/Alert";
import { SuccessIcon } from "./icons/Success";
// TODO: should flex-dir column on mobile
export function Alert(props: {
children: React.ReactNode;
type: "warning" | "info" | "success";
className?: string;
rightAction?: React.ReactNode;
"data-cy"?: string;
}) {
return (
<div
data-type={props.type}
className={clsx("alert", props.className)}
data-cy={props["data-cy"]}
>
{(props.type === "warning" || props.type === "info") && <AlertIcon />}
{props.type === "success" && <SuccessIcon />}
{props.children}
{props.rightAction}
</div>
);
}