66
77import { User } from "@gitpod/gitpod-protocol" ;
88import React , { useContext , useEffect , useState } from "react" ;
9+ import { Link } from "react-router-dom" ;
910import { getGitpodService } from "../service/service" ;
1011import { UserContext } from "../user-context" ;
1112
@@ -80,9 +81,18 @@ export default function RepositoryFinder(props: { initialQuery?: string }) {
8081 < div className = "py-4" >
8182 < svg xmlns = "http://www.w3.org/2000/svg" fill = "none" viewBox = "0 0 16 16" width = "16" height = "16" > < path fill = "#A8A29E" d = "M6 2a4 4 0 100 8 4 4 0 000-8zM0 6a6 6 0 1110.89 3.477l4.817 4.816a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 010 6z" /> </ svg >
8283 </ div >
83- < input type = "search" className = "flex-grow" placeholder = "Repository " autoFocus value = { searchQuery } onChange = { e => search ( e . target . value ) } onKeyDown = { onKeyDown } />
84+ < input type = "search" className = "flex-grow" placeholder = "Search repositories and examples " autoFocus value = { searchQuery } onChange = { e => search ( e . target . value ) } onKeyDown = { onKeyDown } />
8485 </ div >
85- < div className = "mt-3 flex flex-col space-y-2 h-64 overflow-y-auto" id = "search-results" >
86+ < div className = "mt-3 -mx-5 px-5 flex flex-col space-y-2 h-64 overflow-y-auto" >
87+ { searchQuery === '' && searchResults . length === 0 &&
88+ < div className = "mt-12 mx-auto w-96 text-gray-500" >
89+ Paste a < a className = "gp-link" href = "https://www.gitpod.io/docs/context-urls" > repository context URL</ a > , or start typing to see suggestions from:
90+ < ul className = "list-disc mt-4 pl-7 flex flex-col space-y-1" >
91+ < li > Your recent repositories</ li >
92+ < li > Your repositories from < Link className = "gp-link" to = "/integrations" > connected integrations</ Link > </ li >
93+ < li > Example repositories</ li >
94+ </ ul >
95+ </ div > }
8696 { searchResults . slice ( 0 , MAX_DISPLAYED_ITEMS ) . map ( ( result , index ) =>
8797 < a className = { `px-4 py-3 rounded-xl` + ( result === selectedSearchResult ? ' bg-gray-600 text-gray-50 dark:bg-gray-700' : '' ) } href = { `/#${ result } ` } key = { `search-result-${ index } ` } onMouseEnter = { ( ) => setSelectedSearchResult ( result ) } >
8898 { searchQuery . length < 2
@@ -94,7 +104,7 @@ export default function RepositoryFinder(props: { initialQuery?: string }) {
94104 </ a >
95105 ) }
96106 { searchResults . length > MAX_DISPLAYED_ITEMS &&
97- < span className = "mt-3 px-4 py-2 italic text-sm" > { searchResults . length - MAX_DISPLAYED_ITEMS } results not shown </ span > }
107+ < span className = "mt-3 px-4 py-2 text-sm text-gray-400 dark:text-gray-500 " > { searchResults . length - MAX_DISPLAYED_ITEMS } more results found </ span > }
98108 </ div >
99109 </ form > ;
100110}
@@ -157,5 +167,5 @@ async function findResults(query: string, onResults: (results: string[]) => void
157167 } catch {
158168 }
159169 // console.log('searching', query, 'in', searchData);
160- onResults ( searchData . filter ( result => result . includes ( query ) ) ) ;
170+ onResults ( searchData . filter ( result => result . toLowerCase ( ) . includes ( query . toLowerCase ( ) ) ) ) ;
161171}
0 commit comments