Skip to content

Commit 214c0fc

Browse files
authored
revert: feat(infiniteHits): add previous button
This reverts commit 2c9e38d.
1 parent cd64bcf commit 214c0fc

File tree

17 files changed

+27
-838
lines changed

17 files changed

+27
-838
lines changed

.storybook/MemoryRouter.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

.storybook/preview-head.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/instantsearch.css@7.2.0/themes/algolia.min.css">
1+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/instantsearch.css@7.1.1/themes/algolia.min.css">
22
<link rel="stylesheet" href="storybook.css">

src/components/InfiniteHits/InfiniteHits.js

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ import Template from '../Template/Template';
66
const InfiniteHits = ({
77
results,
88
hits,
9-
hasShowPrevious,
10-
showPrevious,
119
showMore,
12-
isFirstPage,
1310
isLastPage,
1411
cssClasses,
1512
templateProps,
@@ -29,21 +26,6 @@ const InfiniteHits = ({
2926

3027
return (
3128
<div className={cssClasses.root}>
32-
{hasShowPrevious && (
33-
<Template
34-
{...templateProps}
35-
templateKey="showPreviousText"
36-
rootTagName="button"
37-
rootProps={{
38-
className: cx(cssClasses.loadPrevious, {
39-
[cssClasses.disabledLoadPrevious]: isFirstPage,
40-
}),
41-
disabled: isFirstPage,
42-
onClick: showPrevious,
43-
}}
44-
/>
45-
)}
46-
4729
<ol className={cssClasses.list}>
4830
{hits.map((hit, position) => (
4931
<Template
@@ -82,18 +64,13 @@ InfiniteHits.propTypes = {
8264
emptyRoot: PropTypes.string.isRequired,
8365
list: PropTypes.string.isRequired,
8466
item: PropTypes.string.isRequired,
85-
loadPrevious: PropTypes.string.isRequired,
86-
disabledLoadPrevious: PropTypes.string.isRequired,
8767
loadMore: PropTypes.string.isRequired,
8868
disabledLoadMore: PropTypes.string.isRequired,
8969
}).isRequired,
9070
hits: PropTypes.array.isRequired,
9171
results: PropTypes.object.isRequired,
92-
hasShowPrevious: PropTypes.bool.isRequired,
93-
showPrevious: PropTypes.func.isRequired,
94-
showMore: PropTypes.func.isRequired,
72+
showMore: PropTypes.func,
9573
templateProps: PropTypes.object.isRequired,
96-
isFirstPage: PropTypes.bool.isRequired,
9774
isLastPage: PropTypes.bool.isRequired,
9875
};
9976

src/components/InfiniteHits/__tests__/InfiniteHits-test.js

Lines changed: 0 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ describe('InfiniteHits', () => {
88
emptyRoot: 'emptyRoot',
99
item: 'item',
1010
list: 'list',
11-
loadPrevious: 'loadPrevious',
12-
disabledLoadPrevious: 'disabledLoadPrevious',
1311
loadMore: 'loadMore',
1412
disabledLoadMore: 'disabledLoadMore',
1513
};
@@ -28,12 +26,8 @@ describe('InfiniteHits', () => {
2826
];
2927

3028
const props = {
31-
hasShowPrevious: false,
32-
showPrevious: () => {},
33-
showMore: () => {},
3429
results: { hits },
3530
hits,
36-
isFirstPage: true,
3731
isLastPage: false,
3832
templateProps: {
3933
templates: {
@@ -62,12 +56,8 @@ describe('InfiniteHits', () => {
6256
];
6357

6458
const props = {
65-
hasShowPrevious: false,
66-
showPrevious: () => {},
67-
showMore: () => {},
6859
results: { hits },
6960
hits,
70-
isFirstPage: false,
7161
isLastPage: true,
7262
templateProps: {
7363
templates: {
@@ -87,12 +77,8 @@ describe('InfiniteHits', () => {
8777
const hits = [];
8878

8979
const props = {
90-
hasShowPrevious: false,
91-
showPrevious: () => {},
92-
showMore: () => {},
9380
results: { hits },
9481
hits,
95-
isFirstPage: true,
9682
isLastPage: false,
9783
templateProps: {
9884
templates: {
@@ -112,12 +98,8 @@ describe('InfiniteHits', () => {
11298
const hits = [];
11399

114100
const props = {
115-
hasShowPrevious: false,
116-
showPrevious: () => {},
117-
showMore: () => {},
118101
results: { hits },
119102
hits,
120-
isFirstPage: false,
121103
isLastPage: true,
122104
templateProps: {
123105
templates: {
@@ -132,85 +114,5 @@ describe('InfiniteHits', () => {
132114

133115
expect(tree).toMatchSnapshot();
134116
});
135-
136-
it('should render <InfiniteHits /> with "Show previous" button on first page', () => {
137-
const hits = [
138-
{
139-
objectID: 'one',
140-
foo: 'bar',
141-
},
142-
{
143-
objectID: 'two',
144-
foo: 'baz',
145-
},
146-
];
147-
148-
const props = {
149-
hasShowPrevious: true,
150-
showPrevious: () => {},
151-
showMore: () => {},
152-
results: { hits },
153-
hits,
154-
isFirstPage: true,
155-
isLastPage: false,
156-
templateProps: {
157-
templates: {
158-
item: 'item',
159-
showMoreText: 'showMoreText',
160-
showPreviousText: 'showPreviousText',
161-
},
162-
},
163-
cssClasses,
164-
};
165-
166-
const tree = mount(<InfiniteHits {...props} />);
167-
168-
const previousButton = tree.find('.loadPrevious');
169-
170-
expect(previousButton.exists()).toEqual(true);
171-
expect(previousButton.hasClass('disabledLoadPrevious')).toEqual(true);
172-
expect(previousButton.props().disabled).toEqual(true);
173-
expect(tree).toMatchSnapshot();
174-
});
175-
176-
it('should render <InfiniteHits /> with "Show previous" button on last page', () => {
177-
const hits = [
178-
{
179-
objectID: 'one',
180-
foo: 'bar',
181-
},
182-
{
183-
objectID: 'two',
184-
foo: 'baz',
185-
},
186-
];
187-
188-
const props = {
189-
hasShowPrevious: true,
190-
showPrevious: () => {},
191-
showMore: () => {},
192-
results: { hits },
193-
hits,
194-
isFirstPage: false,
195-
isLastPage: true,
196-
templateProps: {
197-
templates: {
198-
item: 'item',
199-
showMoreText: 'showMoreText',
200-
showPreviousText: 'showPreviousText',
201-
},
202-
},
203-
cssClasses,
204-
};
205-
206-
const tree = mount(<InfiniteHits {...props} />);
207-
208-
const previousButton = tree.find('.loadPrevious');
209-
210-
expect(previousButton.exists()).toEqual(true);
211-
expect(previousButton.hasClass('disabledLoadPrevious')).toEqual(false);
212-
expect(previousButton.props().disabled).toEqual(false);
213-
expect(tree).toMatchSnapshot();
214-
});
215117
});
216118
});

src/components/InfiniteHits/__tests__/__snapshots__/InfiniteHits-test.js.snap

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ exports[`InfiniteHits markup should render <InfiniteHits /> on first page 1`] =
3232
}
3333
}
3434
disabled={false}
35-
onClick={[Function]}
3635
/>
3736
</div>
3837
`;
@@ -69,101 +68,6 @@ exports[`InfiniteHits markup should render <InfiniteHits /> on last page 1`] = `
6968
}
7069
}
7170
disabled={true}
72-
onClick={[Function]}
73-
/>
74-
</div>
75-
`;
76-
77-
exports[`InfiniteHits markup should render <InfiniteHits /> with "Show previous" button on first page 1`] = `
78-
<div
79-
className="root"
80-
>
81-
<button
82-
className="loadPrevious disabledLoadPrevious"
83-
dangerouslySetInnerHTML={
84-
Object {
85-
"__html": "showPreviousText",
86-
}
87-
}
88-
disabled={true}
89-
onClick={[Function]}
90-
/>
91-
<ol
92-
className="list"
93-
>
94-
<li
95-
className="item"
96-
dangerouslySetInnerHTML={
97-
Object {
98-
"__html": "item",
99-
}
100-
}
101-
/>
102-
<li
103-
className="item"
104-
dangerouslySetInnerHTML={
105-
Object {
106-
"__html": "item",
107-
}
108-
}
109-
/>
110-
</ol>
111-
<button
112-
className="loadMore"
113-
dangerouslySetInnerHTML={
114-
Object {
115-
"__html": "showMoreText",
116-
}
117-
}
118-
disabled={false}
119-
onClick={[Function]}
120-
/>
121-
</div>
122-
`;
123-
124-
exports[`InfiniteHits markup should render <InfiniteHits /> with "Show previous" button on last page 1`] = `
125-
<div
126-
className="root"
127-
>
128-
<button
129-
className="loadPrevious"
130-
dangerouslySetInnerHTML={
131-
Object {
132-
"__html": "showPreviousText",
133-
}
134-
}
135-
disabled={false}
136-
onClick={[Function]}
137-
/>
138-
<ol
139-
className="list"
140-
>
141-
<li
142-
className="item"
143-
dangerouslySetInnerHTML={
144-
Object {
145-
"__html": "item",
146-
}
147-
}
148-
/>
149-
<li
150-
className="item"
151-
dangerouslySetInnerHTML={
152-
Object {
153-
"__html": "item",
154-
}
155-
}
156-
/>
157-
</ol>
158-
<button
159-
className="loadMore disabledLoadMore"
160-
dangerouslySetInnerHTML={
161-
Object {
162-
"__html": "showMoreText",
163-
}
164-
}
165-
disabled={true}
166-
onClick={[Function]}
16771
/>
16872
</div>
16973
`;

0 commit comments

Comments
 (0)