Skip to content

Commit

Permalink
feat(docsearch): allow placeholder customization
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour committed Apr 10, 2020
1 parent cb35ea6 commit 7d62c6f
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/DocSearch.tsx
Expand Up @@ -27,6 +27,7 @@ interface DocSearchProps
appId?: string;
apiKey: string;
indexName: string;
placeholder?: string;
searchParameters?: any;
onClose?(): void;
transformItems?(items: DocSearchHit[]): DocSearchHit[];
Expand All @@ -40,6 +41,7 @@ export function DocSearch({
appId = 'BH4D9OD16A',
apiKey,
indexName,
placeholder = 'Search docs',
searchParameters,
onClose = noop,
transformItems = x => x,
Expand Down Expand Up @@ -112,7 +114,7 @@ export function DocSearch({
id: 'docsearch',
defaultHighlightedIndex: 0,
autoFocus: true,
placeholder: 'Search docs',
placeholder,
openOnFocus: true,
initialState: {
query: initialQuery,
Expand Down Expand Up @@ -267,6 +269,7 @@ export function DocSearch({
favoriteSearches,
saveRecentSearch,
initialQuery,
placeholder,
navigator,
transformItems,
]
Expand Down Expand Up @@ -310,20 +313,19 @@ export function DocSearch({
return (
<div
ref={containerRef}
{...getRootProps({})}
className={[
'DocSearch-Container',
state.status === 'stalled' && 'DocSearch-Container--Stalled',
state.status === 'error' && 'DocSearch-Container--Errored',
]
.filter(Boolean)
.join(' ')}
{...getRootProps({
onClick(event: React.MouseEvent) {
if (event.target === event.currentTarget) {
onClose();
}
},
})}
onClick={event => {
if (event.target === event.currentTarget) {
onClose();
}
}}
>
<div className="DocSearch-Modal">
<header className="DocSearch-SearchBar" ref={searchBoxRef}>
Expand Down

0 comments on commit 7d62c6f

Please sign in to comment.