6
6
7
7
import { User } from "@gitpod/gitpod-protocol" ;
8
8
import React , { useContext , useEffect , useState } from "react" ;
9
+ import { Link } from "react-router-dom" ;
9
10
import { getGitpodService } from "../service/service" ;
10
11
import { UserContext } from "../user-context" ;
11
12
@@ -80,9 +81,18 @@ export default function RepositoryFinder(props: { initialQuery?: string }) {
80
81
< div className = "py-4" >
81
82
< 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 >
82
83
</ 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 } />
84
85
</ 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 > }
86
96
{ searchResults . slice ( 0 , MAX_DISPLAYED_ITEMS ) . map ( ( result , index ) =>
87
97
< 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 ) } >
88
98
{ searchQuery . length < 2
@@ -94,7 +104,7 @@ export default function RepositoryFinder(props: { initialQuery?: string }) {
94
104
</ a >
95
105
) }
96
106
{ 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 > }
98
108
</ div >
99
109
</ form > ;
100
110
}
@@ -157,5 +167,5 @@ async function findResults(query: string, onResults: (results: string[]) => void
157
167
} catch {
158
168
}
159
169
// console.log('searching', query, 'in', searchData);
160
- onResults ( searchData . filter ( result => result . includes ( query ) ) ) ;
170
+ onResults ( searchData . filter ( result => result . toLowerCase ( ) . includes ( query . toLowerCase ( ) ) ) ) ;
161
171
}
0 commit comments