mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
44 lines
982 B
TypeScript
44 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">×</span>
|
||
|
</button>
|
||
|
)}
|
||
|
</span>
|
||
|
)
|
||
|
}
|
||
|
|
||
|
export default Badge
|