File size: 3,451 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
102
103
104
105
import React from 'react';
import { storiesOf } from '@storybook/react';
import { object, number } from '@storybook/addon-knobs';
import { Panel, RangeInput, SearchBox } from 'react-instantsearch-dom';
import { WrapWithHits } from './util';

const stories = storiesOf('RangeInput', module);

stories
  .add('default', () => (
    <WrapWithHits linkedStoryGroup="RangeInput.stories.js">
      <RangeInput attribute="price" />
    </WrapWithHits>
  ))
  .add('visible without refinement', () => (
    <WrapWithHits searchBox={false} linkedStoryGroup="RangeInput.stories.js">
      <RangeInput attribute="price" header="Range Input" />

      <div style={{ display: 'none' }}>
        <SearchBox defaultRefinement="ds" />
      </div>
    </WrapWithHits>
  ))
  .add('with no refinement', () => (
    <WrapWithHits searchBox={false} linkedStoryGroup="RangeInput.stories.js">
      <RangeInput attribute="price" />
      <div style={{ display: 'none' }}>
        <SearchBox defaultRefinement="ds" />
      </div>
    </WrapWithHits>
  ))
  .add('with precision of 2', () => (
    <WrapWithHits linkedStoryGroup="RangeInput.stories.js">
      <RangeInput attribute="price" precision={2} />
    </WrapWithHits>
  ))
  .add('with default value', () => (
    <WrapWithHits linkedStoryGroup="RangeInput.stories.js">
      <RangeInput attribute="price" defaultRefinement={{ min: 50 }} />
    </WrapWithHits>
  ))
  .add('with default values', () => (
    <WrapWithHits linkedStoryGroup="RangeInput.stories.js">
      <RangeInput attribute="price" defaultRefinement={{ min: 50, max: 200 }} />
    </WrapWithHits>
  ))
  .add('with min boundaries', () => (
    <WrapWithHits linkedStoryGroup="RangeInput.stories.js">
      <RangeInput attribute="price" min={30} />
    </WrapWithHits>
  ))
  .add('with max boundaries', () => (
    <WrapWithHits linkedStoryGroup="RangeInput.stories.js">
      <RangeInput attribute="price" max={500} />
    </WrapWithHits>
  ))
  .add('with min / max boundaries', () => (
    <WrapWithHits linkedStoryGroup="RangeInput.stories.js">
      <RangeInput attribute="price" min={30} max={500} />
    </WrapWithHits>
  ))
  .add('with boundaries and default value', () => (
    <WrapWithHits linkedStoryGroup="RangeInput.stories.js">
      <RangeInput
        attribute="price"
        min={30}
        max={500}
        defaultRefinement={{ min: 50, max: 200 }}
      />
    </WrapWithHits>
  ))
  .add('playground', () => (
    <WrapWithHits linkedStoryGroup="RangeInput.stories.js">
      <RangeInput
        attribute="price"
        min={number('min', 0)}
        max={number('max', 500)}
        precision={number('precision', 0)}
        defaultRefinement={object('default value', { min: 100, max: 400 })}
        translations={object('translations', {
          submit: ' go',
          separator: 'to',
        })}
      />
    </WrapWithHits>
  ))
  .add('with Panel', () => (
    <WrapWithHits linkedStoryGroup="RangeInput.stories.js">
      <Panel header="Range Input" footer="Footer">
        <RangeInput attribute="price" />
      </Panel>
    </WrapWithHits>
  ))
  .add('with Panel but no refinement', () => (
    <WrapWithHits searchBox={false} linkedStoryGroup="RangeInput.stories.js">
      <Panel header="Range Input" footer="Footer">
        <RangeInput attribute="price" />
      </Panel>

      <div style={{ display: 'none' }}>
        <SearchBox defaultRefinement="ds" />
      </div>
    </WrapWithHits>
  ));