From a4795453b8deb78a0b23ad118f36f7c868b6c517 Mon Sep 17 00:00:00 2001 From: simaQ Date: Tue, 14 Jul 2015 12:06:44 +0800 Subject: [PATCH] update slider demo --- components/slider/demo/basic.md | 14 +++ components/slider/demo/icon-slider.md | 94 +++++++++++++++++++ components/slider/demo/input-number-slider.md | 45 +++++++++ components/slider/demo/mark.md | 12 ++- 4 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 components/slider/demo/icon-slider.md create mode 100644 components/slider/demo/input-number-slider.md diff --git a/components/slider/demo/basic.md b/components/slider/demo/basic.md index 6a1ba462e0..65268b67e3 100644 --- a/components/slider/demo/basic.md +++ b/components/slider/demo/basic.md @@ -10,7 +10,21 @@ var Slider = antd.Slider; React.render( +
+ +
, document.getElementById('components-slider-demo-basic')); ```` + \ No newline at end of file diff --git a/components/slider/demo/icon-slider.md b/components/slider/demo/icon-slider.md new file mode 100644 index 0000000000..4298b57687 --- /dev/null +++ b/components/slider/demo/icon-slider.md @@ -0,0 +1,94 @@ +# 带 icon 的滑块 + +- order: 2 + +--- + +````jsx +var Slider = antd.Slider; + +var IconSlider = React.createClass({ + getInitialState() { + var max = this.props.max; + var min = this.props.min; + var mid = ((max - min) / 2).toFixed(5); + + var preIcon, nextIcon; + if (this.props.value >= mid) { + preIcon = this.props.icon[0]; + nextIcon = this.props.icon[1] + ' anticon-highlight'; + } else { + preIcon = this.props.icon[0] + ' anticon-highlight'; + nextIcon = this.props.icon[1]; + } + + return { + preIcon: preIcon, + nextIcon: nextIcon, + mid: mid, + sliderValue: this.props.value + }; + }, + + handleChange(v) { + var preIcon, nextIcon; + if (v >= this.state.mid) { + preIcon = this.props.icon[0]; + nextIcon = this.props.icon[1] + ' anticon-highlight'; + } else { + preIcon = this.props.icon[0] + ' anticon-highlight'; + nextIcon = this.props.icon[1]; + } + + this.setState( + { + preIcon: preIcon, + nextIcon: nextIcon, + sliderValue: v + } + ); + }, + + render() { + return ( +
+ + + +
+ ); + } +}); + +React.render( + +, document.getElementById('components-slider-demo-icon-slider')); +```` + + \ No newline at end of file diff --git a/components/slider/demo/input-number-slider.md b/components/slider/demo/input-number-slider.md new file mode 100644 index 0000000000..a423550a3a --- /dev/null +++ b/components/slider/demo/input-number-slider.md @@ -0,0 +1,45 @@ +# 带输入框的滑块 + +- order: 1 + + + +--- + +````jsx +var Slider = antd.Slider; +var InputNumber = antd.InputNumber; + +var Test = React.createClass({ + getInitialState() { + return { + inputValue: 0 + }; + }, + onChange(v){ + this.setState({ + inputValue: v + }); + }, + render() { + return ( +
+
+ +
+
+ +
+
+ ); + } +}); + +React.render(, document.getElementById('components-slider-demo-input-number-slider')); +```` + + diff --git a/components/slider/demo/mark.md b/components/slider/demo/mark.md index f20d5150d8..dc704a8ef9 100644 --- a/components/slider/demo/mark.md +++ b/components/slider/demo/mark.md @@ -10,7 +10,17 @@ var Slider = antd.Slider; React.render( - +
+

包含关系

+ +

并列关系

+ +
, document.getElementById('components-slider-demo-mark')); ```` + \ No newline at end of file