Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/js/default-theme/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ search.addWidgets([
}),
chat({
container: '#chat',
agentId: '7c2f6816-bfdb-46e9-a51f-9cb8e5fc9628',
agentId: 'eedef238-5468-470d-bc37-f99fa741bd25',
templates: {
item: itemTemplate,
},
Expand Down
3 changes: 3 additions & 0 deletions examples/js/getting-started/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ <h1 class="header-title">
<div class="search-panel">
<div class="search-panel__filters">
<div id="brand-list"></div>
<div id="categories-list"></div>
</div>

<div class="search-panel__results">
<div id="searchbox"></div>
<div id="current-refinements"></div>
<div id="filter-suggestions"></div>
<div id="hits"></div>
<div id="pagination"></div>
<div id="trending"></div>
Expand Down
4 changes: 4 additions & 0 deletions examples/js/getting-started/src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
text-align: center;
}

.ais-Hits {
margin-top: 1rem;
}

#related-products,
.ais-Hits--single {
margin-top: 1rem;
Expand Down
26 changes: 25 additions & 1 deletion examples/js/getting-started/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
searchBox,
trendingItems,
chat,
filterSuggestions,
currentRefinements,
} from 'instantsearch.js/es/widgets';

import 'instantsearch.css/themes/satellite.css';
Expand Down Expand Up @@ -45,6 +47,20 @@ search.addWidgets([
searchBox({
container: '#searchbox',
}),
panel({
templates: { header: 'Current Refinements' },
hidden: ({ items }) => items.length === 0,
})(currentRefinements)({
container: '#current-refinements',
}),
panel({ templates: { header: 'Filter Suggestions' } })(filterSuggestions)({
container: '#filter-suggestions',
agentId: '3123062d-d611-4d4f-8ab2-4fa39302dc64',
attributes: ['brand', 'categories'],
templates: {
header: false,
},
}),
hits({
container: '#hits',
templates: {
Expand All @@ -69,6 +85,14 @@ search.addWidgets([
})(refinementList)({
container: '#brand-list',
attribute: 'brand',
showMore: true,
}),
panel({
templates: { header: 'categories' },
})(refinementList)({
container: '#categories-list',
attribute: 'categories',
showMore: true,
}),
pagination({
container: '#pagination',
Expand All @@ -83,7 +107,7 @@ search.addWidgets([
}),
chat({
container: '#chat',
agentId: '7c2f6816-bfdb-46e9-a51f-9cb8e5fc9628',
agentId: 'eedef238-5468-470d-bc37-f99fa741bd25',
templates: {
item: productItemTemplate,
},
Expand Down
2 changes: 1 addition & 1 deletion examples/react/default-theme/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export function App() {
</div>

<Chat
agentId="7c2f6816-bfdb-46e9-a51f-9cb8e5fc9628"
agentId="eedef238-5468-470d-bc37-f99fa741bd25"
itemComponent={ItemComponent}
/>
</InstantSearch>
Expand Down
22 changes: 21 additions & 1 deletion examples/react/getting-started/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
TrendingItems,
Carousel,
Chat,
FilterSuggestions,
CurrentRefinements,
} from 'react-instantsearch';

import { Panel } from './Panel';
Expand Down Expand Up @@ -52,10 +54,28 @@ export function App() {
<Panel header="brand">
<RefinementList attribute="brand" />
</Panel>
<Panel header="categories">
<RefinementList attribute="categories" />
</Panel>
</div>

<div className="search-panel__results">
<SearchBox placeholder="" className="searchbox" />
<Panel
header="Current Refinements"
hidden={(state) =>
state.currentRefinements?.items?.length === 0
}
>
<CurrentRefinements />
</Panel>
<Panel header="Filter Suggestions">
<FilterSuggestions
agentId="3123062d-d611-4d4f-8ab2-4fa39302dc64"
attributes={['brand', 'categories']}
headerComponent={false}
/>
</Panel>
<Hits hitComponent={HitComponent} />

<div className="pagination">
Expand All @@ -72,7 +92,7 @@ export function App() {
</div>

<Chat
agentId="7c2f6816-bfdb-46e9-a51f-9cb8e5fc9628"
agentId="eedef238-5468-470d-bc37-f99fa741bd25"
itemComponent={ItemComponent}
/>
</InstantSearch>
Expand Down
13 changes: 11 additions & 2 deletions examples/react/getting-started/src/Panel.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import React from 'react';
import { useInstantSearch } from 'react-instantsearch';

import type { IndexRenderState } from 'instantsearch.js';

type PanelProps = React.PropsWithChildren<{
header: string;
hidden?: (state: IndexRenderState) => boolean;
}>;

export function Panel({ header, children }: PanelProps) {
export function Panel({ header, children, hidden }: PanelProps) {
const { indexRenderState } = useInstantSearch();

return (
<div className="ais-Panel">
<div
className="ais-Panel"
hidden={hidden ? hidden(indexRenderState) : false}
>
<div className="ais-Panel-header">
<span>{header}</span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion examples/react/query-suggestions/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export function App() {
</div>

<Chat
agentId="7c2f6816-bfdb-46e9-a51f-9cb8e5fc9628"
agentId="eedef238-5468-470d-bc37-f99fa741bd25"
itemComponent={ItemComponent}
/>
</InstantSearch>
Expand Down