import Slider from '../index'
import '../assets/index.less'
const { Range } = Slider
function log (value) {
console.log(value); //eslint-disable-line
}
const CustomizedRange = {
data () {
return {
lowerBound: 20,
upperBound: 40,
value: [20, 40],
}
},
methods: {
onLowerBoundChange (e) {
this.lowerBound = +e.target.value
},
onUpperBoundChange (e) {
this.upperBound = +e.target.value
},
onSliderChange (value) {
log(value)
this.value = value
},
handleApply () {
this.value = [this.lowerBound, this.upperBound]
},
},
render () {
return (
)
},
}
const DynamicBounds = {
data () {
return {
min: 0,
max: 100,
}
},
methods: {
onSliderChange (value) {
log(value)
},
onMinChange (e) {
this.min = +e.target.value || 0
},
onMaxChange (e) {
this.max = +e.target.value || 100
},
},
render () {
return (
)
},
}
const ControlledRange = {
data () {
return {
value: [20, 40, 60, 80],
}
},
methods: {
handleChange (value) {
this.value = value
},
},
render () {
return
},
}
const ControlledRangeDisableAcross = {
props: {
pushable: [Number, Boolean],
},
data () {
return {
value: [20, 40, 60, 80],
}
},
methods: {
handleChange (value) {
this.value = value
},
},
render () {
const rangeRange = {
props: {
value: this.value,
allowCross: false,
...this.$props,
},
on: {
change: this.handleChange,
},
}
return
},
}
const PureRenderRange = {
data () {
return {
foo: false,
}
},
methods: {
handleChange (value) {
console.log(value)
this.foo = !this.foo
},
},
render () {
return
},
}
export default {
render () {
const style = { width: '400px', margin: '50px' }
const pStyle = { margin: '20px 0' }
return (
Basic Range,`allowCross=false`
Basic Range,`step=20, dots`
Controlled Range, not allow across
Controlled Range, not allow across, pushable=5
Multi Range with custom track and handle style
Range with dynamic `max` `min`
)
},
}