UNPKG

@stratakit/react

Version:

A React component library for StrataKit

33 lines (32 loc) 868 B
import { jsx } from "react/jsx-runtime"; import * as React from "react"; import { Badge as SkBadge } from "@stratakit/bricks"; import { useCompatProps } from "./~utils.js"; const Badge = React.forwardRef((props, forwardedRef) => { const { backgroundColor, // PARTIALLY IMPLEMENTED children, // PARTIALLY IMPLEMENTED ...rest } = useCompatProps(props); const tone = React.useMemo(() => { switch (backgroundColor) { case "primary": case "informational": return "info"; case "positive": return "positive"; case "negative": return "critical"; case "warning": return "attention"; } return void 0; }, [backgroundColor]); return /* @__PURE__ */ jsx(SkBadge, { ...rest, ref: forwardedRef, label: children, tone }); }); DEV: Badge.displayName = "Badge"; export { Badge };