({
user,
tooltip = true,
clickable = true,
size = IconSize.Size16,
}: Props)
| 21 | }; |
| 22 | |
| 23 | export const PlusUserBadge = ({ |
| 24 | user, |
| 25 | tooltip = true, |
| 26 | clickable = true, |
| 27 | size = IconSize.Size16, |
| 28 | }: Props): ReactElement | null => { |
| 29 | const { isPlus, logSubscriptionEvent } = usePlusSubscription(); |
| 30 | const { logPreviewOpen, logPreviewAction } = usePlusPreviewLog( |
| 31 | TargetId.PlusBadge, |
| 32 | ); |
| 33 | |
| 34 | if (!user.isPlus) { |
| 35 | return null; |
| 36 | } |
| 37 | |
| 38 | const badge = <PlusUser withText={false} iconSize={size} />; |
| 39 | const memberSince = ( |
| 40 | <DateFormat |
| 41 | prefix="Plus member since " |
| 42 | date={user.plusMemberSince} |
| 43 | type={TimeFormatType.PlusMember} |
| 44 | /> |
| 45 | ); |
| 46 | |
| 47 | if (!tooltip) { |
| 48 | return <div className="flex items-center">{badge}</div>; |
| 49 | } |
| 50 | |
| 51 | if (isPlus) { |
| 52 | return ( |
| 53 | <SimpleTooltip content={memberSince} placement="top"> |
| 54 | <div className="flex items-center">{badge}</div> |
| 55 | </SimpleTooltip> |
| 56 | ); |
| 57 | } |
| 58 | |
| 59 | const logUpgradeClick = () => |
| 60 | logSubscriptionEvent({ |
| 61 | event_name: LogEvent.UpgradeSubscription, |
| 62 | target_id: TargetId.PlusBadge, |
| 63 | }); |
| 64 | |
| 65 | return ( |
| 66 | <PlusPreview |
| 67 | side="bottom" |
| 68 | onOpen={logPreviewOpen} |
| 69 | onAction={logPreviewAction} |
| 70 | context={ |
| 71 | <span className="text-text-tertiary typo-footnote">{memberSince}</span> |
| 72 | } |
| 73 | > |
| 74 | {clickable ? ( |
| 75 | <span className="flex items-center"> |
| 76 | <Link href={plusUrl} passHref> |
| 77 | <a |
| 78 | href={plusUrl} |
| 79 | aria-label="Plus member" |
| 80 | className="focus-outline flex items-center rounded-6" |
nothing calls this directly
no test coverage detected