AnnotatedSpan() — supabase Function Reference
Architecture documentation for the AnnotatedSpan() function in CodeBlock.client.tsx from the supabase codebase.
Entity Profile
Relationship Graph
Source Code
apps/docs/features/ui/CodeBlock/CodeBlock.client.tsx lines 10–64
export function AnnotatedSpan({
token,
annotations,
}: {
token: ThemedToken
annotations: Array<NodeHover>
}) {
const [open, setOpen] = useState(false)
const [isTouchDevice, setIsTouchDevice] = useState(false)
useEffect(() => {
const touchDevice = !window.matchMedia('(pointer: fine)').matches
setIsTouchDevice(touchDevice)
}, [])
const handleClick = useCallback(
(evt: MouseEvent) => {
if (isTouchDevice) {
evt.preventDefault()
evt.stopPropagation()
setOpen((open) => !open)
}
},
[isTouchDevice]
)
const onOpenChange = useCallback(
(open: boolean) => {
if (!isTouchDevice || !open) {
setOpen(open)
}
},
[isTouchDevice]
)
return (
<Tooltip open={open} onOpenChange={onOpenChange}>
<TooltipTrigger asChild onClick={handleClick}>
<button
style={token.htmlStyle}
className={cn(
isTouchDevice &&
'underline underline-offset-4 decoration-dashed [text-decoration-color:rgba(from_currentColor_r_g_b_/_0.5)]'
)}
>
{token.content}
</button>
</TooltipTrigger>
<TooltipContent className="max-w-[min(80vw,400px)] p-0 divide-y">
{annotations.map((annotation, idx) => (
<Annotation key={idx} annotation={annotation} />
))}
</TooltipContent>
</Tooltip>
)
}
Domain
Subdomains
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free