2019-01-12 03:33:27 +00:00
|
|
|
|
import Slider from '../index';
|
|
|
|
|
import Tooltip from '../../vc-tooltip';
|
|
|
|
|
import '../assets/index.less';
|
|
|
|
|
import '../../vc-tooltip/assets/bootstrap.less';
|
2018-03-29 06:32:43 +00:00
|
|
|
|
|
2019-03-01 14:58:46 +00:00
|
|
|
|
const { createSliderWithTooltip } = Slider;
|
2018-03-29 06:32:43 +00:00
|
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
|
function log(value) {
|
2018-03-29 06:32:43 +00:00
|
|
|
|
console.log(value); //eslint-disable-line
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const CustomizedSlider = {
|
2019-01-12 03:33:27 +00:00
|
|
|
|
data() {
|
2018-03-29 06:32:43 +00:00
|
|
|
|
return {
|
|
|
|
|
value: 50,
|
2019-01-12 03:33:27 +00:00
|
|
|
|
};
|
2018-03-29 06:32:43 +00:00
|
|
|
|
},
|
|
|
|
|
methods: {
|
2019-01-12 03:33:27 +00:00
|
|
|
|
onSliderChange(value) {
|
|
|
|
|
log(value);
|
|
|
|
|
this.value = value;
|
2018-03-29 06:32:43 +00:00
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
|
onAfterChange(value) {
|
|
|
|
|
log(value);
|
2018-03-29 06:32:43 +00:00
|
|
|
|
},
|
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
|
render() {
|
|
|
|
|
return (
|
|
|
|
|
<Slider
|
|
|
|
|
value={this.value}
|
|
|
|
|
onChange={this.onSliderChange}
|
|
|
|
|
onAfterChange={this.onAfterChange}
|
|
|
|
|
/>
|
|
|
|
|
);
|
2018-03-29 06:32:43 +00:00
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
|
};
|
2018-03-29 06:32:43 +00:00
|
|
|
|
|
|
|
|
|
const DynamicBounds = {
|
2019-01-12 03:33:27 +00:00
|
|
|
|
data() {
|
2018-03-29 06:32:43 +00:00
|
|
|
|
return {
|
|
|
|
|
min: 0,
|
|
|
|
|
max: 100,
|
2019-01-12 03:33:27 +00:00
|
|
|
|
};
|
2018-03-29 06:32:43 +00:00
|
|
|
|
},
|
|
|
|
|
methods: {
|
2019-01-12 03:33:27 +00:00
|
|
|
|
onSliderChange(value) {
|
|
|
|
|
log(value);
|
|
|
|
|
this.value = value;
|
2018-03-29 06:32:43 +00:00
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
|
onAfterChange(value) {
|
|
|
|
|
log(value);
|
2018-03-29 06:32:43 +00:00
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
|
onMinChange(e) {
|
|
|
|
|
this.min = +e.target.value || 0;
|
2018-03-29 06:32:43 +00:00
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
|
onMaxChange(e) {
|
|
|
|
|
this.max = +e.target.value || 100;
|
2018-03-29 06:32:43 +00:00
|
|
|
|
},
|
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
|
render() {
|
2018-03-29 06:32:43 +00:00
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<label>Min: </label>
|
2019-01-12 03:33:27 +00:00
|
|
|
|
<input type="number" value={this.min} onInput={this.onMinChange} />
|
2018-03-29 06:32:43 +00:00
|
|
|
|
<br />
|
|
|
|
|
<label>Max: </label>
|
2019-01-12 03:33:27 +00:00
|
|
|
|
<input type="number" value={this.max} onInput={this.onMaxChange} />
|
|
|
|
|
<br />
|
|
|
|
|
<br />
|
|
|
|
|
<Slider defaultValue={50} min={this.min} max={this.max} onChange={this.onSliderChange} />
|
2018-03-29 06:32:43 +00:00
|
|
|
|
</div>
|
2019-01-12 03:33:27 +00:00
|
|
|
|
);
|
2018-03-29 06:32:43 +00:00
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
|
};
|
2018-03-29 06:32:43 +00:00
|
|
|
|
|
2019-03-01 14:58:46 +00:00
|
|
|
|
const SliderWithTooltip = createSliderWithTooltip(Slider);
|
2018-03-29 06:32:43 +00:00
|
|
|
|
|
|
|
|
|
export default {
|
2019-01-12 03:33:27 +00:00
|
|
|
|
render() {
|
|
|
|
|
const style = { width: '400px', margin: '50px' };
|
|
|
|
|
const pStyle = { margin: '20px 0' };
|
2018-03-29 06:32:43 +00:00
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<div style={style}>
|
|
|
|
|
<p style={pStyle}>Basic Slider</p>
|
|
|
|
|
<Slider onChange={log} />
|
|
|
|
|
</div>
|
|
|
|
|
<div style={style}>
|
|
|
|
|
<p style={pStyle}>Basic Slider,`step=20`</p>
|
|
|
|
|
<Slider step={20} defaultValue={50} onBeforeChange={log} />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div style={style}>
|
|
|
|
|
<p style={pStyle}>Basic Slider,`step=20, dots`</p>
|
|
|
|
|
<Slider dots step={20} defaultValue={100} onAfterChange={log} />
|
|
|
|
|
</div>
|
|
|
|
|
<div style={style}>
|
2019-01-12 03:33:27 +00:00
|
|
|
|
<p style={pStyle}>
|
|
|
|
|
Basic Slider,`step=20, dots, dotStyle={"{borderColor: 'orange'}"}, activeDotStyle=
|
|
|
|
|
{"{borderColor: 'yellow'}"}`
|
|
|
|
|
</p>
|
|
|
|
|
<Slider
|
|
|
|
|
dots
|
|
|
|
|
step={20}
|
|
|
|
|
defaultValue={100}
|
|
|
|
|
onAfterChange={log}
|
|
|
|
|
dotStyle={{ borderColor: 'orange' }}
|
|
|
|
|
activeDotStyle={{ borderColor: 'yellow' }}
|
|
|
|
|
/>
|
2018-03-29 06:32:43 +00:00
|
|
|
|
</div>
|
|
|
|
|
<div style={style}>
|
|
|
|
|
<p style={pStyle}>Slider with tooltip, with custom `tipFormatter`</p>
|
2019-03-01 14:58:46 +00:00
|
|
|
|
<SliderWithTooltip
|
|
|
|
|
tipFormatter={v => `${v} %`}
|
|
|
|
|
tipProps={{ overlayClassName: 'foo' }}
|
|
|
|
|
onChange={log}
|
|
|
|
|
/>
|
2018-03-29 06:32:43 +00:00
|
|
|
|
</div>
|
|
|
|
|
<div style={style}>
|
2019-01-12 03:33:27 +00:00
|
|
|
|
<p style={pStyle}>
|
|
|
|
|
Slider with custom handle and track style.<strong>(old api, will be deprecated)</strong>
|
|
|
|
|
</p>
|
2018-03-29 06:32:43 +00:00
|
|
|
|
<Slider
|
|
|
|
|
defaultValue={30}
|
|
|
|
|
maximumTrackStyle={{ backgroundColor: 'red', height: '10px' }}
|
|
|
|
|
minimumTrackStyle={{ backgroundColor: 'blue', height: '10px' }}
|
|
|
|
|
handleStyle={{
|
|
|
|
|
borderColor: 'blue',
|
|
|
|
|
height: '28px',
|
|
|
|
|
width: '28px',
|
|
|
|
|
marginLeft: '-14px',
|
|
|
|
|
marginTop: '-9px',
|
|
|
|
|
backgroundColor: 'black',
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div style={style}>
|
2019-01-12 03:33:27 +00:00
|
|
|
|
<p style={pStyle}>
|
|
|
|
|
Slider with custom handle and track style.<strong>(The recommended new api)</strong>
|
|
|
|
|
</p>
|
2018-03-29 06:32:43 +00:00
|
|
|
|
<Slider
|
|
|
|
|
defaultValue={30}
|
|
|
|
|
trackStyle={{ backgroundColor: 'blue', height: '10px' }}
|
|
|
|
|
handleStyle={{
|
|
|
|
|
borderColor: 'blue',
|
|
|
|
|
height: '28px',
|
|
|
|
|
width: '28px',
|
|
|
|
|
marginLeft: '-14px',
|
|
|
|
|
marginTop: '-9px',
|
|
|
|
|
backgroundColor: 'black',
|
|
|
|
|
}}
|
|
|
|
|
railStyle={{ backgroundColor: 'red', height: '10px' }}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div style={style}>
|
|
|
|
|
<p style={pStyle}>Basic Slider, disabled</p>
|
|
|
|
|
<Slider onChange={log} disabled />
|
|
|
|
|
</div>
|
|
|
|
|
<div style={style}>
|
|
|
|
|
<p style={pStyle}>Controlled Slider</p>
|
|
|
|
|
<Slider value={50} />
|
|
|
|
|
</div>
|
|
|
|
|
<div style={style}>
|
|
|
|
|
<p style={pStyle}>Customized Slider</p>
|
|
|
|
|
<CustomizedSlider />
|
|
|
|
|
</div>
|
|
|
|
|
<div style={style}>
|
|
|
|
|
<p style={pStyle}>Slider with dynamic `min` `max`</p>
|
|
|
|
|
<DynamicBounds />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2019-01-12 03:33:27 +00:00
|
|
|
|
);
|
2018-03-29 06:32:43 +00:00
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
|
};
|