forked from algolia/vue-instantsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRangeInput.stories.js
136 lines (133 loc) · 3.7 KB
/
RangeInput.stories.js
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import { storiesOf } from '@storybook/vue';
import { previewWrapper } from './utils';
import VueSlider from 'vue-slider-component';
import 'vue-slider-component/theme/default.css';
import Vuetify from 'vuetify';
import 'vuetify/dist/vuetify.css';
import Vue from 'vue';
Vue.use(Vuetify);
storiesOf('ais-range-input', module)
.addDecorator(previewWrapper())
.add('default', () => ({
template: `
<ais-range-input attribute="price" />
`,
}))
.add('with precision', () => ({
template: `
<ais-range-input attribute="price" :precision="3" />
`,
}))
.add('with min', () => ({
template: `
<ais-range-input attribute="price" :min="10" />
`,
}))
.add('with max', () => ({
template: `
<ais-range-input attribute="price" :max="40" />
`,
}))
.add('with min and max', () => ({
template: `
<ais-range-input attribute="price" :min="10" :max="50" />
`,
}))
.add('with a custom render', () => ({
template: `
<ais-range-input attribute="price">
<template slot-scope="{ refine, currentRefinement }">
<form @submit.prevent="refine({ min, max })" >
<label>
<input
type="number"
:max="this.max"
:placeholder="this.max"
:value="currentRefinement.min"
@change="min = $event.currentTarget.value"
/>
</label>
<span>to</span>
<label >
<input
type="number"
:min="this.min"
:placeholder="this.max"
:value="currentRefinement.max"
@change="max = $event.currentTarget.value"
/>
</label>
<button type="submit">Go</button>
</form>
</template>
</ais-range-input>
`,
data() {
return {
min: undefined,
max: undefined,
};
},
}))
.add('with vue-slider-component', () => ({
template: `
<ais-range-input attribute="price">
<template
slot-scope="{
refine,
currentRefinement: { min: minValue, max: maxValue },
range: { min: minRange, max: maxRange }
}"
>
<vue-slider
:min="minRange"
:max="maxRange"
:lazy="true"
:value="[
typeof minValue === 'number' ? minValue : minRange,
typeof maxValue === 'number' ? maxValue : maxRange,
]"
@change="refine({ min: $event[0], max: $event[1] })"
/>
</template>
</ais-range-input>
`,
components: { VueSlider },
}))
.add('with vuetify slider', () => ({
template: `
<v-app>
<v-container mt-4>
<ais-range-input attribute="price">
<template
slot-scope="{
refine,
currentRefinement: { min: minValue, max: maxValue },
range: { min: minRange, max: maxRange }
}"
>
<v-range-slider
:min="minRange"
:max="maxRange"
:value="[
typeof minValue === 'number' ? minValue : minRange,
typeof maxValue === 'number' ? maxValue : maxRange,
]"
@input="refine({min: $event[0], max: $event[1]})"
thumb-label="always"
/>
</template>
</ais-range-input>
</v-container>
</v-app>
`,
}))
.add('with a Panel', () => ({
template: `
<ais-panel>
<template slot="header">Range Input</template>
<ais-range-input attribute="price" />
<template slot="footer">Footer</template>
</ais-panel>
`,
}));