Skip to content

Commit

Permalink
Refactor search feature
Browse files Browse the repository at this point in the history
Signed-off-by: Damian Stasik <[email protected]>
  • Loading branch information
damianstasik committed Aug 29, 2024
1 parent 8b7d6bc commit f7aa6fb
Show file tree
Hide file tree
Showing 9 changed files with 298 additions and 244 deletions.
157 changes: 0 additions & 157 deletions frontend/src/components/Header/Search.tsx

This file was deleted.

75 changes: 0 additions & 75 deletions frontend/src/components/Header/hooks/useGroupedResults.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion frontend/src/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Icon } from "../Icon";
import { x } from "../../icons/x";
import { slack } from "../../icons/slack";
import { ThemeSwitcher } from "./ThemeSwitcher";
import { Search } from "./Search";
import { Search } from "../Search";

export function Header() {
return (
Expand Down
14 changes: 14 additions & 0 deletions frontend/src/components/Search/ModuleResult.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { SearchResult } from "./types";

interface SearchModuleResultProps {
result: SearchResult;
}

export function SearchModuleResult({ result }: SearchModuleResultProps) {
return (
<>
<div className="text-sm">{result.addr}</div>
<div className="text-xs text-gray-500">{result.description}</div>
</>
);
}
14 changes: 14 additions & 0 deletions frontend/src/components/Search/OtherResult.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { SearchResult } from "./types";

interface SearchOtherResultProps {
result: SearchResult;
}

export function SearchOtherResult({ result }: SearchOtherResultProps) {
return (
<>
<div className="text-sm">{result.addr}</div>
<div className="text-xs text-gray-500">{result.description}</div>
</>
);
}
40 changes: 40 additions & 0 deletions frontend/src/components/Search/ProviderResult.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { SearchResult, SearchResultType } from "./types";

interface SearchProviderResultProps {
result: SearchResult;
}

export function SearchProviderResult({ result }: SearchProviderResultProps) {
if (result.type === SearchResultType.ProviderResource) {
return (
<>
<div className="text-sm">Resource: {result.title}</div>
<div className="text-sm">{result.addr}</div>
<div className="text-xs text-gray-500">{result.description}</div>
</>
);
} else if (result.type === SearchResultType.ProviderDatasource) {
return (
<>
<div className="text-sm">Data source: {result.title}</div>
<div className="text-sm">{result.addr}</div>
<div className="text-xs text-gray-500">{result.description}</div>
</>
);
} else if (result.type === SearchResultType.ProviderFunction) {
return (
<>
<div className="text-sm">Function: {result.title}</div>
<div className="text-sm">{result.addr}</div>
<div className="text-xs text-gray-500">{result.description}</div>
</>
);
}

return (
<>
<div className="text-sm">{result.addr}</div>
<div className="text-xs text-gray-500">{result.description}</div>
</>
);
}
Loading

0 comments on commit f7aa6fb

Please sign in to comment.