UNPKG

@stratakit/react

Version:

A React component library for StrataKit

48 lines (47 loc) 1.46 kB
import { jsx, jsxs } from "react/jsx-runtime"; import * as React from "react"; import { Anchor } from "@stratakit/bricks"; import * as SkBanner from "@stratakit/structures/unstable_Banner"; import { useCompatProps } from "./~utils.js"; const Alert = React.forwardRef((props, forwardedRef) => { const { type, children, clickableText, clickableTextProps, onClose, // biome-ignore-start lint/correctness/noUnusedVariables: NOT IMPLEMENTED isSticky, // biome-ignore-end lint/correctness/noUnusedVariables: NOT IMPLEMENTED ...rest } = useCompatProps(props); const tone = React.useMemo(() => { switch (type) { case "positive": return "positive"; case "negative": return "critical"; case "warning": return "attention"; } return "info"; }, [type]); return /* @__PURE__ */ jsxs(SkBanner.Root, { ...rest, ref: forwardedRef, tone, children: [ /* @__PURE__ */ jsx(SkBanner.Icon, {}), /* @__PURE__ */ jsx(SkBanner.Message, { children }), clickableText != null ? /* @__PURE__ */ jsx(SkBanner.Actions, { children: /* @__PURE__ */ jsx( Anchor, { render: clickableTextProps?.href ? void 0 : /* @__PURE__ */ jsx("button", {}), ...clickableTextProps, children: clickableText } ) }) : null, onClose != null ? /* @__PURE__ */ jsx(SkBanner.DismissButton, { onClick: onClose }) : null ] }); }); export { Alert };