Skip to content

Commit eb2c993

Browse files
committed
feat(numeric-refinement-list): facetValues -> items / toggleRefinement -> refine
1 parent be5e063 commit eb2c993

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

src/connectors/numeric-refinement-list/connectNumericRefinementList.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ const usage = `Usage:
77
var customNumericRefinementList = connectNumericRefinementList(function renderFn(params, isFirstRendering) {
88
// params = {
99
// createURL,
10-
// facetValues,
10+
// items,
1111
// hasNoResults,
12-
// toggleRefinement,
12+
// refine,
1313
// instantSearchInstance,
1414
// widgetParams,
1515
// }
@@ -35,14 +35,14 @@ Full documentation available at https://community.algolia.com/instantsearch.js/c
3535
/**
3636
* @typedef {Object} NumericRefinementListRenderingOptions
3737
* @property {function(string)} createURL create URL's for the next state, the string is the name of the selected option
38-
* @property {FacetValue[]} facetValues the list of available choices
39-
* @property {string} facetValues[].name Name of the option
40-
* @property {number} [facetValues[].start] Low bound of the option (>=)
41-
* @property {number} [facetValues[].end] High bound of the option (<=)
42-
* @property {number} [facetValues[].isRefined] true if the value is selected
43-
* @property {number} [facetValues[].attributeName] the name of the attribute in the records
38+
* @property {FacetValue[]} items the list of available choices
39+
* @property {string} items[].name Name of the option
40+
* @property {number} [items[].start] Low bound of the option (>=)
41+
* @property {number} [items[].end] High bound of the option (<=)
42+
* @property {number} [items[].isRefined] true if the value is selected
43+
* @property {number} [items[].attributeName] the name of the attribute in the records
4444
* @property {boolean} hasNoResults true if there were no results retrieved in the previous search
45-
* @property {function(string)} toggleRefinement set the selected value and trigger a new search
45+
* @property {function(string)} refine set the selected value and trigger a new search
4646
* @property {Object} widgetParams all original options forwarded to rendering
4747
* @property {InstantSearch} instantSearchInstance the instance of instantsearch on which the widget is attached
4848
*/
@@ -69,14 +69,14 @@ export default function connectNumericRefinementList(renderFn) {
6969

7070
return {
7171
init({helper, createURL, instantSearchInstance}) {
72-
this._toggleRefinement = facetValue => {
72+
this._refine = facetValue => {
7373
const refinedState = refine(helper.state, attributeName, options, facetValue);
7474
helper.setState(refinedState).search();
7575
};
7676

7777
this._createURL = state => facetValue => createURL(refine(state, attributeName, options, facetValue));
7878

79-
const facetValues = options.map(facetValue =>
79+
const items = options.map(facetValue =>
8080
({
8181
...facetValue,
8282
isRefined: isRefined(helper.state, attributeName, facetValue),
@@ -86,15 +86,15 @@ export default function connectNumericRefinementList(renderFn) {
8686

8787
renderFn({
8888
createURL: this._createURL(helper.state),
89-
facetValues,
89+
items,
9090
hasNoResults: true,
91-
toggleRefinement: this._toggleRefinement,
91+
refine: this._refine,
9292
instantSearchInstance,
9393
widgetParams,
9494
}, true);
9595
},
9696
render({results, state, instantSearchInstance}) {
97-
const facetValues = options.map(facetValue =>
97+
const items = options.map(facetValue =>
9898
({
9999
...facetValue,
100100
isRefined: isRefined(state, attributeName, facetValue),
@@ -104,9 +104,9 @@ export default function connectNumericRefinementList(renderFn) {
104104

105105
renderFn({
106106
createURL: this._createURL(state),
107-
facetValues,
107+
items,
108108
hasNoResults: results.nbHits === 0,
109-
toggleRefinement: this._toggleRefinement,
109+
refine: this._refine,
110110
instantSearchInstance,
111111
widgetParams,
112112
}, false);

src/widgets/numeric-refinement-list/numeric-refinement-list.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ const renderer = ({
2525
}) => ({
2626
createURL,
2727
instantSearchInstance,
28-
toggleRefinement,
29-
facetValues,
28+
refine,
29+
items,
3030
hasNoResults,
3131
}, isFirstRendering) => {
3232
if (isFirstRendering) {
@@ -44,10 +44,10 @@ const renderer = ({
4444
collapsible={collapsible}
4545
createURL={createURL}
4646
cssClasses={cssClasses}
47-
facetValues={facetValues}
47+
facetValues={items}
4848
shouldAutoHideContainer={autoHideContainer && hasNoResults}
4949
templateProps={renderState.templateProps}
50-
toggleRefinement={toggleRefinement}
50+
toggleRefinement={refine}
5151
/>,
5252
containerNode
5353
);

0 commit comments

Comments
 (0)