import {InfoOutlineIcon} from '@sanity/icons' import {APIReleaseTag} from '@sanity/tsdoc' import {Box, Card, CardTone, Flex, Text, Tooltip} from '@sanity/ui' import {useMemo} from 'react' import {useTextSize} from '../lib/ui' import {ReleaseBadgeTextWrapper} from './ReleaseBadgeTextWrapper' import {UnformattedCode} from './UnformattedCode' export function ReleaseBadge(props: { padding?: number radius?: number releaseTag?: APIReleaseTag }): React.ReactNode { const {padding = 1, radius = 2, releaseTag} = props const releaseTone: CardTone = useMemo(() => { if (releaseTag === 'alpha') return 'primary' if (releaseTag === 'beta') return 'caution' if (releaseTag === 'public') return 'positive' return 'primary' }, [releaseTag]) const explanation: string = useMemo(() => { if (releaseTag === 'alpha' || releaseTag === 'experimental') return `The API is in very early stages of development. Breaking changes are not only expected but very likely.\n We strongly recommend against using it in a production environment.` if (releaseTag === 'beta') return `The API is in a testing phase and is considered immature. Breaking changes are expected.\n We don't recommend using it in a production environment.` if (releaseTag === 'public') return 'The API is public and stable.' return 'primary' }, [releaseTag]) return ( <> {`@${releaseTag || 'public'}`} {explanation} } fallbackPlacements={['bottom', 'top', 'left']} placement="right" portal > ) }