2023-01-05 05:17:57 -05:00
|
|
|
import type { FC, ReactNode } from 'react'
|
|
|
|
import classnames from 'classnames'
|
2022-05-18 09:46:10 -04:00
|
|
|
import Tooltip from './tooltip'
|
|
|
|
import { OverlayTriggerProps } from 'react-bootstrap'
|
|
|
|
|
|
|
|
type TooltipProps = {
|
|
|
|
id: string
|
2023-01-05 05:17:57 -05:00
|
|
|
text: ReactNode
|
2022-05-18 09:46:10 -04:00
|
|
|
placement?: OverlayTriggerProps['placement']
|
|
|
|
className?: string
|
|
|
|
}
|
|
|
|
|
2023-01-05 05:17:57 -05:00
|
|
|
const BetaBadge: FC<{
|
2022-05-18 09:46:10 -04:00
|
|
|
tooltip: TooltipProps
|
|
|
|
url?: string
|
2022-06-22 05:34:42 -04:00
|
|
|
phase?: string
|
2023-01-05 05:17:57 -05:00
|
|
|
}> = ({ tooltip, url = '/beta/participate', phase = 'beta' }) => {
|
2022-06-22 05:34:42 -04:00
|
|
|
let badgeClass
|
|
|
|
switch (phase) {
|
|
|
|
case 'release':
|
|
|
|
badgeClass = 'info-badge'
|
|
|
|
break
|
2022-07-25 08:33:39 -04:00
|
|
|
case 'alpha':
|
|
|
|
badgeClass = 'alpha-badge'
|
|
|
|
break
|
|
|
|
case 'beta':
|
2022-06-22 05:34:42 -04:00
|
|
|
default:
|
|
|
|
badgeClass = 'beta-badge'
|
|
|
|
}
|
|
|
|
|
2022-05-18 09:46:10 -04:00
|
|
|
return (
|
|
|
|
<Tooltip
|
|
|
|
id={tooltip.id}
|
|
|
|
description={tooltip.text}
|
|
|
|
tooltipProps={{ className: tooltip.className }}
|
|
|
|
overlayProps={{
|
|
|
|
placement: tooltip.placement || 'bottom',
|
|
|
|
delayHide: 100,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<a
|
|
|
|
href={url}
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
2023-01-05 05:17:57 -05:00
|
|
|
className={classnames('badge', badgeClass)}
|
2022-05-18 09:46:10 -04:00
|
|
|
>
|
|
|
|
<span className="sr-only">{tooltip.text}</span>
|
|
|
|
</a>
|
|
|
|
</Tooltip>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default BetaBadge
|