feat: support React.Component in marks

This commit is contained in:
Benjy Cui
2016-03-22 16:53:38 +08:00
parent e030ba9f9d
commit 6a5573b6ca
2 changed files with 4 additions and 3 deletions
+2 -2
View File
@@ -7,7 +7,7 @@ const Slider = require('rc-slider');
const style = {width: 400, margin: 50};
const marks = {
'-10': '-10°C',
0: '0°C',
0: <strong>0°C</strong>,
26: '26°C',
37: '37°C',
50: '50°C',
@@ -15,7 +15,7 @@ const marks = {
style: {
color: 'red',
},
label: '100°C',
label: <strong>100°C</strong>,
},
};
+2 -1
View File
@@ -20,7 +20,8 @@ const Marks = ({className, marks, included, upperBound, lowerBound, max, min}) =
style.left = (point - min) / range * 100 - markWidth / 2 + '%';
const markPoint = marks[point];
const markPointIsObject = typeof markPoint === 'object';
const markPointIsObject = typeof markPoint === 'object' &&
!React.isValidElement(markPoint);
const markLabel = markPointIsObject ? markPoint.label : markPoint;
const markStyle = markPointIsObject ?
{ ...style, ...markPoint.style } : style;