From 7991918a9660648e9fc6a8d479cba3302fa9f720 Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Fri, 30 Oct 2015 16:52:25 +0800 Subject: [PATCH] feat: rename APIs --- README.md | 6 +++--- examples/simple.js | 6 +++--- src/Marks.jsx | 4 ++-- src/Slider.jsx | 18 +++++++++--------- src/Steps.jsx | 6 +++--- tests/index.spec.js | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index b1b1521..be4ae1a 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ ReactDOM.render(, container); Mark every step for the slider, it will ignore the `step` parameter if it has been defined. Does not work with `range` - isIncluded + included boolean true If the value is `true`, it means a continuous value interval, otherwise, it is a independent value. @@ -161,10 +161,10 @@ ReactDOM.render(, container); Set the animation for tooltip if it shows. - withDots + dots bool false - For linear slider, when the `step` value is greater than 1, you can set the `withDots` to `true` if you want to render the slider bar with dots. + For linear slider, when the `step` value is greater than 1, you can set the `dots` to `true` if you want to render the slider bar with dots. diff --git a/examples/simple.js b/examples/simple.js index 7f588f8..7a13ad0 100644 --- a/examples/simple.js +++ b/examples/simple.js @@ -22,7 +22,7 @@ React.render(

基础滑块,step=20 带原点

- +

双滑块

@@ -30,7 +30,7 @@ React.render(

双滑块,step=20

- +

分段式滑块(包含关系)

@@ -38,7 +38,7 @@ React.render(

分段式滑块(并列关系)

- +
, document.getElementById('__react-content')); diff --git a/src/Marks.jsx b/src/Marks.jsx index d4afefa..7a03023 100644 --- a/src/Marks.jsx +++ b/src/Marks.jsx @@ -1,14 +1,14 @@ import React from 'react'; import rcUtil from 'rc-util'; -const Marks = ({className, marks, index, isIncluded}) => { +const Marks = ({className, marks, index, included}) => { const marksLen = marks.length; const unit = 100 / (marksLen - 1); const markWidth = unit / 2 + '%'; const elements = []; for (let i = 0; i < marksLen; i++) { - const isActived = (isIncluded && i <= index) || (!isIncluded && i === index); + const isActived = (included && i <= index) || (!included && i === index); const markClassName = rcUtil.classSet({ [className + '-text']: true, [className + '-text-active']: isActived, diff --git a/src/Slider.jsx b/src/Slider.jsx index 9ea885e..88cdf79 100644 --- a/src/Slider.jsx +++ b/src/Slider.jsx @@ -305,7 +305,7 @@ class Slider extends React.Component { render() { const {handle, upperBound, lowerBound} = this.state; const props = this.props; - const {className, prefixCls, disabled, isIncluded, withDots, range} = props; + const {className, prefixCls, disabled, included, dots, range} = props; const {marks, step, max, min, tipTransitionName, children} = props; const marksLen = marks.length; @@ -319,7 +319,7 @@ class Slider extends React.Component { const lowerOffset = this.calcOffset(lowerBound); let track = null; - if (isIncluded || range) { + if (included || range) { const trackClassName = prefixCls + '-track'; track = ; } @@ -338,19 +338,19 @@ class Slider extends React.Component { const upperIndex = this.getIndex(upperBound); let steps = null; - if (marksLen > 0 || (step > 1 && withDots)) { + if (marksLen > 0 || (step > 1 && dots)) { const stepsClassName = prefixCls + '-step'; const stepNum = marksLen > 0 ? marksLen : Math.floor((max - min) / step) + 1; steps = (); + included={included || range} />); } let mark = null; if (marksLen > 0) { const markClassName = prefixCls + '-mark'; mark = (); + index={upperIndex} included={included} />); } return ( @@ -379,7 +379,7 @@ Slider.propTypes = { values: React.PropTypes.arrayOf(React.PropTypes.number), index: React.PropTypes.number, marks: React.PropTypes.array, - isIncluded: React.PropTypes.bool, + included: React.PropTypes.bool, className: React.PropTypes.string, prefixCls: React.PropTypes.string, disabled: React.PropTypes.bool, @@ -388,7 +388,7 @@ Slider.propTypes = { onChange: React.PropTypes.func, onAfterChange: React.PropTypes.func, tipTransitionName: React.PropTypes.string, - withDots: React.PropTypes.bool, + dots: React.PropTypes.bool, range: React.PropTypes.bool, }; @@ -400,12 +400,12 @@ Slider.defaultProps = { defaultValues: [0, 0], defaultIndex: 0, marks: [], - isIncluded: true, + included: true, className: '', prefixCls: 'rc-slider', disabled: false, tipTransitionName: '', - withDots: false, + dots: false, range: false, }; diff --git a/src/Steps.jsx b/src/Steps.jsx index ea7ec08..da2cdb0 100644 --- a/src/Steps.jsx +++ b/src/Steps.jsx @@ -1,7 +1,7 @@ import React from 'react'; import rcUtil from 'rc-util'; -const Steps = ({className, stepNum, isIncluded, lowerIndex, upperIndex}) => { +const Steps = ({className, stepNum, included, lowerIndex, upperIndex}) => { const dotClassName = className.replace('step', 'dot'); const unit = 100 / (stepNum - 1); @@ -10,8 +10,8 @@ const Steps = ({className, stepNum, isIncluded, lowerIndex, upperIndex}) => { const offset = unit * i + '%'; const style = { left: offset }; - const isActived = (isIncluded && i <= upperIndex && i >= lowerIndex ) || - (!isIncluded && i === upperIndex); + const isActived = (included && i <= upperIndex && i >= lowerIndex ) || + (!included && i === upperIndex); const stepClassName = rcUtil.classSet({ [dotClassName]: true, [dotClassName + '-active']: isActived, diff --git a/tests/index.spec.js b/tests/index.spec.js index b2b5057..742585e 100644 --- a/tests/index.spec.js +++ b/tests/index.spec.js @@ -43,7 +43,7 @@ describe('rc-slider', function () { expect(slider.state.upperBound).to.be(0); var sliderWithDots = React.render( - , + , div ); var node1 = $(div);