import {LegacyLayerProvider, UserAvatar} from '@sanity/base/components' import {useUser, useTimeAgo} from '@sanity/base/hooks' import {Path} from '@sanity/types' import React from 'react' import {Tooltip, TooltipProps, Text, Stack, Flex, Inline, Label} from '@sanity/ui' import {Diff, getAnnotationAtPath} from '../../diff' import {AnnotationDetails} from '../../types' import {useAnnotationColor} from '../annotations' interface DiffTooltipProps extends TooltipProps { children: React.ReactElement description?: React.ReactNode diff: Diff path?: Path | string } interface DiffTooltipWithAnnotationsProps extends TooltipProps { annotations: AnnotationDetails[] children: React.ReactElement description?: React.ReactNode } export function DiffTooltip(props: DiffTooltipProps | DiffTooltipWithAnnotationsProps) { if ('diff' in props) { const {diff, path = [], ...restProps} = props const annotation = getAnnotationAtPath(diff, path) return } return } function DiffTooltipWithAnnotation(props: DiffTooltipWithAnnotationsProps) { const {annotations, children, description = 'Changed', ...restProps} = props if (!annotations) { return children } const content = ( {annotations.map((annotation, idx) => ( ))} ) return ( {children} ) } function AnnotationItem({annotation}: {annotation: AnnotationDetails}) { const {author, timestamp} = annotation const {error, value: user} = useUser(author) const color = useAnnotationColor(annotation) const timeAgo = useTimeAgo(timestamp, {minimal: true}) // @todo handle? if (error) { return null } return ( {user ? user.displayName : 'Loading…'} {timeAgo} ) }