/** * @params color - Text color for badge with color/20 background * @params label - Text within badge */ import { ColorType, ColorVariantType } from "../../types/colors"; import Avatar from "../avatar/avatar"; import { Icon, IconType } from "../icon"; import Typography from "../typography/typography"; export interface BadgeProps extends React.HTMLAttributes { color?: Exclude; label: string; size?: "sm" | "md" | "lg"; icon?: IconType; endIcon?: IconType; avatar?: string; status?: "online" | "offline" | "away"; } const relevantStyleToSize = { sm: "px-2 py-0.5", md: "px-2.5 py-0.5 h-6", lg: "px-3 py-1 h-7", }; export function Badge({ label, color = "gray", icon, endIcon, size = "md", avatar, status = "offline", ...props }: BadgeProps) { return (
{icon && ( )} {status !== "offline" && (
)} {avatar && ( )} {label} {endIcon && ( )}
); } export default Badge;