overleaf/services/web/frontend/js/shared/components/badge.tsx
Alexandre Bourdin 481cd14cb1 Merge pull request #12557 from overleaf/ii-history-react-labels-only
[web] History labels only list

GitOrigin-RevId: 58b8e5a5af0754e32841223f9c478c25900df526
2023-04-13 08:04:12 +00:00

43 lines
982 B
TypeScript

import classnames from 'classnames'
import { MergeAndOverride } from '../../../../types/utils'
type BadgeProps = MergeAndOverride<
React.ComponentProps<'span'>,
{
prepend?: React.ReactNode
children: React.ReactNode
className?: string
showCloseButton?: boolean
onClose?: (e: React.MouseEvent<HTMLButtonElement>) => void
closeBtnProps?: React.ComponentProps<'button'>
}
>
function Badge({
prepend,
children,
className,
showCloseButton = false,
onClose,
closeBtnProps,
...rest
}: BadgeProps) {
return (
<span className={classnames('badge-new', className)} {...rest}>
{prepend}
<span className="badge-new-comment">{children}</span>
{showCloseButton && (
<button
type="button"
className="badge-new-close"
onClick={onClose}
{...closeBtnProps}
>
<span aria-hidden="true">&times;</span>
</button>
)}
</span>
)
}
export default Badge