sourcebot/src/app/search/components/searchResultsPanel/index.tsx

47 lines
1.4 KiB
TypeScript
Raw Normal View History

'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>
)
}