diff --git a/dev/app/builtin/stories/hits.stories.js b/dev/app/builtin/stories/hits.stories.js index 435c3090bc..c014002010 100644 --- a/dev/app/builtin/stories/hits.stories.js +++ b/dev/app/builtin/stories/hits.stories.js @@ -36,7 +36,6 @@ export default () => { window.search.addWidget( instantsearch.widgets.hits({ container, - escapeHits: true, templates: { item: `
diff --git a/dev/app/builtin/stories/infinite-hits.stories.js b/dev/app/builtin/stories/infinite-hits.stories.js index ca0c519b47..19a2cf7ac7 100644 --- a/dev/app/builtin/stories/infinite-hits.stories.js +++ b/dev/app/builtin/stories/infinite-hits.stories.js @@ -14,7 +14,7 @@ export default () => { window.search.addWidget( instantsearch.widgets.infiniteHits({ container, - showMoreLabel: 'Show more', + loadMoreLabel: 'Show more', templates: { item: '{{name}}', }, @@ -34,9 +34,9 @@ export default () => { window.search.addWidget( instantsearch.widgets.infiniteHits({ container, - showMoreLabel: 'Show more', + loadMoreLabel: 'Show more', cssClasses: { - showmore: 'button', + loadMore: 'button', }, templates: { item: '{{name}}', @@ -51,7 +51,7 @@ export default () => { window.search.addWidget( instantsearch.widgets.infiniteHits({ container, - showMoreLabel: 'Show more', + loadMoreLabel: 'Show more', templates: { item: '{{name}}', }, diff --git a/dev/app/init-unmount-widgets.js b/dev/app/init-unmount-widgets.js index 4290bca27d..cdaae85296 100644 --- a/dev/app/init-unmount-widgets.js +++ b/dev/app/init-unmount-widgets.js @@ -161,7 +161,7 @@ export default () => { wrapWithUnmount(container => instantsearch.widgets.infiniteHits({ container, - showMoreLabel: 'Show more', + loadMoreLabel: 'Show more', templates: { item: '{{name}}', }, diff --git a/docgen/src/guides/v3-migration.md b/docgen/src/guides/v3-migration.md index ecd7197f3a..9e30364d1b 100644 --- a/docgen/src/guides/v3-migration.md +++ b/docgen/src/guides/v3-migration.md @@ -4,6 +4,116 @@ InstantSearch 3 introduces some breaking changes in the widget's naming, options ## Widgets +### Hits + +#### Options + +| Before | After | +| --------------- | --------------- | +| `escapeHits` | `escapeHTML` | +| `showMoreLabel` | `loadMoreLabel` | + +* `escapeHTML` becomes `true` by default. +* `allItems` template has been removed in favor of `connectHits` + +#### CSS classes + +| Before | After | +| ----------------- | ----------------- | +| `ais-hits` | `ais-Hits` | +| `ais-hits--empty` | `ais-Hits--empty` | +| | `ais-Hits--list` | +| `ais-hits--item` | `ais-Hits--item` | + +#### Markup + +```html +
+
    +
  1. + Hit 5477500: Amazon - Fire TV Stick with Alexa Voice Remote - Black +
  2. +
  3. + Hit 4397400: Google - Chromecast - Black +
  4. +
  5. + Hit 4397400: Google - Chromecast - Black +
  6. +
  7. + Hit 5477500: Amazon - Fire TV Stick with Alexa Voice Remote - Black +
  8. +
  9. + Hit 4397400: Google - Chromecast - Black +
  10. +
  11. + Hit 4397400: Google - Chromecast - Black +
  12. +
  13. + Hit 5477500: Amazon - Fire TV Stick with Alexa Voice Remote - Black +
  14. +
  15. + Hit 4397400: Google - Chromecast - Black +
  16. +
+
+``` + +### InfiniteHits + +#### Options + +| Before | After | +| ------------ | ------------ | +| `escapeHits` | `escapeHTML` | + +`escapeHTML` becomes `true` by default. + +#### CSS classes + +| Before | After | +| ----------------------------------- | ------------------------------------- | +| `ais-infinite-hits` | `ais-InfiniteHits` | +| `ais-infinite-hits--empty` | `ais-InfiniteHits--empty` | +| | `ais-InfiniteHits--list` | +| `ais-infinite-hits--item` | `ais-InfiniteHits--item` | +| `ais-infinite-hits--showmore` | | +| `ais-infinite-hits--showmoreButton` | `ais-InfiniteHits-loadMore` | +| | `ais-InfiniteHits-loadMore--disabled` | + +#### Markup + +```html +
+
    +
  1. + Hit 5477500: Amazon - Fire TV Stick with Alexa Voice Remote - Black +
  2. +
  3. + Hit 4397400: Google - Chromecast - Black +
  4. +
  5. + Hit 4397400: Google - Chromecast - Black +
  6. +
  7. + Hit 5477500: Amazon - Fire TV Stick with Alexa Voice Remote - Black +
  8. +
  9. + Hit 4397400: Google - Chromecast - Black +
  10. +
  11. + Hit 4397400: Google - Chromecast - Black +
  12. +
  13. + Hit 5477500: Amazon - Fire TV Stick with Alexa Voice Remote - Black +
  14. +
  15. + Hit 4397400: Google - Chromecast - Black +
  16. +
+ + +``` + ### Stats #### CSS classes diff --git a/src/components/Hits.js b/src/components/Hits.js index 82afb9a136..0ed657e177 100644 --- a/src/components/Hits.js +++ b/src/components/Hits.js @@ -2,18 +2,19 @@ import PropTypes from 'prop-types'; import React, { Component } from 'preact-compat'; import map from 'lodash/map'; import Template from './Template.js'; -import hasKey from 'lodash/has'; import cx from 'classnames'; class Hits extends Component { - renderWithResults() { + renderResults() { const renderedHits = map(this.props.hits, (hit, position) => { const data = { ...hit, __hitIndex: position, }; + return (