Skip to content

Commit f571a1e

Browse files
tomoberryparanoidjk
authored andcommitted
Added dotStyle and activeDotStyle. This commit resolves #291 (#292)
1 parent 4feebbe commit f571a1e

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ The following APIs are shared by Slider and Range.
111111
| handleStyle | Array[Object] \| Object | `[{}]` | The style used for handle. (`both for slider(`Object`) and range(`Array of Object`), the array will be used for mutli handle follow element order`) |
112112
| trackStyle | Array[Object] \| Object | `[{}]` | The style used for track. (`both for slider(`Object`) and range(`Array of Object`), the array will be used for mutli track follow element order`)|w
113113
| railStyle | Object | `{}` | The style used for the track base color. |
114-
114+
| dotStyle | Object | `{}` | The style used for the dots. |
115+
| activeDotStyle | Object | `{}` | The style used for the active dots. |
115116
116117
### Slider
117118

examples/slider.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ ReactDOM.render(
9595
<p>Basic Slider,`step=20, dots`</p>
9696
<Slider dots step={20} defaultValue={100} onAfterChange={log} />
9797
</div>
98+
<div style={style}>
99+
<p>Basic Slider,`step=20, dots, dotStyle={"{borderColor: 'orange'}"}, activeDotStyle={"{borderColor: 'yellow'}"}`</p>
100+
<Slider dots step={20} defaultValue={100} onAfterChange={log} dotStyle={{ borderColor: 'orange' }} activeDotStyle={{ borderColor: 'yellow' }} />
101+
</div>
98102
<div style={style}>
99103
<p>Slider with tooltip, with custom `tipFormatter`</p>
100104
<SliderWithTooltip

src/common/Steps.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@ const calcPoints = (vertical, marks, dots, step, min, max) => {
1818
};
1919

2020
const Steps = ({ prefixCls, vertical, marks, dots, step, included,
21-
lowerBound, upperBound, max, min }) => {
21+
lowerBound, upperBound, max, min, dotStyle, activeDotStyle }) => {
2222
const range = max - min;
2323
const elements = calcPoints(vertical, marks, dots, step, min, max).map((point) => {
2424
const offset = `${Math.abs(point - min) / range * 100}%`;
25-
const style = vertical ? { bottom: offset } : { left: offset };
2625

2726
const isActived = (!included && point === upperBound) ||
2827
(included && point <= upperBound && point >= lowerBound);
28+
let style = vertical ? { bottom: offset, ...dotStyle } : { left: offset, ...dotStyle };
29+
if (isActived) {
30+
style = { ...style, ...activeDotStyle };
31+
}
32+
2933
const pointClassName = classNames({
3034
[`${prefixCls}-dot`]: true,
3135
[`${prefixCls}-dot-active`]: isActived,

src/common/createSlider.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ export default function createSlider(Component) {
3636
handleStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.arrayOf(PropTypes.object)]),
3737
trackStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.arrayOf(PropTypes.object)]),
3838
railStyle: PropTypes.object,
39+
dotStyle: PropTypes.object,
40+
activeDotStyle: PropTypes.object,
3941
};
4042

4143
static defaultProps = {
@@ -60,6 +62,8 @@ export default function createSlider(Component) {
6062
trackStyle: [{}],
6163
handleStyle: [{}],
6264
railStyle: {},
65+
dotStyle: {},
66+
activeDotStyle: {},
6367
};
6468

6569
constructor(props) {
@@ -216,6 +220,8 @@ export default function createSlider(Component) {
216220
maximumTrackStyle,
217221
style,
218222
railStyle,
223+
dotStyle,
224+
activeDotStyle,
219225
} = this.props;
220226
const { tracks, handles } = super.render();
221227

@@ -252,6 +258,8 @@ export default function createSlider(Component) {
252258
upperBound={this.getUpperBound()}
253259
max={max}
254260
min={min}
261+
dotStyle={dotStyle}
262+
activeDotStyle={activeDotStyle}
255263
/>
256264
{handles}
257265
<Marks

0 commit comments

Comments
 (0)