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
8 changes: 4 additions & 4 deletions docgen/src/guides/v3-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,10 @@ With the redo button:

#### Options

| Before | After |
| --------------- | -------------------- |
| `escapeHits` | `escapeHTML` |
| `loadMoreLabel` | `templates.showMore` |
| Before | After |
| --------------- | ------------------------ |
| `escapeHits` | `escapeHTML` |
| `loadMoreLabel` | `templates.showMoreText` |

- `escapeHTML` defaults to `true`

Expand Down
2 changes: 1 addition & 1 deletion src/components/InfiniteHits/InfiniteHits.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const InfiniteHits = ({

<Template
{...templateProps}
templateKey="showMore"
templateKey="showMoreText"
rootTagName="button"
rootProps={{
className: cx(cssClasses.loadMore, {
Expand Down
8 changes: 4 additions & 4 deletions src/components/InfiniteHits/__tests__/InfiniteHits-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('InfiniteHits', () => {
templateProps: {
templates: {
item: 'item',
showMore: 'showMore',
showMoreText: 'showMoreText',
},
},
cssClasses,
Expand Down Expand Up @@ -62,7 +62,7 @@ describe('InfiniteHits', () => {
templateProps: {
templates: {
item: 'item',
showMore: 'showMore',
showMoreText: 'showMoreText',
},
},
cssClasses,
Expand All @@ -83,7 +83,7 @@ describe('InfiniteHits', () => {
templateProps: {
templates: {
empty: 'empty',
showMore: 'showMore',
showMoreText: 'showMoreText',
},
},
cssClasses,
Expand All @@ -104,7 +104,7 @@ describe('InfiniteHits', () => {
templateProps: {
templates: {
empty: 'empty',
showMore: 'showMore',
showMoreText: 'showMoreText',
},
},
cssClasses,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ exports[`InfiniteHits markup should render <InfiniteHits /> on first page 1`] =
className="loadMore"
dangerouslySetInnerHTML={
Object {
"__html": "showMore",
"__html": "showMoreText",
}
}
disabled={false}
Expand Down Expand Up @@ -64,7 +64,7 @@ exports[`InfiniteHits markup should render <InfiniteHits /> on last page 1`] = `
className="loadMore disabledLoadMore"
dangerouslySetInnerHTML={
Object {
"__html": "showMore",
"__html": "showMoreText",
}
}
disabled={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ exports[`infiniteHits() calls twice ReactDOM.render(<Hits props />, container) 1
"templates": Object {
"empty": "No results",
"item": [Function],
"showMore": "Show more results",
"showMoreText": "Show more results",
},
"templatesConfig": undefined,
"useCustomCompileOptions": Object {
"empty": false,
"item": false,
"showMore": false,
"showMoreText": false,
},
}
}
Expand Down Expand Up @@ -87,13 +87,13 @@ exports[`infiniteHits() calls twice ReactDOM.render(<Hits props />, container) 2
"templates": Object {
"empty": "No results",
"item": [Function],
"showMore": "Show more results",
"showMoreText": "Show more results",
},
"templatesConfig": undefined,
"useCustomCompileOptions": Object {
"empty": false,
"item": false,
"showMore": false,
"showMoreText": false,
},
}
}
Expand Down Expand Up @@ -139,13 +139,13 @@ exports[`infiniteHits() if it is the last page, then the props should contain is
"templates": Object {
"empty": "No results",
"item": [Function],
"showMore": "Show more results",
"showMoreText": "Show more results",
},
"templatesConfig": undefined,
"useCustomCompileOptions": Object {
"empty": false,
"item": false,
"showMore": false,
"showMoreText": false,
},
}
}
Expand Down Expand Up @@ -191,13 +191,13 @@ exports[`infiniteHits() if it is the last page, then the props should contain is
"templates": Object {
"empty": "No results",
"item": [Function],
"showMore": "Show more results",
"showMoreText": "Show more results",
},
"templatesConfig": undefined,
"useCustomCompileOptions": Object {
"empty": false,
"item": false,
"showMore": false,
"showMoreText": false,
},
}
}
Expand Down Expand Up @@ -243,13 +243,13 @@ exports[`infiniteHits() renders transformed items 1`] = `
"templates": Object {
"empty": "No results",
"item": [Function],
"showMore": "Show more results",
"showMoreText": "Show more results",
},
"templatesConfig": undefined,
"useCustomCompileOptions": Object {
"empty": false,
"item": false,
"showMore": false,
"showMoreText": false,
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/infinite-hits/defaultTemplates.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
empty: 'No results',
showMore: 'Show more results',
showMoreText: 'Show more results',
item(data) {
return JSON.stringify(data, null, 2);
},
Expand Down
6 changes: 3 additions & 3 deletions src/widgets/infinite-hits/infinite-hits.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ infiniteHits({
[ escapeHTML = true ],
[ transformItems ],
[ cssClasses.{root, emptyRoot, list, item, loadMore, disabledLoadMore} ],
[ templates.{empty, item, showMore} ],
[ templates.{empty, item, showMoreText} ],
})`;

/**
* @typedef {Object} InfiniteHitsTemplates
* @property {string|function} [empty = "No results"] Template used when there are no results.
* @property {string|function} [showMore = "Show more results"] Template used for the "load more" button.
* @property {string|function} [showMoreText = "Show more results"] Template used for the "load more" button.
* @property {string|function} [item = ""] Template used for each result. This template will receive an object containing a single record.
*/

Expand Down Expand Up @@ -87,7 +87,7 @@ infiniteHits({
* container: '#infinite-hits-container',
* templates: {
* empty: 'No results',
* showMore: 'Show more results',
* showMoreText: 'Show more results',
* item: '<strong>Hit {{objectID}}</strong>: {{{_highlightResult.name.value}}}'
* },
* transformItems: items => items.map(item => item),
Expand Down
4 changes: 2 additions & 2 deletions storybook/app/builtin/stories/infinite-hits.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ export default () => {
})
)
.add(
'with custom "showMore" template',
'with custom "showMoreText" template',
wrapWithHits(container => {
window.search.addWidget(
instantsearch.widgets.infiniteHits({
container,
templates: {
item: '{{name}}',
showMore: 'Load more',
showMoreText: 'Load more',
},
})
);
Expand Down