diff --git a/examples/custom-handles.js b/examples/custom-handles.js index a306f4f..7a50e90 100644 --- a/examples/custom-handles.js +++ b/examples/custom-handles.js @@ -19,7 +19,7 @@ const handleStyle = { }; const CustomHandle = props => { - const style = Object.assign({ left: props.offset + '%' }, handleStyle); + const style = Object.assign({ left: `${props.offset}%` }, handleStyle); return (
val: {props.value}
); @@ -39,5 +39,6 @@ ReactDOM.render(

Slider with custom handle

} /> - - , document.getElementById('__react-content')); + , + document.getElementById('__react-content') +); diff --git a/examples/range.js b/examples/range.js index 5cf1836..de589fb 100644 --- a/examples/range.js +++ b/examples/range.js @@ -81,7 +81,9 @@ const DynamicBounds = React.createClass({

- + ); }, diff --git a/examples/slider.js b/examples/slider.js index 01b193f..ee6f9ab 100644 --- a/examples/slider.js +++ b/examples/slider.js @@ -13,7 +13,7 @@ function log(value) { function percentFormatter(v) { - return v + ' %'; + return `${v} %`; } const CustomizedSlider = React.createClass({ @@ -32,7 +32,11 @@ const CustomizedSlider = React.createClass({ console.log(value); }, render() { - return ; + return ( + + ); }, }); @@ -65,7 +69,9 @@ const DynamicBounds = React.createClass({

- + ); }, @@ -87,7 +93,9 @@ ReactDOM.render(

Basic Slider with `tipFormatter`

- +

Basic Slider without tooltip

diff --git a/examples/v-marks.js b/examples/v-marks.js index 22143dd..2b9d856 100644 --- a/examples/v-marks.js +++ b/examples/v-marks.js @@ -49,7 +49,9 @@ ReactDOM.render(

Range with marks and steps

- +
, document.getElementById('__react-content')); diff --git a/examples/v-range.js b/examples/v-range.js index c8522b3..678ba43 100644 --- a/examples/v-range.js +++ b/examples/v-range.js @@ -39,7 +39,9 @@ const CustomizedRange = React.createClass({ render() { return (
- +
@@ -75,7 +77,9 @@ const DynamicBounds = React.createClass({ render() { return (
- +
diff --git a/examples/v-slider.js b/examples/v-slider.js index 21360f8..8d009fb 100644 --- a/examples/v-slider.js +++ b/examples/v-slider.js @@ -14,7 +14,7 @@ function log(value) { function percentFormatter(v) { - return v + ' %'; + return `${v} %`; } const CustomizedSlider = React.createClass({ @@ -58,7 +58,9 @@ const DynamicBounds = React.createClass({ return (

Slider with dynamic `min` `max`

- +
@@ -85,7 +87,9 @@ ReactDOM.render(

Basic Slider with `tipFormatter`

- +

Basic Slider without tooltip

diff --git a/src/Handle.jsx b/src/Handle.jsx index 8a5449e..e3d16a5 100644 --- a/src/Handle.jsx +++ b/src/Handle.jsx @@ -35,7 +35,7 @@ export default class Handle extends React.Component { noTip, } = this.props; - const style = vertical ? { bottom: offset + '%' } : { left: offset + '%' }; + const style = vertical ? { bottom: `${offset}%` } : { left: `${offset}%` }; const handle = (
= lowerBound); const markClassName = classNames({ - [className + '-text']: true, - [className + '-text-active']: isActived, + [`${className}-text`]: true, + [`${className}-text-active`]: isActived, }); const bottomStyle = { // height: markWidth + '%', - marginBottom: '-200' + '%', - bottom: (point - min) / range * 100 + '%', + marginBottom: '-200%', + bottom: `${(point - min) / range * 100}%`, }; const leftStyle = { - width: markWidth + '%', - marginLeft: -markWidth / 2 + '%', - left: (point - min) / range * 100 + '%', + width: `${markWidth}%`, + marginLeft: `${-markWidth / 2}%`, + left: `${(point - min) / range * 100}%`, }; const style = vertical ? bottomStyle : leftStyle; diff --git a/src/Slider.jsx b/src/Slider.jsx index a83e929..beed01d 100644 --- a/src/Slider.jsx +++ b/src/Slider.jsx @@ -364,11 +364,15 @@ class Slider extends React.Component { addDocumentEvents(type) { if (type === 'touch') { // just work for chrome iOS Safari and Android Browser - this.onTouchMoveListener = addEventListener(document, 'touchmove', this.onTouchMove.bind(this)); - this.onTouchUpListener = addEventListener(document, 'touchend', this.end.bind(this, 'touch')); + this.onTouchMoveListener = + addEventListener(document, 'touchmove', this.onTouchMove.bind(this)); + this.onTouchUpListener = + addEventListener(document, 'touchend', this.end.bind(this, 'touch')); } else if (type === 'mouse') { - this.onMouseMoveListener = addEventListener(document, 'mousemove', this.onMouseMove.bind(this)); - this.onMouseUpListener = addEventListener(document, 'mouseup', this.end.bind(this, 'mouse')); + this.onMouseMoveListener = + addEventListener(document, 'mousemove', this.onMouseMove.bind(this)); + this.onMouseUpListener = + addEventListener(document, 'mouseup', this.end.bind(this, 'mouse')); } } @@ -413,7 +417,7 @@ class Slider extends React.Component { const offsets = bounds.map(v => this.calcOffset(v)); - const handleClassName = prefixCls + '-handle'; + const handleClassName = `${prefixCls}-handle`; const handlesClassNames = bounds.map((v, i) => classNames({ [handleClassName]: true, @@ -451,33 +455,36 @@ class Slider extends React.Component { [`${prefixCls}-track-${i}`]: true, }); tracks.push( - + ); } const sliderClassName = classNames({ [prefixCls]: true, - [prefixCls + '-disabled']: disabled, + [`${prefixCls}-disabled`]: disabled, [className]: !!className, - [prefixCls + '-vertical']: this.props.vertical, + [`${prefixCls}-vertical`]: this.props.vertical, }); return ( -
- {tracks} - - {handles} - - {children} -
+
+ {tracks} + + {handles} + + {children} +
); } } diff --git a/src/Steps.jsx b/src/Steps.jsx index 8234148..5c4da08 100644 --- a/src/Steps.jsx +++ b/src/Steps.jsx @@ -3,7 +3,10 @@ import classNames from 'classnames'; import warning from 'warning'; function calcPoints(vertical, marks, dots, step, min, max) { - warning(dots ? step > 0 : true, '`Slider[step]` should be a positive number in order to make Slider[dots] work.'); + warning( + dots ? step > 0 : true, + '`Slider[step]` should be a positive number in order to make Slider[dots] work.' + ); const points = Object.keys(marks).map(parseFloat); if (dots) { for (let i = min; i <= max; i = i + step) { @@ -18,20 +21,20 @@ const Steps = ({ prefixCls, vertical, marks, dots, step, included, lowerBound, upperBound, max, min }) => { const range = max - min; const elements = calcPoints(vertical, marks, dots, step, min, max).map((point) => { - const offset = Math.abs(point - min) / range * 100 + '%'; + const offset = `${Math.abs(point - min) / range * 100}%`; const style = vertical ? { bottom: offset } : { left: offset }; const isActived = (!included && point === upperBound) || (included && point <= upperBound && point >= lowerBound); const pointClassName = classNames({ - [prefixCls + '-dot']: true, - [prefixCls + '-dot-active']: isActived, + [`${prefixCls}-dot`]: true, + [`${prefixCls}-dot-active`]: isActived, }); return ; }); - return
{elements}
; + return
{elements}
; }; export default Steps; diff --git a/src/Track.jsx b/src/Track.jsx index dcc2cbe..32e9859 100644 --- a/src/Track.jsx +++ b/src/Track.jsx @@ -5,11 +5,11 @@ const Track = ({ className, included, vertical, offset, length }) => { visibility: included ? 'visible' : 'hidden', }; if (vertical) { - style.bottom = offset + '%'; - style.height = length + '%'; + style.bottom = `${offset}%`; + style.height = `${length}%`; } else { - style.left = offset + '%'; - style.width = length + '%'; + style.left = `${offset}%`; + style.width = `${length}%`; } return
; }; diff --git a/tests/index.js b/tests/index.js index 8c878a3..325139c 100644 --- a/tests/index.js +++ b/tests/index.js @@ -1,3 +1,4 @@ +/* eslint-disable max-len */ const expect = require('expect.js'); const React = require('react'); const ReactDOM = require('react-dom');