This repository was archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
svelte: Refactor search results page (#59029)
My main goal was to add an empty state for the search results page, but I took the opportunity to adopt/test some of Taiyab's ideas for the search results page (left sidebar with type filters, more condense results display). It's only a crude approximation since his work is still in flux. It wasn't the goal to strictly follow the design.
- Loading branch information
Showing
25 changed files
with
317 additions
and
263 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 |
---|---|---|
|
@@ -20,3 +20,4 @@ yarn.lock | |
*.gql.d.ts | ||
src/lib/graphql-operations.ts | ||
src/lib/graphql-types.ts | ||
static/mockServiceWorker.js |
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
Empty file.
File renamed without changes.
69 changes: 0 additions & 69 deletions
69
client/web-sveltekit/src/lib/search/QueryExampleChip.svelte
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,26 +1,71 @@ | ||
import type { SidebarFilter } from './utils' | ||
import { | ||
mdiCodeTags, | ||
mdiFileCodeOutline, | ||
mdiPlusMinus, | ||
mdiShapeOutline, | ||
mdiSourceCommit, | ||
mdiSourceRepository, | ||
} from '@mdi/js' | ||
|
||
export const searchTypes: SidebarFilter[] = [ | ||
import { FilterKind, FilterType, appendFilter, findFilter, updateFilter } from '$lib/shared' | ||
|
||
function addOrUpdateTypeFilter(value: string): (query: string) => string { | ||
return query => { | ||
try { | ||
return updateFilter(query, FilterType.type, value) | ||
} catch { | ||
// Ignore error | ||
} | ||
return appendFilter(query, FilterType.type, value) | ||
} | ||
} | ||
|
||
function isSelectedTypeFilter(value: string): (query: string) => boolean { | ||
return query => findFilter(query, FilterType.type, FilterKind.Global)?.value?.value === value | ||
} | ||
|
||
interface ResultTypeFilter { | ||
label: string | ||
icon: string | ||
getQuery: (query: string) => string | ||
isSelected: (query: string) => boolean | ||
} | ||
|
||
export const resultTypeFilter: ResultTypeFilter[] = [ | ||
{ | ||
label: 'Code', | ||
icon: mdiCodeTags, | ||
getQuery: addOrUpdateTypeFilter('file'), | ||
isSelected: isSelectedTypeFilter('file'), | ||
}, | ||
{ | ||
label: 'Repositories', | ||
icon: mdiSourceRepository, | ||
getQuery: addOrUpdateTypeFilter('repo'), | ||
isSelected: isSelectedTypeFilter('repo'), | ||
}, | ||
{ | ||
label: 'Search repos by org or name', | ||
value: 'repo:', | ||
kind: 'utility', | ||
label: 'Paths', | ||
icon: mdiFileCodeOutline, | ||
getQuery: addOrUpdateTypeFilter('path'), | ||
isSelected: isSelectedTypeFilter('path'), | ||
}, | ||
{ | ||
label: 'Find a symbol', | ||
value: 'type:symbol', | ||
kind: 'utility', | ||
runImmediately: true, | ||
label: 'Symbols', | ||
icon: mdiShapeOutline, | ||
getQuery: addOrUpdateTypeFilter('symbol'), | ||
isSelected: isSelectedTypeFilter('symbol'), | ||
}, | ||
{ | ||
label: 'Search diffs', | ||
value: 'type:diff', | ||
kind: 'utility', | ||
runImmediately: true, | ||
label: 'Commits', | ||
icon: mdiSourceCommit, | ||
getQuery: addOrUpdateTypeFilter('commit'), | ||
isSelected: isSelectedTypeFilter('commit'), | ||
}, | ||
{ | ||
label: 'Search commit message', | ||
value: 'type:commit', | ||
kind: 'utility', | ||
label: 'Diffs', | ||
icon: mdiPlusMinus, | ||
getQuery: addOrUpdateTypeFilter('diff'), | ||
isSelected: isSelectedTypeFilter('diff'), | ||
}, | ||
] |
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
Oops, something went wrong.