-
Notifications
You must be signed in to change notification settings - Fork 337
Expand file tree
/
Copy pathapp.tsx
More file actions
58 lines (54 loc) · 1.51 KB
/
app.tsx
File metadata and controls
58 lines (54 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/** @jsx h */
import { autocomplete } from '@algolia/autocomplete-js';
import {
NavigationCommands,
SearchByAlgolia,
} from '@algolia/autocomplete-layout-classic';
import { createQuerySuggestionsPlugin } from '@algolia/autocomplete-plugin-query-suggestions';
import algoliasearch from 'algoliasearch/lite';
import { h, render } from 'preact';
import '@algolia/autocomplete-theme-classic';
const appId = 'latency';
const apiKey = '6be0576ff61c053d5f9a3225e2a90f76';
const searchClient = algoliasearch(appId, apiKey);
const querySuggestionsPlugin = createQuerySuggestionsPlugin({
searchClient,
indexName: 'instant_search_demo_query_suggestions',
getSearchParams() {
return {
hitsPerPage: 10,
};
},
});
autocomplete({
container: '#autocomplete',
placeholder: 'Search',
openOnFocus: true,
plugins: [querySuggestionsPlugin],
components: {
NavigationCommands,
SearchByAlgolia,
},
render({ sections, Fragment, components }, root) {
render(
<Fragment>
<div className="aa-PanelLayout aa-Panel--scrollable">{sections}</div>
<footer className="aa-PanelFooter">
<components.NavigationCommands
translations={{
toClose: 'pour fermer',
toNavigate: 'pour naviguer',
toSelect: 'pour sélectionner',
}}
/>
<components.SearchByAlgolia
translations={{
searchBy: 'Recherche par',
}}
/>
</footer>
</Fragment>,
root
);
},
});