-
-
Notifications
You must be signed in to change notification settings - Fork 777
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
Allow callback for "dotStyle" and "activeDotStyle" props #828
Conversation
I have to use rc-slider to make a range selector, where the active range has a horizontal color gradient. I can style the trackline with pure CSS, but not the step dots. I even went to great extents with CSS by adding some creative attribute selectors based on the `style="left: ..."` values, which was enough to have the correct dot colors when the full range is selected. But when the range is set to a narrower state, the gradient changes too, and the dots can't adapt to that. I can only solve this with a callback where I can set the style based on the dot position and the slider value. This is what this PR is about.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Please change the type definition, and add some test case for this. |
Codecov Report
@@ Coverage Diff @@
## master #828 +/- ##
=======================================
Coverage 99.81% 99.81%
=======================================
Files 13 13
Lines 533 535 +2
Branches 135 137 +2
=======================================
+ Hits 532 534 +2
Misses 1 1
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
I've added the types. As for the tests, I can't run the test suite because of an error which I couldn't fix, even after googling around. I'm pasting the output below. I've tried it on Windows and macOS.
|
This pull request introduces 4 alerts when merging cbc16b2 into 410717a - view on LGTM.com new alerts:
|
Your types are wrong I believe, should be:
See the related CI alert from LGTM in comment above. You are also missing types updates in Slider.tsx for activeDotStyle and dotStyle props. |
Thanks, @yann-combarnous, for the suggestions. |
@yoyo837, I followed the steps for installation and test commands from the README, and I am getting the same errors as the PR author. So looks like some step is missing in the installation / contribution instructions. Any hint? I also removed any global Jest installation, as some suggested online. npm@8.1.2 |
@@ -97,8 +97,8 @@ The following APIs are shared by Slider and Range. | |||
| handleStyle | Array[Object] \| Object | `[{}]` | The style used for handle. (`both for slider(`Object`) and range(`Array of Object`), the array will be used for multi handle following element order`) | | |||
| trackStyle | Array[Object] \| Object | `[{}]` | The style used for track. (`both for slider(`Object`) and range(`Array of Object`), the array will be used for multi track following element order`)| | |||
| railStyle | Object | `{}` | The style used for the track base color. | | |||
| dotStyle | Object | `{}` | The style used for the dots. | | |||
| activeDotStyle | Object | `{}` | The style used for the active dots. | | |||
| dotStyle | Object or (dotValue) => Object | `{}` | The style used for the dots. | |
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.
| dotStyle | Object or (dotValue) => Object | `{}` | The style used for the dots. | | |
| dotStyle | Object \| (dotValue) => Object | `{}` | The style used for the dots. | |
| dotStyle | Object | `{}` | The style used for the dots. | | ||
| activeDotStyle | Object | `{}` | The style used for the active dots. | | ||
| dotStyle | Object or (dotValue) => Object | `{}` | The style used for the dots. | | ||
| activeDotStyle | Object or (dotValue) => Object | `{}` | The style used for the active dots. | |
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.
| activeDotStyle | Object or (dotValue) => Object | `{}` | The style used for the active dots. | | |
| activeDotStyle | Object \| (dotValue) => Object | `{}` | The style used for the active dots. | |
The failed does not seem to be caused by PR. |
Thx @yoyo837 , any chance a new release can be made to include this feature? |
I have to use rc-slider to make a range selector, where the active range has a horizontal color gradient. I can style the trackline with pure CSS, but not the step dots. I even went to great extents with CSS by adding some creative attribute selectors based on the
style="left: ..."
values, which was enough to have the correct dot colors when the full range is selected. But when the range is set to a narrower state, the gradient changes too, and the dots can't adapt to that. I can only solve this with a callback where I can set the style based on the dot position and the slider value. This is what this PR is about.