mirror of
https://github.com/wassname/slider.git
synced 2026-09-09 11:35:22 +08:00
feat: support set style of specific mark point
This commit is contained in:
@@ -90,9 +90,9 @@ ReactDOM.render(<Rcslider />, container);
|
||||
</tr>
|
||||
<tr>
|
||||
<td>marks</td>
|
||||
<td>object {number: string}</td>
|
||||
<td>object{number: string} or object{number: object{ style, label }}</td>
|
||||
<td>{}</td>
|
||||
<td>Mark on the slider. The key determines the position, and the value determines what will show.</td>
|
||||
<td>Mark on the slider. The key determines the position, and the value determines what will show. If you want to set the style of a specific mark point, the value should be an object which contains `style` and `label` properties.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>step</td>
|
||||
|
||||
+6
-1
@@ -11,7 +11,12 @@ const marks = {
|
||||
26: '26°C',
|
||||
37: '37°C',
|
||||
50: '50°C',
|
||||
100: '100°C',
|
||||
100: {
|
||||
style: {
|
||||
color: 'red',
|
||||
},
|
||||
label: '100°C',
|
||||
},
|
||||
};
|
||||
|
||||
function log(value) {
|
||||
|
||||
+7
-2
@@ -19,8 +19,13 @@ const Marks = ({className, marks, included, upperBound, lowerBound, max, min}) =
|
||||
const style = { width: markWidth + '%' };
|
||||
style.left = (point - min) / range * 100 - markWidth / 2 + '%';
|
||||
|
||||
return (<span className={markClassName} style={style} key={point}>
|
||||
{marks[point]}
|
||||
const markPoint = marks[point];
|
||||
const markPointIsObject = typeof markPoint === 'object';
|
||||
const markLabel = markPointIsObject ? markPoint.label : markPoint;
|
||||
const markStyle = markPointIsObject ?
|
||||
{ ...style, ...markPoint.style } : style;
|
||||
return (<span className={markClassName} style={markStyle} key={point}>
|
||||
{markLabel}
|
||||
</span>);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user