-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathsymbolDefinitionPreview.tsx
More file actions
57 lines (54 loc) · 1.86 KB
/
symbolDefinitionPreview.tsx
File metadata and controls
57 lines (54 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { Badge } from "@/components/ui/badge";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { LightweightCodeHighlighter } from "@/app/[domain]/components/lightweightCodeHighlighter";
import { useMemo } from "react";
import { SourceRange } from "@/features/search/types";
interface SymbolDefinitionPreviewProps {
symbolDefinition: {
lineContent: string;
language: string;
fileName: string;
repoName: string;
range: SourceRange;
};
}
export const SymbolDefinitionPreview = ({
symbolDefinition,
}: SymbolDefinitionPreviewProps) => {
const { lineContent, language, range } = symbolDefinition;
const highlightRanges = useMemo(() => [range], [range]);
return (
<div className="flex flex-col gap-2 mb-2">
<Tooltip
delayDuration={100}
>
<TooltipTrigger
disabled={true}
className="mr-auto"
>
<Badge
variant="outline"
className="w-fit h-fit flex-shrink-0 select-none"
>
Search Based
</Badge>
</TooltipTrigger>
<TooltipContent
side="top"
align="start"
>
Symbol definition found using a best-guess search heuristic.
</TooltipContent>
</Tooltip>
<LightweightCodeHighlighter
language={language}
highlightRanges={highlightRanges}
lineNumbers={false}
lineNumbersOffset={range.start.lineNumber}
renderWhitespace={false}
>
{lineContent}
</LightweightCodeHighlighter>
</div>
)
}