Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/keep-pushable
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin-front committed Nov 6, 2017
2 parents 3e74742 + e296bd5 commit 8437ce8
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 16 deletions.
6 changes: 0 additions & 6 deletions assets/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@
cursor: pointer;
border-radius: 50%;
vertical-align: middle;
&:first-child {
margin-left: -4px;
}
&:last-child {
margin-left: -4px;
}
&-active {
border-color: tint(@primary-color, 50%);
}
Expand Down
17 changes: 13 additions & 4 deletions examples/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,12 @@ class ControlledRangeDisableAcross extends React.Component {
}
render() {
return (
<Range value={this.state.value} onChange={this.handleChange} allowCross={false} />
<Range
value={this.state.value}
onChange={this.handleChange}
allowCross={false}
{...this.props}
/>
);
}
}
Expand Down Expand Up @@ -175,9 +180,13 @@ ReactDOM.render(
<ControlledRange />
</div>
<div style={style}>
<p>Controlled Range, not allow across</p>
<ControlledRangeDisableAcross />
</div>
<p>Controlled Range, not allow across</p>
<ControlledRangeDisableAcross />
</div>
<div style={style}>
<p>Controlled Range, not allow across, pushable</p>
<ControlledRangeDisableAcross pushable/>
</div>
<div style={style}>
<p>Multi Range</p>
<Range count={3} defaultValue={[20, 40, 60, 80]} pushable />
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"jest": "^20.0.0",
"pre-commit": "1.x",
"rc-tools": "6.x",
"rc-trigger": "^2.2.0",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-test-renderer": "^16.0.0"
Expand Down
13 changes: 8 additions & 5 deletions src/common/Marks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ const Marks = ({

const range = max - min;
const elements = marksKeys.map(parseFloat).sort((a, b) => a - b).map(point => {
const markPoint = marks[point];
const markPointIsObject = typeof markPoint === 'object' &&
!React.isValidElement(markPoint);
const markLabel = markPointIsObject ? markPoint.label : markPoint;
if (!markLabel) {
return null;
}

const isActive = (!included && point === upperBound) ||
(included && point <= upperBound && point >= lowerBound);
const markClassName = classNames({
Expand All @@ -36,11 +44,6 @@ const Marks = ({
};

const style = vertical ? bottomStyle : leftStyle;

const markPoint = marks[point];
const markPointIsObject = typeof markPoint === 'object' &&
!React.isValidElement(markPoint);
const markLabel = markPointIsObject ? markPoint.label : markPoint;
const markStyle = markPointIsObject ?
{ ...style, ...markPoint.style } : style;
return (
Expand Down
3 changes: 3 additions & 0 deletions tests/__mocks__/rc-trigger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Trigger from 'rc-trigger/lib/mock';

export default Trigger;
2 changes: 1 addition & 1 deletion tests/common/marks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { Range } = Slider;

describe('marks', () => {
it('should render marks correctly when `marks` is not an empty object', () => {
const marks = { 0: '0', 30: '30', 100: '100' };
const marks = { 0: '0', 30: '30', 99: '', 100: '100' };

const sliderWrapper = mount(<Slider value={30} marks={marks} />);
expect(sliderWrapper.find('.rc-slider-mark-text').length).toBe(3);
Expand Down

0 comments on commit 8437ce8

Please sign in to comment.