Skip to content

Commit 229630c

Browse files
docs(examples): add InstantSearch example (#550)
1 parent d32d908 commit 229630c

File tree

15 files changed

+797
-4
lines changed

15 files changed

+797
-4
lines changed

.codesandbox/ci.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"^": "buildCommand is false because `yarn prepare` is going to build packages anyway.",
55
"sandboxes": [
66
"/examples/github-repositories-custom-plugin",
7+
"/examples/instantsearch",
78
"/examples/multiple-datasets-with-headers",
89
"/examples/playground",
910
"/examples/preview-panel-in-modal",

examples/instantsearch/README.md

Whitespace-only changes.

examples/instantsearch/env.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as preact from 'preact';
2+
3+
// Parcel picks the `source` field of the monorepo packages and thus doesn't
4+
// apply the Babel config. We therefore need to manually override the constants
5+
// in the app, as well as the React pragmas.
6+
// See https://twitter.com/devongovett/status/1134231234605830144
7+
(global as any).__DEV__ = process.env.NODE_ENV !== 'production';
8+
(global as any).__TEST__ = false;
9+
(global as any).h = preact.h;
10+
(global as any).React = preact;

examples/instantsearch/favicon.png

228 KB
Loading

examples/instantsearch/index.html

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<html lang="en">
2+
<head>
3+
<meta charset="UTF-8" />
4+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
5+
6+
<link rel="shortcut icon" href="favicon.png" type="image/x-icon" />
7+
<link
8+
rel="stylesheet"
9+
href="https://unpkg.com/instantsearch.css@7/themes/satellite-min.css"
10+
/>
11+
12+
<title>InstantSearch | Autocomplete</title>
13+
</head>
14+
15+
<body>
16+
<header class="header">
17+
<div class="header-wrapper wrapper">
18+
<nav class="header-nav">
19+
<a href="/">Home</a>
20+
</nav>
21+
<div id="autocomplete"></div>
22+
</div>
23+
</header>
24+
25+
<div class="container wrapper">
26+
<div>
27+
<div id="categories"></div>
28+
</div>
29+
<div>
30+
<img src="iphone-banner.png" alt="iPhone banner" class="banner" />
31+
32+
<div id="hits"></div>
33+
<div id="pagination"></div>
34+
</div>
35+
</div>
36+
37+
<script src="env.ts"></script>
38+
<script src="src/app.ts"></script>
39+
</body>
40+
</html>
101 KB
Loading

examples/instantsearch/package.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "@algolia/autocomplete-example-instantsearch",
3+
"description": "Autocomplete with InstantSearch example",
4+
"version": "1.0.0-alpha.46",
5+
"private": true,
6+
"license": "MIT",
7+
"scripts": {
8+
"build": "parcel build index.html",
9+
"start": "parcel index.html"
10+
},
11+
"dependencies": {
12+
"@algolia/autocomplete-js": "1.0.0-alpha.46",
13+
"@algolia/autocomplete-plugin-query-suggestions": "1.0.0-alpha.46",
14+
"@algolia/autocomplete-plugin-recent-searches": "1.0.0-alpha.46",
15+
"@algolia/autocomplete-theme-classic": "1.0.0-alpha.46",
16+
"@algolia/client-search": "4.9.0",
17+
"algoliasearch": "4.9.0",
18+
"instantsearch.js": "4.21.0",
19+
"preact": "10.5.13"
20+
},
21+
"devDependencies": {
22+
"parcel": "2.0.0-beta.2"
23+
},
24+
"keywords": [
25+
"algolia",
26+
"autocomplete",
27+
"javascript"
28+
]
29+
}

examples/instantsearch/src/app.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import '@algolia/autocomplete-theme-classic';
2+
import '../style.css';
3+
4+
import { startAutocomplete } from './autocomplete';
5+
import { search } from './instantsearch';
6+
7+
search.start();
8+
startAutocomplete();

0 commit comments

Comments
 (0)