diff --git a/src/components/ui/Badge.tsx b/src/components/ui/Badge.tsx index 01b6c469..286c77c7 100644 --- a/src/components/ui/Badge.tsx +++ b/src/components/ui/Badge.tsx @@ -43,6 +43,11 @@ const sizeClasses: Record = { md: "px-3.5 py-1 text-sm", }; +const iconSizeClasses: Record = { + sm: "w-3 h-3", + md: "w-4 h-4", +}; + const interactiveClasses = "focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-current disabled:cursor-not-allowed disabled:opacity-60"; @@ -62,70 +67,7 @@ const getBadgeClasses = ( .filter(Boolean) .join(" "); -const renderBadgeContent = ( - icon: React.ReactNode, - children: React.ReactNode, - label?: string -) => { - const content = children ?? label; - - return ( - - {icon && {icon}} - {content} - - ); -}; - const Badge = (props: BadgeProps) => { - if (props.as === "button") { - const { - as: Component, - label, - children, - variant = "default", - size = "md", - icon, - className, - type = "button", - ...buttonProps - } = props; - - return ( - - {renderBadgeContent(icon, children, label)} - - ); - } - - if (props.as === "a") { - const { - as: Component, - label, - children, - variant = "default", - size = "md", - icon, - className, - ...anchorProps - } = props; - - return ( - - {renderBadgeContent(icon, children, label)} - - ); - } - const { as: Component = "span", label, @@ -133,16 +75,26 @@ const Badge = (props: BadgeProps) => { variant = "default", size = "md", icon, - className, - ...spanProps - } = props; + className = "", + ...restProps + } = props as BadgeSpanProps & BadgeButtonProps & BadgeAnchorProps; + + const isInteractive = Component === "button" || Component === "a"; return ( - {renderBadgeContent(icon, children, label)} + {icon && ( + + )} + {children ?? label} ); };