import { forwardRef, type ForwardedRef, type PropsWithChildren, type HTMLAttributes, } from 'react' import { getBadgeProps, getBadgeIconProps, getIconProps, splitClassNameProp, } from '@pluralsight/headless-styles' import type { BadgeOptions } from '@pluralsight/headless-styles/types' import type { UsesIconProps } from './shared/types.ts' interface BadgeProps extends BadgeOptions, UsesIconProps, HTMLAttributes {} function BadgeEl( props: PropsWithChildren, ref: ForwardedRef ) { const { children, icon, sentiment, size, usage, ...nativeProps } = props const badgeProps = getBadgeProps({ classNames: splitClassNameProp(nativeProps.className), sentiment, size, usage, }) const iconProps = getBadgeIconProps(size ?? 's') const Icon = icon return ( {Icon && ( )} {children} ) } export const Badge = forwardRef(BadgeEl)