File size: 2,900 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 98 99 100 101 | import React from 'react';
import { storiesOf } from '@storybook/react';
import {
CurrentRefinements,
Menu,
NumericMenu,
HierarchicalMenu,
Panel,
RangeInput,
RefinementList,
ToggleRefinement,
} from 'react-instantsearch-dom';
import { WrapWithHits } from './util';
const stories = storiesOf('CurrentRefinements', module);
stories
.add('with RefinementList', () => (
<WrapWithHits linkedStoryGroup="CurrentRefinements.stories.js">
<CurrentRefinements />
<hr />
<RefinementList
attribute="brand"
defaultRefinement={['Apple', 'Samsung']}
/>
</WrapWithHits>
))
.add('with Menu', () => (
<WrapWithHits linkedStoryGroup="CurrentRefinements.stories.js">
<CurrentRefinements />
<hr />
<Menu attribute="brand" defaultRefinement="Apple" />
</WrapWithHits>
))
.add('with HierarchicalMenu', () => (
<WrapWithHits linkedStoryGroup="CurrentRefinements.stories.js">
<CurrentRefinements />
<hr />
<HierarchicalMenu
attributes={[
'hierarchicalCategories.lvl0',
'hierarchicalCategories.lvl1',
'hierarchicalCategories.lvl2',
]}
defaultRefinement="Cameras & Camcorders > Digital Cameras"
/>
</WrapWithHits>
))
.add('with ToggleRefinement', () => (
<WrapWithHits linkedStoryGroup="CurrentRefinements.stories.js">
<CurrentRefinements />
<hr />
<ToggleRefinement
attribute="free_shipping"
label="Free Shipping"
value={true}
/>
</WrapWithHits>
))
.add('with NumericMenu', () => (
<WrapWithHits linkedStoryGroup="CurrentRefinements.stories.js">
<CurrentRefinements />
<hr />
<NumericMenu
attribute="price"
items={[
{ end: 10, label: '<$10' },
{ start: 10, end: 100, label: '$10-$100' },
{ start: 100, end: 500, label: '$100-$500' },
{ start: 500, label: '>$500' },
]}
defaultRefinement=":10"
/>
</WrapWithHits>
))
.add('with RangeInput', () => (
<WrapWithHits linkedStoryGroup="CurrentRefinements.stories.js">
<CurrentRefinements />
<hr />
<RangeInput attribute="price" defaultRefinement={{ min: 30, max: 500 }} />
</WrapWithHits>
))
.add('with Panel', () => (
<WrapWithHits linkedStoryGroup="CurrentRefinements.stories.js">
<Panel header="Current refinements" footer="Footer">
<CurrentRefinements />
</Panel>
<div style={{ display: 'none' }}>
<RefinementList attribute="brand" defaultRefinement={['Apple']} />
</div>
</WrapWithHits>
))
.add('with Panel but no refinements', () => (
<WrapWithHits linkedStoryGroup="CurrentRefinements.stories.js">
<Panel header="Current refinements" footer="Footer">
<CurrentRefinements />
</Panel>
</WrapWithHits>
));
|