-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/Nil2000/morphic
- Loading branch information
Showing
8 changed files
with
110 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
'use client' | ||
|
||
import { SearchResults } from './search-results' | ||
import { SearchSkeleton } from './search-skeleton' | ||
import { SearchResultsImageSection } from './search-results-image' | ||
import { Section } from './section' | ||
import { ToolBadge } from './tool-badge' | ||
import type { SearchResults as TypeSearchResults } from '@/lib/types' | ||
import { StreamableValue, useStreamableValue } from 'ai/rsc' | ||
|
||
export type SearchSectionProps = { | ||
result?: StreamableValue<string> | ||
} | ||
|
||
export function SearchSection({ result }: SearchSectionProps) { | ||
const [data, error, pending] = useStreamableValue(result) | ||
const results: TypeSearchResults = data ? JSON.parse(data) : undefined | ||
return ( | ||
<div> | ||
{!pending && data ? ( | ||
<> | ||
<Section size="sm" className="pt-2 pb-0"> | ||
<ToolBadge tool="search">{`${results.query}`}</ToolBadge> | ||
</Section> | ||
{results.images && results.images.length > 0 && ( | ||
<Section title="Images"> | ||
<SearchResultsImageSection | ||
images={results.images} | ||
query={results.query} | ||
/> | ||
</Section> | ||
)} | ||
<Section title="Results"> | ||
<SearchResults results={results.results} /> | ||
</Section> | ||
</> | ||
) : ( | ||
<Section className="pt-2 pb-0"> | ||
<SearchSkeleton /> | ||
</Section> | ||
)} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export type SearchResults = { | ||
images: string[] | ||
results: SearchResultItem[] | ||
query: string | ||
} | ||
|
||
export type SearchResultItem = { | ||
title: string | ||
url: string | ||
content: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters