-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react): add multi-index hits example
- Loading branch information
Showing
14 changed files
with
7,599 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
extends: 'algolia/react', | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# See https://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"singleQuote": true, | ||
"proseWrap": "never", | ||
"trailingComma": "es5" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# multi-index-hits | ||
|
||
_This project was generated with [create-instantsearch-app](https://github.com/algolia/create-instantsearch-app) by [Algolia](https://algolia.com)._ | ||
|
||
## Get started | ||
|
||
To run this project locally, install the dependencies and run the local server: | ||
|
||
```sh | ||
npm install | ||
npm start | ||
``` | ||
|
||
Alternatively, you may use [Yarn](https://http://yarnpkg.com/): | ||
|
||
```sh | ||
yarn | ||
yarn start | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "multi-index-hits", | ||
"version": "1.0.0", | ||
"private": true, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"lint": "eslint .", | ||
"lint:fix": "npm run lint -- --fix" | ||
}, | ||
"dependencies": { | ||
"react": "16.4.1", | ||
"react-dom": "16.4.1", | ||
"react-instantsearch-dom": "5.2.2", | ||
"react-scripts": "1.1.4" | ||
}, | ||
"devDependencies": { | ||
"eslint": "4.19.1", | ||
"eslint-config-algolia": "13.1.0", | ||
"eslint-config-prettier": "2.9.0", | ||
"eslint-plugin-import": "2.13.0", | ||
"eslint-plugin-prettier": "2.6.1", | ||
"eslint-plugin-react": "7.10.0", | ||
"prettier": "1.13.5", | ||
"prop-types": "15.6.2" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
<meta name="theme-color" content="#000000"> | ||
|
||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json"> | ||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.png"> | ||
|
||
<!-- | ||
Do not use @7 in production, use a complete version like x.x.x, see website for latest version: | ||
https://community.algolia.com/react-instantsearch/Getting_started.html#load-the-algolia-theme | ||
--> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/instantsearch.css@7/themes/algolia-min.css"> | ||
|
||
<title>multi-index-hits</title> | ||
</head> | ||
|
||
<body> | ||
<noscript> | ||
You need to enable JavaScript to run this app. | ||
</noscript> | ||
|
||
<div id="root"></div> | ||
</body> | ||
|
||
</html> |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"short_name": "multi-index-hits", | ||
"name": "multi-index-hits Sample", | ||
"icons": [ | ||
{ | ||
"src": "favicon.png", | ||
"sizes": "64x64 32x32 24x24 16x16", | ||
"type": "image/x-icon" | ||
} | ||
], | ||
"start_url": "./index.html", | ||
"display": "standalone", | ||
"theme_color": "#000000", | ||
"background_color": "#ffffff" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
h1 { | ||
margin-bottom: 1rem; | ||
} | ||
|
||
em { | ||
background: cyan; | ||
font-style: normal; | ||
} | ||
|
||
.ais-InstantSearch__root { | ||
max-width: 1200px; | ||
margin: 0 auto; | ||
padding: 1rem; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React, { Component } from 'react'; | ||
import { | ||
InstantSearch, | ||
Index, | ||
Hits, | ||
SearchBox, | ||
Highlight, | ||
} from 'react-instantsearch-dom'; | ||
import PropTypes from 'prop-types'; | ||
import './App.css'; | ||
|
||
class App extends Component { | ||
render() { | ||
return ( | ||
<InstantSearch | ||
appId="latency" | ||
apiKey="6be0576ff61c053d5f9a3225e2a90f76" | ||
indexName="instant_search" | ||
> | ||
<h1>React InstantSearch - Hits from multiple indices</h1> | ||
|
||
<SearchBox /> | ||
|
||
<Index indexName="instant_search"> | ||
<h2> | ||
index: <code>instant_search</code> | ||
</h2> | ||
<Hits hitComponent={Hit} /> | ||
</Index> | ||
|
||
<Index indexName="bestbuy"> | ||
<h2> | ||
index: <code>bestbuy</code> | ||
</h2> | ||
<Hits hitComponent={Hit} /> | ||
</Index> | ||
</InstantSearch> | ||
); | ||
} | ||
} | ||
|
||
function Hit(props) { | ||
return ( | ||
<div> | ||
<Highlight attribute="name" hit={props.hit} /> | ||
</div> | ||
); | ||
} | ||
|
||
Hit.propTypes = { | ||
hit: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default App; |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
body, | ||
h1 { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
body { | ||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, | ||
Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import './index.css'; | ||
import App from './App'; | ||
|
||
ReactDOM.render(<App />, document.getElementById('root')); |
Oops, something went wrong.