-
-
Notifications
You must be signed in to change notification settings - Fork 776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support custom track & handle style, for react-tiny #249
Conversation
2a51f4a
to
11d765e
Compare
examples/slider.js
Outdated
@@ -102,6 +102,10 @@ ReactDOM.render( | |||
<Slider tipFormatter={null} onChange={log} /> | |||
</div> | |||
<div style={style}> | |||
<p>custo Slider handle and track style</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
custom
typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paranoidjk done
11d765e
to
b9c73bb
Compare
Why not just
|
@benjycui for react-tiny, gitlab/react-tiny/issue/85, use xxx-color or xxx-size;
but https://github.com/react-component/slider/pull/249/files#diff-9c6be5d20cab58fc76addf3a454a2dafR20; Normally it is enough to custom style use |
@silentcloud minimumTrackTintColor |
|
b9c73bb
to
c3df6dc
Compare
style.borderColor = minimumTrackTintColor; | ||
} | ||
return <div {...restProps} className={className} style={style} />; | ||
return <div {...restProps} className={className} style={assign({}, style, handleStyle)} />; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
disabled 的背景色逻辑不需要了?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why import object-assign here when you're literally spreading objects all over?
This should be style={{...style, ...handleStyle}}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
track 有个 border-radius 而 rail 没有,底色不同的时候左侧就会露出来 @silentcloud 也顺手改下吧 https://github.com/react-component/slider/blob/master/assets/index.less#L43 https://github.com/react-component/slider/blob/master/assets/index.less#L32 |
c3df6dc
to
a1d31f1
Compare
a1d31f1
to
1ca4303
Compare
src/common/Track.jsx
Outdated
} | ||
return <div className={className} style={style} />; | ||
|
||
const trackStyle = disabled ? style : assign({}, style, minimumTrackStyle); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样感觉有点怪,minimumTrackStyle 用处是自定义样式,除了颜色还有宽高也可能会变,这样如何:
const baseTrackStyle = assign({}, style, minimumTrackStyle);
const disabledTrackStyle = {
// 原来 disable 的样式逻辑
};
const trackStyle = disabled ? assign(baseTrackStyle, disabledTrackStyle) : baseTrackStyle;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paranoidjk 我就是按照没加 minimumTintColor 的时候的逻辑搞的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
恩,主要是我们的api 从 minimumTintColor 自定义颜色 扩大到了 minimumTrackStyle 自定义样式,如果用户发现 disable 的时候他自定义的样式全没了,就不太合理。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我直接把 disabled 去掉好了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok,把 disabled 的样式逻辑去掉也行。
1ca4303
to
db4a0f1
Compare
@silentcloud 7.0.0 |
@@ -105,8 +105,9 @@ The following APIs are shared by Slider and Range. | |||
| onBeforeChange | Function | NOOP | `onBeforeChange` will be triggered when `ontouchstart` or `onmousedown` is triggered. | | |||
| onChange | Function | NOOP | `onChange` will be triggered while the value of Slider changing. | | |||
| onAfterChange | Function | NOOP | `onAfterChange` will be triggered when `ontouchend` or `onmouseup` is triggered. | | |||
| minimumTrackTintColor | String | | The color used for the track to the left of the button. | | |||
| maximumTrackTintColor | String | | The color used for the track to the right of the button. | | |||
| minimumTrackStyle | Object |`{}` | The style used for the track to the left of the button. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
看了源码和内网 issue 才知道这个 API 是干嘛用的 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对于单滑块,这个命名是没问题的,但对于多滑块,就含义不清了。。不过算了,先用着看看吧。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
恩多滑块貌似是不适合,当时也没想到好名字,就跟着 RN 来了
Was the handleSize prop also added to Range or just Slider? Would love to have this functionality for Range as well. |
No description provided.