2023-01-05 05:17:57 -05:00
|
|
|
import type { FC, ReactNode } from 'react'
|
|
|
|
import classnames from 'classnames'
|
2024-09-30 04:11:26 -04:00
|
|
|
import OLTooltip from '@/features/ui/components/ol/ol-tooltip'
|
|
|
|
import MaterialIcon from '@/shared/components/material-icon'
|
|
|
|
import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
|
2024-11-14 06:50:20 -05:00
|
|
|
import { bsVersion } from '@/features/utils/bootstrap-5'
|
2022-05-18 09:46:10 -04:00
|
|
|
|
|
|
|
type TooltipProps = {
|
|
|
|
id: string
|
2023-01-05 05:17:57 -05:00
|
|
|
text: ReactNode
|
2022-05-18 09:46:10 -04:00
|
|
|
className?: string
|
2024-09-30 04:11:26 -04:00
|
|
|
placement?: NonNullable<
|
|
|
|
React.ComponentProps<typeof OLTooltip>['overlayProps']
|
|
|
|
>['placement']
|
2022-05-18 09:46:10 -04:00
|
|
|
}
|
|
|
|
|
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' }) => {
|
2024-10-08 04:25:49 -04:00
|
|
|
const badgeClass = chooseBadgeClass(phase)
|
2022-05-18 09:46:10 -04:00
|
|
|
return (
|
2024-09-30 04:11:26 -04:00
|
|
|
<OLTooltip
|
2022-05-18 09:46:10 -04:00
|
|
|
id={tooltip.id}
|
|
|
|
description={tooltip.text}
|
|
|
|
tooltipProps={{ className: tooltip.className }}
|
|
|
|
overlayProps={{
|
|
|
|
placement: tooltip.placement || 'bottom',
|
2024-09-30 04:11:26 -04:00
|
|
|
delay: 100,
|
2022-05-18 09:46:10 -04:00
|
|
|
}}
|
|
|
|
>
|
2024-09-30 04:11:26 -04:00
|
|
|
<a href={url} target="_blank" rel="noopener noreferrer">
|
2024-11-14 06:50:20 -05:00
|
|
|
<span className={bsVersion({ bs5: 'visually-hidden', bs3: 'sr-only' })}>
|
|
|
|
{tooltip.text}
|
|
|
|
</span>
|
2024-09-30 04:11:26 -04:00
|
|
|
<BootstrapVersionSwitcher
|
|
|
|
bs3={<span className={classnames('badge', badgeClass)} />}
|
|
|
|
bs5={
|
|
|
|
<MaterialIcon
|
|
|
|
type="info"
|
|
|
|
className={classnames('align-middle', badgeClass)}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
/>
|
2022-05-18 09:46:10 -04:00
|
|
|
</a>
|
2024-09-30 04:11:26 -04:00
|
|
|
</OLTooltip>
|
2022-05-18 09:46:10 -04:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2024-10-08 04:25:49 -04:00
|
|
|
export const chooseBadgeClass = (phase?: string) => {
|
|
|
|
switch (phase) {
|
|
|
|
case 'release':
|
|
|
|
return 'info-badge'
|
|
|
|
case 'alpha':
|
|
|
|
return 'alpha-badge'
|
|
|
|
case 'beta':
|
|
|
|
default:
|
|
|
|
return 'beta-badge'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-18 09:46:10 -04:00
|
|
|
export default BetaBadge
|