File size: 2,717 Bytes
1e92f2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | import React from 'react';
import orderBy from 'lodash.orderby';
import { storiesOf } from '@storybook/react';
import { boolean, number, array } from '@storybook/addon-knobs';
import { Panel, RefinementList, SearchBox } from 'react-instantsearch-dom';
import { WrapWithHits } from './util';
const stories = storiesOf('RefinementList', module);
stories
.add('default', () => (
<WrapWithHits
linkedStoryGroup="RefinementList.stories.js"
hasPlayground={true}
>
<RefinementList attribute="brand" />
</WrapWithHits>
))
.add('with selected item', () => (
<WrapWithHits
linkedStoryGroup="RefinementList.stories.js"
hasPlayground={true}
>
<RefinementList attribute="brand" defaultRefinement={['Apple']} />
</WrapWithHits>
))
.add('with show more', () => (
<WrapWithHits
linkedStoryGroup="RefinementList.stories.js"
hasPlayground={true}
>
<RefinementList
attribute="brand"
limit={2}
showMoreLimit={5}
showMore={true}
/>
</WrapWithHits>
))
.add('with search inside items', () => (
<WrapWithHits
linkedStoryGroup="RefinementList.stories.js"
hasPlayground={true}
>
<RefinementList attribute="brand" searchable />
</WrapWithHits>
))
.add('with the sort strategy changed', () => (
<WrapWithHits
linkedStoryGroup="RefinementList.stories.js"
hasPlayground={true}
>
<RefinementList
attribute="brand"
transformItems={(items) =>
orderBy(items, ['label', 'count'], ['asc', 'desc'])
}
/>
</WrapWithHits>
))
.add('with Panel', () => (
<WrapWithHits
linkedStoryGroup="RefinementList.stories.js"
hasPlayground={true}
>
<Panel header="Refinement List" footer="Footer">
<RefinementList attribute="brand" />
</Panel>
</WrapWithHits>
))
.add('with Panel but no refinement', () => (
<WrapWithHits
searchBox={false}
linkedStoryGroup="RefinementList.stories.js"
hasPlayground={true}
>
<Panel header="Refinement List" footer="Footer">
<RefinementList attribute="brand" />
</Panel>
<div style={{ display: 'none' }}>
<SearchBox defaultRefinement="tutututututu" />
</div>
</WrapWithHits>
))
.add('playground', () => (
<WrapWithHits linkedStoryGroup="RefinementList.stories.js">
<RefinementList
attribute="brand"
defaultRefinement={array('defaultSelectedItem', ['Apple', 'Samsung'])}
limit={number('limit', 10)}
showMoreLimit={number('showMoreLimit', 20)}
showMore={boolean('showMore', true)}
/>
</WrapWithHits>
));
|