overleaf/services/web/frontend/js/shared/components/badge.tsx
ilkin-overleaf fe7de51827 Merge pull request #18338 from overleaf/ii-bs5-split-badges-and-tags
[web] Split badges and tags

GitOrigin-RevId: fce5a93672f431ff74c2b63a67e249f5f7e7fecd
2024-05-28 08:04:05 +00:00

29 lines
754 B
TypeScript

import { Label } from 'react-bootstrap'
import classnames from 'classnames'
import { MergeAndOverride } from '../../../../types/utils'
type BadgeProps = MergeAndOverride<
React.ComponentProps<'span'>,
{
prepend?: React.ReactNode
children: React.ReactNode
className?: string
bsStyle?: React.ComponentProps<typeof Label>['bsStyle'] | null
}
>
function Badge({ prepend, children, bsStyle, className, ...rest }: BadgeProps) {
const classNames =
bsStyle === null
? className
: classnames('label', `label-${bsStyle}`, className)
return (
<span className={classNames} {...rest}>
{prepend && <span className="badge-tag-bs3-prepend">{prepend}</span>}
{children}
</span>
)
}
export default Badge