mirror of
https://github.com/wassname/slider.git
synced 2026-09-09 11:35:22 +08:00
feat: support React.Component in marks
This commit is contained in:
+2
-2
@@ -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
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user