All files / src/components/badge BuiltInBadge.tsx

100% Statements 4/4
100% Branches 4/4
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45                                        34x   34x         34x       308x                          
import { BadgeCheck } from "lucide-react";
import React from "react";
 
/**
 * Marks a platform-managed resource — CHAINR Bot, its user guide, the
 * built-in skillsets, datasets, repositories and rules.
 *
 * A pill rather than a corner mark: the sparkle on an icon says where a
 * resource *came from* (see `GeneratedMark`), while this says who it
 * *belongs to* and what the reader may do with it, which is the first thing
 * someone needs before they go looking for an edit button that is not there.
 */
 
export interface BuiltInBadgeProps {
  /** `sm` for dense rows; `md` beside a page or card title. */
  size?: "sm" | "md";
  className?: string;
}
 
export const BUILT_IN_TOOLTIP =
  "Built-in: managed by CHAIN-R and available to every user. It cannot be edited.";
 
const SIZES: Record<NonNullable<BuiltInBadgeProps["size"]>, string> = {
  sm: "gap-0.5 px-1.5 py-px text-[10px]",
  md: "gap-1 px-2 py-0.5 text-xs",
};
 
export const BuiltInBadge: React.FC<BuiltInBadgeProps> = ({
  size = "md",
  className = "",
}) => (
  <span
    title={BUILT_IN_TOOLTIP}
    className={`inline-flex shrink-0 items-center rounded-full border border-indigo-200 dark:border-indigo-800 bg-indigo-50 dark:bg-indigo-950/40 font-medium text-indigo-700 dark:text-indigo-300 ${SIZES[size]} ${className}`}
  >
    <BadgeCheck
      className={size === "sm" ? "size-2.5" : "size-3"}
      aria-hidden="true"
    />
    Built-in
  </span>
);
 
export default BuiltInBadge;