@stratakit/react
Version:
A React component library for StrataKit
49 lines (48 loc) • 1.49 kB
JavaScript
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
] });
});
DEV: Alert.displayName = "Alert";
export {
Alert
};