mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
dd5509b16f
GitOrigin-RevId: 4e69d582ce770abcff10f3a6b34662f4873fc224
45 lines
994 B
TypeScript
45 lines
994 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
|
|
closeButton?: boolean
|
|
onClose?: (e: React.MouseEvent<HTMLButtonElement>) => void
|
|
closeBtnProps?: React.ComponentProps<'button'>
|
|
size?: 'sm'
|
|
}
|
|
>
|
|
|
|
function Badge({
|
|
prepend,
|
|
children,
|
|
className,
|
|
closeButton = false,
|
|
onClose,
|
|
closeBtnProps,
|
|
size,
|
|
...rest
|
|
}: BadgeProps) {
|
|
return (
|
|
<span className={classnames('badge-new', className)} {...rest}>
|
|
{prepend}
|
|
<span className="badge-new-comment">{children}</span>
|
|
{closeButton && (
|
|
<button
|
|
type="button"
|
|
className="badge-new-close"
|
|
onClick={onClose}
|
|
{...closeBtnProps}
|
|
>
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
)}
|
|
</span>
|
|
)
|
|
}
|
|
|
|
export default Badge
|