Skip to content

Commit

Permalink
feat(react): add multi-index hits example
Browse files Browse the repository at this point in the history
  • Loading branch information
samouss committed Jul 16, 2018
1 parent f0b5e22 commit 02c22b3
Show file tree
Hide file tree
Showing 14 changed files with 7,599 additions and 0 deletions.
9 changes: 9 additions & 0 deletions React InstantSearch/multi-index-hits/.editorconfig
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
3 changes: 3 additions & 0 deletions React InstantSearch/multi-index-hits/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: 'algolia/react',
};
21 changes: 21 additions & 0 deletions React InstantSearch/multi-index-hits/.gitignore
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*
5 changes: 5 additions & 0 deletions React InstantSearch/multi-index-hits/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"proseWrap": "never",
"trailingComma": "es5"
}
19 changes: 19 additions & 0 deletions React InstantSearch/multi-index-hits/README.md
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
```
27 changes: 27 additions & 0 deletions React InstantSearch/multi-index-hits/package.json
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.
29 changes: 29 additions & 0 deletions React InstantSearch/multi-index-hits/public/index.html
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>
15 changes: 15 additions & 0 deletions React InstantSearch/multi-index-hits/public/manifest.json
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"
}
14 changes: 14 additions & 0 deletions React InstantSearch/multi-index-hits/src/App.css
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;
}
54 changes: 54 additions & 0 deletions React InstantSearch/multi-index-hits/src/App.js
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;
10 changes: 10 additions & 0 deletions React InstantSearch/multi-index-hits/src/index.css
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';
}
6 changes: 6 additions & 0 deletions React InstantSearch/multi-index-hits/src/index.js
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'));
Loading

0 comments on commit 02c22b3

Please sign in to comment.