Skip to content

Commit 8287de0

Browse files
Sponesamouss
authored andcommitted
feat(infiniteHits): add showmoreButton to cssClasses (#3026)
* feat(infiniteHits): add showmoreButton to cssClasses * feat(infiniteHits): fix snapshot to make tests pass * feat(infiniteHits): prettify file
1 parent e620bf3 commit 8287de0

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/components/InfiniteHits.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ class InfiniteHits extends Component {
1313
templateProps,
1414
} = this.props;
1515
const btn = this.props.isLastPage ? (
16-
<button disabled>{showMoreLabel}</button>
16+
<button disabled className={cssClasses.showmoreButton}>
17+
{showMoreLabel}
18+
</button>
1719
) : (
18-
<button onClick={showMore}>{showMoreLabel}</button>
20+
<button onClick={showMore} className={cssClasses.showmoreButton}>
21+
{showMoreLabel}
22+
</button>
1923
);
2024

2125
return (
@@ -39,6 +43,7 @@ InfiniteHits.propTypes = {
3943
allItems: PropTypes.string,
4044
empty: PropTypes.string,
4145
showmore: PropTypes.string,
46+
showmoreButton: PropTypes.string,
4247
}),
4348
hits: PropTypes.array,
4449
results: PropTypes.object,

src/widgets/infinite-hits/__tests__/__snapshots__/infinite-hits-test.js.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ exports[`infiniteHits() calls twice ReactDOM.render(<Hits props />, container) 1
88
"item": "ais-infinite-hits--item",
99
"root": "ais-infinite-hits root cx",
1010
"showmore": "ais-infinite-hits--showmore",
11+
"showmoreButton": "ais-infinite-hits--showmoreButton",
1112
}
1213
}
1314
hits={
@@ -56,6 +57,7 @@ exports[`infiniteHits() calls twice ReactDOM.render(<Hits props />, container) 2
5657
"item": "ais-infinite-hits--item",
5758
"root": "ais-infinite-hits root cx",
5859
"showmore": "ais-infinite-hits--showmore",
60+
"showmoreButton": "ais-infinite-hits--showmoreButton",
5961
}
6062
}
6163
hits={
@@ -104,6 +106,7 @@ exports[`infiniteHits() if it is the last page, then the props should contain is
104106
"item": "ais-infinite-hits--item",
105107
"root": "ais-infinite-hits root cx",
106108
"showmore": "ais-infinite-hits--showmore",
109+
"showmoreButton": "ais-infinite-hits--showmoreButton",
107110
}
108111
}
109112
hits={
@@ -154,6 +157,7 @@ exports[`infiniteHits() if it is the last page, then the props should contain is
154157
"item": "ais-infinite-hits--item",
155158
"root": "ais-infinite-hits root cx",
156159
"showmore": "ais-infinite-hits--showmore",
160+
"showmoreButton": "ais-infinite-hits--showmoreButton",
157161
}
158162
}
159163
hits={

src/widgets/infinite-hits/infinite-hits.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ infiniteHits({
5454
container,
5555
[ escapeHits = false ],
5656
[ showMoreLabel ],
57-
[ cssClasses.{root,empty,item,showmore}={} ],
57+
[ cssClasses.{root,empty,item,showmore,showmoreButton}={} ],
5858
[ templates.{empty,item} | templates.{empty} ],
5959
[ transformData.{empty,item} | transformData.{empty} ],
6060
})`;
@@ -76,7 +76,8 @@ infiniteHits({
7676
* @property {string|string[]} [root] CSS class to add to the wrapping element.
7777
* @property {string|string[]} [empty] CSS class to add to the wrapping element when no results.
7878
* @property {string|string[]} [item] CSS class to add to each result.
79-
* @property {string|string[]} [showmore] CSS class to add to the show more button.
79+
* @property {string|string[]} [showmore] CSS class to add to the show more button container.
80+
* @property {string|string[]} [showmoreButton] CSS class to add to the show more button.
8081
*/
8182

8283
/**
@@ -138,6 +139,7 @@ export default function infiniteHits({
138139
item: cx(bem('item'), userCssClasses.item),
139140
empty: cx(bem(null, 'empty'), userCssClasses.empty),
140141
showmore: cx(bem('showmore'), userCssClasses.showmore),
142+
showmoreButton: cx(bem('showmoreButton'), userCssClasses.showmoreButton),
141143
};
142144

143145
const specializedRenderer = renderer({

0 commit comments

Comments
 (0)