Skip to content

Commit 40a13a7

Browse files
committed
Upgrade playgrounds to include keepZeroFacets and multi-index
1 parent 9b13454 commit 40a13a7

File tree

3 files changed

+69
-4
lines changed

3 files changed

+69
-4
lines changed

tests/env/react/src/App.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react'
22
import { Routes, Route, Outlet } from 'react-router-dom'
33
import SingleIndex from './components/SingleIndex'
44
import MultiIndex from './components/MultiIndex'
5+
import SingleMovieIndex from './components/SingleMovieIndex'
56

67
import './App.css'
78

@@ -11,6 +12,7 @@ const App = () => {
1112
<Routes>
1213
<Route path="/" element={<SingleIndex />} />
1314
<Route path="multi-index" element={<MultiIndex />} />
15+
<Route path="movie-index" element={<SingleMovieIndex />} />
1416
</Routes>
1517
<Outlet />
1618
</div>

tests/env/react/src/components/MultiIndex.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ import {
66
Highlight,
77
RefinementList,
88
Index,
9-
Hits,
9+
InfiniteHits,
1010
Pagination,
11+
Hits,
1112
} from 'react-instantsearch-dom'
1213
import { instantMeiliSearch } from '../../../../../src/index'
1314

1415
const searchClient = instantMeiliSearch('http://localhost:7700', 'masterKey', {
1516
primaryKey: 'id',
1617
finitePagination: true,
18+
keepZeroFacets: true,
1719
})
1820

1921
const Hit = ({ hit }) => {
@@ -40,7 +42,7 @@ const MultiIndex = () => (
4042
<h2 style={{ margin: 0 }}>Genres</h2>
4143
<RefinementList attribute="genres" />
4244
<h2 style={{ margin: 0 }}>Color</h2>
43-
<RefinementList attribute="color" />
45+
<RefinementList attribute="color" operator="and" />
4446
<h2 style={{ margin: 0 }}>Platforms</h2>
4547
<RefinementList attribute="platforms" />
4648
</div>
@@ -62,9 +64,8 @@ const MultiIndex = () => (
6264
<RefinementList attribute="platforms" />
6365
</div>
6466
<div className="right-panel">
65-
<Hits hitComponent={Hit} />
67+
<InfiniteHits hitComponent={Hit} />
6668
</div>
67-
<Pagination />
6869
</div>
6970
</Index>
7071
</InstantSearch>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import 'instantsearch.css/themes/algolia-min.css'
2+
import React from 'react'
3+
import {
4+
InstantSearch,
5+
InfiniteHits,
6+
SearchBox,
7+
Stats,
8+
Highlight,
9+
ClearRefinements,
10+
RefinementList,
11+
} from 'react-instantsearch-dom'
12+
import { instantMeiliSearch } from '../../../../../src/index'
13+
14+
const searchClient = instantMeiliSearch('http://localhost:7700', 'masterKey', {
15+
primaryKey: 'id',
16+
keepZeroFacets: true,
17+
})
18+
19+
const SingleIndex = () => (
20+
<div className="ais-InstantSearch">
21+
<h1>Meilisearch + React InstantSearch</h1>
22+
<h2>Search in movies</h2>
23+
24+
<InstantSearch indexName="movies" searchClient={searchClient}>
25+
<Stats />
26+
<div className="left-panel">
27+
<ClearRefinements />
28+
<h2>Genres</h2>
29+
<RefinementList attribute="genres" />
30+
<h2>Players</h2>
31+
<RefinementList attribute="color" />
32+
<h2>Platforms</h2>
33+
<RefinementList attribute="platforms" />
34+
</div>
35+
<div className="right-panel">
36+
<SearchBox />
37+
<InfiniteHits hitComponent={Hit} />
38+
</div>
39+
</InstantSearch>
40+
</div>
41+
)
42+
43+
const Hit = ({ hit }) => {
44+
return (
45+
<div key={hit.id}>
46+
<div className="hit-name">
47+
<Highlight attribute="title" hit={hit} />
48+
</div>
49+
<div className="hit-name">
50+
<Highlight attribute="genres" hit={hit} />
51+
</div>
52+
<div className="hit-name">
53+
<Highlight attribute="color" hit={hit} />
54+
</div>
55+
<div className="hit-name">
56+
<Highlight attribute="platforms" hit={hit} />
57+
</div>
58+
</div>
59+
)
60+
}
61+
62+
export default SingleIndex

0 commit comments

Comments
 (0)