-
-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
import React, { PropTypes } from 'react'; | ||
import assign from 'object-assign'; | ||
|
||
export default class Handle extends React.Component { | ||
render() { | ||
const { | ||
className, vertical, offset, minimumTrackTintColor, disabled, ...restProps, | ||
className, vertical, offset, handleStyle, ...restProps, | ||
} = this.props; | ||
const style = vertical ? { bottom: `${offset}%` } : { left: `${offset}%` }; | ||
if (minimumTrackTintColor && !disabled) { | ||
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 commentThe 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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
} | ||
|
||
Handle.propTypes = { | ||
className: PropTypes.string, | ||
vertical: PropTypes.bool, | ||
offset: PropTypes.number, | ||
minimumTrackTintColor: PropTypes.string, | ||
disabled: PropTypes.bool, | ||
handleStyle: PropTypes.object, | ||
}; |
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.
@benjycui 没啊,RN 官方也这么命名的 http://facebook.github.io/react-native/releases/next/docs/slider.html
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 来了