mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-12 12:25:22 +00:00
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
|
|
'use client';
|
||
|
|
|
||
|
|
import { ScrollArea } from "@/components/ui/scroll-area";
|
||
|
|
import { Scrollbar } from "@radix-ui/react-scroll-area";
|
||
|
|
import { FileMatchContainer } from "./fileMatchContainer";
|
||
|
|
import { SearchResultFile } from "@/lib/types";
|
||
|
|
|
||
|
|
interface SearchResultsPanelProps {
|
||
|
|
fileMatches: SearchResultFile[];
|
||
|
|
onOpenFileMatch: (fileMatch: SearchResultFile) => void;
|
||
|
|
onMatchIndexChanged: (matchIndex: number) => void;
|
||
|
|
}
|
||
|
|
|
||
|
|
export const SearchResultsPanel = ({
|
||
|
|
fileMatches,
|
||
|
|
onOpenFileMatch,
|
||
|
|
onMatchIndexChanged,
|
||
|
|
}: SearchResultsPanelProps) => {
|
||
|
|
|
||
|
|
if (fileMatches.length === 0) {
|
||
|
|
return (
|
||
|
|
<div className="flex flex-col items-center justify-center h-full">
|
||
|
|
<p className="text-sm text-muted-foreground">No results found</p>
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
return (
|
||
|
|
<ScrollArea
|
||
|
|
className="h-full"
|
||
|
|
>
|
||
|
|
{fileMatches.map((fileMatch, index) => (
|
||
|
|
<FileMatchContainer
|
||
|
|
key={index}
|
||
|
|
file={fileMatch}
|
||
|
|
onOpenFile={() => {
|
||
|
|
onOpenFileMatch(fileMatch);
|
||
|
|
}}
|
||
|
|
onMatchIndexChanged={(matchIndex) => {
|
||
|
|
onMatchIndexChanged(matchIndex);
|
||
|
|
}}
|
||
|
|
/>
|
||
|
|
))}
|
||
|
|
<Scrollbar orientation="vertical" />
|
||
|
|
</ScrollArea>
|
||
|
|
)
|
||
|
|
}
|