adwaita-web
Version:
A GTK inspired toolkit designed to build awesome web apps
50 lines (49 loc) • 1.39 kB
JavaScript
import cx from "clsx";
import React from "react";
import { DialogInformation, DialogWarning, EmblemOk, WindowClose } from "../icons";
import { Box } from "./Box";
import { Button } from "./Button";
function Alert({
title,
children,
className,
size,
icon: iconProp,
showClose = false,
onClose = () => {
},
info,
success,
warning,
danger,
...rest
}) {
const IconElement = iconProp ?? info ? DialogInformation : success ? EmblemOk : warning ? DialogWarning : danger ? DialogWarning : DialogWarning;
const showIcon = Boolean(IconElement);
const alertClassName = cx("Alert", className, size, {
info,
success,
warning,
danger
});
return /* @__PURE__ */ React.createElement(Box, {
horizontal: true,
className: alertClassName,
...rest
}, showIcon && /* @__PURE__ */ React.createElement(Box, {
className: "Alert__icon"
}, /* @__PURE__ */ React.createElement(IconElement, null)), /* @__PURE__ */ React.createElement(Box, {
className: "Alert__content Box__fill"
}, title && /* @__PURE__ */ React.createElement("div", {
className: "Alert__title"
}, title), /* @__PURE__ */ React.createElement("div", {
className: "Alert__message"
}, children)), showClose && /* @__PURE__ */ React.createElement(Button, {
className: "Alert__close",
icon: WindowClose,
onClick: onClose
}));
}
export {
Alert
};