import { forwardRef } from "react";

/**
 * Badge
 *
 * variant: "info" | "success" | "warning" | "danger" | "current" | (default)
 * shape:   "pill" | "sharp" | (default)
 */
const Badge = forwardRef(function Badge(
  {
    variant,
    shape,
    className = "",
    children,
    ...props
  },
  ref
) {
  const classes = [
    "prs-badge",
    variant === "info"    && "prs-badge-info",
    variant === "success" && "prs-badge-success",
    variant === "warning" && "prs-badge-warning",
    variant === "danger"  && "prs-badge-danger",
    variant === "current" && "prs-badge-current",
    shape === "pill"  && "prs-badge-pill",
    shape === "sharp" && "prs-badge-sharp",
    className,
  ]
    .filter(Boolean)
    .join(" ");

  return (
    <span ref={ref} className={classes} {...props}>
      {children}
    </span>
  );
});

export default Badge;
