2023-04-12 04:34:56 -04:00
|
|
|
import classnames from 'classnames'
|
|
|
|
import { MergeAndOverride } from '../../../../types/utils'
|
2024-04-19 08:30:23 -04:00
|
|
|
import BadgeWrapper from '@/features/ui/components/bootstrap-5/wrappers/badge-wrapper'
|
2023-04-12 04:34:56 -04:00
|
|
|
|
|
|
|
type BadgeProps = MergeAndOverride<
|
|
|
|
React.ComponentProps<'span'>,
|
|
|
|
{
|
|
|
|
prepend?: React.ReactNode
|
|
|
|
children: React.ReactNode
|
|
|
|
closeBtnProps?: React.ComponentProps<'button'>
|
2024-04-19 08:30:23 -04:00
|
|
|
className?: string
|
|
|
|
bsStyle?: NonNullable<
|
|
|
|
React.ComponentProps<typeof BadgeWrapper>['bs3Props']
|
|
|
|
>['bsStyle']
|
2023-04-12 04:34:56 -04:00
|
|
|
}
|
|
|
|
>
|
|
|
|
|
|
|
|
function Badge({
|
|
|
|
prepend,
|
|
|
|
children,
|
|
|
|
closeBtnProps,
|
2024-04-19 08:30:23 -04:00
|
|
|
bsStyle,
|
|
|
|
className,
|
2023-04-12 04:34:56 -04:00
|
|
|
...rest
|
|
|
|
}: BadgeProps) {
|
2024-04-19 08:30:23 -04:00
|
|
|
const classNames =
|
|
|
|
bsStyle === null
|
|
|
|
? className
|
|
|
|
: classnames('label', `label-${bsStyle}`, className)
|
|
|
|
|
2023-04-12 04:34:56 -04:00
|
|
|
return (
|
2024-04-19 08:30:23 -04:00
|
|
|
<span className={classNames} {...rest}>
|
|
|
|
{prepend && <span className="badge-bs3-prepend">{prepend}</span>}
|
|
|
|
{children}
|
|
|
|
{closeBtnProps && (
|
|
|
|
<button type="button" className="badge-bs3-close" {...closeBtnProps}>
|
2023-04-12 04:34:56 -04:00
|
|
|
<span aria-hidden="true">×</span>
|
|
|
|
</button>
|
|
|
|
)}
|
|
|
|
</span>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Badge
|