UNPKG

@airplane/views

Version:

A React library for building Airplane views. Views components are optimized in style and functionality to produce internal apps that are easy to build and maintain.

60 lines (59 loc) 1.98 kB
import { jsx, jsxs } from "react/jsx-runtime"; import { ComponentErrorBoundary } from "../errorBoundary/ComponentErrorBoundary.js"; import { InformationCircleIcon, CheckCircleIcon, ExclamationTriangleIcon, ExclamationCircleIcon } from "@airplane/views/icons/index.js"; import { useCommonLayoutStyle } from "../layout/useCommonLayoutStyle.js"; import { useStyles } from "./Callout.styles.js"; const CalloutComponent = ({ className, style, children, icon, title, variant = "info", width, height, grow }) => { const { classes, cx } = useStyles({ variant }); const { classes: layoutClasses } = useCommonLayoutStyle({ width, height, grow }); const variantIcon = getIcon(variant); const renderedIcon = icon === void 0 ? variantIcon : icon; return /* @__PURE__ */ jsxs("div", { style, className: cx(classes.root, layoutClasses.style, className), children: [ renderedIcon !== null && /* @__PURE__ */ jsx("div", { className: classes.icon, children: renderedIcon }), /* @__PURE__ */ jsxs("div", { className: classes.body, children: [ title && /* @__PURE__ */ jsx("div", { className: classes.title, children: title }), /* @__PURE__ */ jsx("div", { children }) ] }) ] }); }; const getIcon = (variant) => { if (variant === "info") { return /* @__PURE__ */ jsx(InformationCircleIcon, {}); } else if (variant === "success") { return /* @__PURE__ */ jsx(CheckCircleIcon, {}); } else if (variant === "warning") { return /* @__PURE__ */ jsx(ExclamationTriangleIcon, {}); } else if (variant === "error") { return /* @__PURE__ */ jsx(ExclamationCircleIcon, {}); } else { return null; } }; const Callout = (props) => /* @__PURE__ */ jsx(ComponentErrorBoundary, { componentName: Callout.displayName, children: /* @__PURE__ */ jsx(CalloutComponent, { ...props }) }); Callout.displayName = "Callout"; export { Callout, CalloutComponent }; //# sourceMappingURL=Callout.js.map