2023-04-12 04:34:56 -04:00
|
|
|
import classnames from 'classnames'
|
|
|
|
import { MergeAndOverride } from '../../../../types/utils'
|
|
|
|
|
|
|
|
type BadgeProps = MergeAndOverride<
|
|
|
|
React.ComponentProps<'span'>,
|
|
|
|
{
|
|
|
|
prepend?: React.ReactNode
|
|
|
|
children: React.ReactNode
|
|
|
|
className?: string
|
2023-04-18 04:14:07 -04:00
|
|
|
closeButton?: boolean
|
2023-04-12 04:34:56 -04:00
|
|
|
onClose?: (e: React.MouseEvent<HTMLButtonElement>) => void
|
|
|
|
closeBtnProps?: React.ComponentProps<'button'>
|
2023-04-14 04:07:29 -04:00
|
|
|
size?: 'sm'
|
2023-04-12 04:34:56 -04:00
|
|
|
}
|
|
|
|
>
|
|
|
|
|
|
|
|
function Badge({
|
|
|
|
prepend,
|
|
|
|
children,
|
|
|
|
className,
|
2023-04-18 04:14:07 -04:00
|
|
|
closeButton = false,
|
2023-04-12 04:34:56 -04:00
|
|
|
onClose,
|
|
|
|
closeBtnProps,
|
2023-04-14 04:07:29 -04:00
|
|
|
size,
|
2023-04-12 04:34:56 -04:00
|
|
|
...rest
|
|
|
|
}: BadgeProps) {
|
|
|
|
return (
|
|
|
|
<span className={classnames('badge-new', className)} {...rest}>
|
|
|
|
{prepend}
|
|
|
|
<span className="badge-new-comment">{children}</span>
|
2023-04-18 04:14:07 -04:00
|
|
|
{closeButton && (
|
2023-04-12 04:34:56 -04:00
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="badge-new-close"
|
|
|
|
onClick={onClose}
|
|
|
|
{...closeBtnProps}
|
|
|
|
>
|
|
|
|
<span aria-hidden="true">×</span>
|
|
|
|
</button>
|
|
|
|
)}
|
|
|
|
</span>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Badge
|