badge.tsx 768 B

1234567891011121314151617181920212223242526
  1. "use client";
  2. import type { ComponentRenderProps } from "./types";
  3. import { baseClass, getCustomClass } from "./utils";
  4. export function Badge({ element }: ComponentRenderProps) {
  5. const { props } = element;
  6. const customClass = getCustomClass(props);
  7. const badgeVariant = props.variant as string;
  8. const badgeClass =
  9. badgeVariant === "success"
  10. ? "bg-green-100 text-green-800"
  11. : badgeVariant === "warning"
  12. ? "bg-yellow-100 text-yellow-800"
  13. : badgeVariant === "danger"
  14. ? "bg-red-100 text-red-800"
  15. : "bg-muted text-foreground";
  16. return (
  17. <span
  18. className={`px-1.5 py-0.5 rounded text-[10px] font-medium ${badgeClass} ${baseClass} ${customClass}`}
  19. >
  20. {props.text as string}
  21. </span>
  22. );
  23. }