[slider] Add support for custom slider icon#12485
Conversation
This comment has been minimized.
This comment has been minimized.
eps1lon
left a comment
There was a problem hiding this comment.
When you have added the requested block comments run yarn docs:api.
Please add tests and examples to the documentation (see pages/lab/slider.js).
| const inlineThumbStyles = { [thumbProperty]: `${percent}%` }; | ||
|
|
||
| const Thumbnail = () => { | ||
| if (React.isValidElement(Thumb)) { |
There was a problem hiding this comment.
I'm not sure what the practice is in this package but if you would require the React.element prop-type this check would be redundant.
There was a problem hiding this comment.
Changed prop type to React.element, and removed this extra flag.
| <ButtonBase | ||
| className={thumbClasses} | ||
| className={ | ||
| Thumbnail() ? classNames(thumbClasses, classes.thumbTransparent) : thumbClasses |
There was a problem hiding this comment.
Two possibilities:
- Wouldn't it be more "semantic" to add a
with-iconclass (something along the line) inthumbClassesand letclassNamesto the conditional logic stuff? - Use
IconButtonif a thumb elment is provided instead ofButtonBase(which I'd prefer).
There was a problem hiding this comment.
I went with option 1 here, updated thumbClasses.
| if (React.isValidElement(Thumb)) { | ||
| return React.cloneElement(Thumb, { | ||
| ...Thumb.props, | ||
| className: classes.thumbIcon, |
There was a problem hiding this comment.
This overwrites existing classNames on the thumb. It should respect existing classNames.
There was a problem hiding this comment.
I have made changes now if the user adds classes to the thumb, it won't get over written.
| onFocusVisible={this.handleFocus} | ||
| /> | ||
| > | ||
| {Thumbnail()} |
There was a problem hiding this comment.
I would change the Thumbnail assignment so that you don't have to use this call syntax here. It's more in line with other components and also removes a second call to the function.
| * @ignore | ||
| */ | ||
| theme: PropTypes.object.isRequired, | ||
| thumb: PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.object]), |
There was a problem hiding this comment.
Please add a block comment and document this property and use PropTypes.element.
| thumbTransparent: { | ||
| backgroundColor: 'transparent', | ||
| }, | ||
| thumbIcon: { |
There was a problem hiding this comment.
Please add a block comment to document this className.
There was a problem hiding this comment.
I have added a small documentation to it.
|
@eps1lon first of all thank you so much for reviewing my PR, I have made changes as per your instructions. Do let me know if it still needs any tweaking. |
|
I think I made a mistake, I took a pull master and merged it in my feature-slider-thumbnail branch. And now there is a lot of code in the PR.. what should I do? Also I have no idea that why in |
|
The failing tests should've been resolve with #12535. Try rebasing or merging master again. Running For general advice about PR workflow I recommend https://gist.github.com/Chaser324/ce0505fbed06b947d962. |
|
@eps1lon I took a pull and merged this branch with master again, on running the tests after that merge all the tests where passing. But the Circleci build is failing. A bit information on how I ran the test, for Slider It ran the test and gave an output for After that when the build failed, I in my root folder ran |
|
@adeelibr CircleCI is just broken at the moment (https://discuss.circleci.com/t/saving-cache-stopped-working-warning-skipping-this-step-disabled-in-configuration/24423/2). Nothing you can do about it but patiently wait for a fix. |
|
@eps1lon so does that mean my PR is okay, that it can be merged? |
|
Rebase/merge again to include #12573 and we'll see if everything is ok. |
|
One test is still failing |
|
The branch is just very messy due to all the merge commits. In general if any In this case |
|
I have ran |
|
Looks like you ran |
|
@eps1lon i don't know what's happening this is what I am doing right now |
|
You are not running |
|
@eps1lon sorry, this is what i was doing what i did was I updated, one of my props definition that I added in this PR ran |
|
still failed.. |
|
I'm pretty sure you have your line endings set to This should probably be mentioned in Perfect solution would be to run |
|
I did this And ran I then saw the It is already configured for the use case that you have mentioned above, so back at square one I think.. |
|
It should be set to |
|
@eps1lon I have changed it from CRLF to LF, changed my git configuration's |
|
@oliviertassinari can we somehow change the regex https://github.com/mui-org/material-ui/blob/823fed03727bb6b52dbfc329472640b8e9da0e21/docs/scripts/buildApi.js#L112-L113 so that it is not dependent on the user side. |
|
@adeelibr I would try to replace the |
|
I have made another PR for this, to resolve this CRLF to LF issue. #12584 I have updated the regex, but it's still giving me the same error. @oliviertassinari |
|
This is what I did Then I made some changes in only the files I wanted to be committed. Which were; After that Isn't this how you wanted me to do it. @oliviertassinari But it committed those docs files as well. I am really bad at this.. sigh |
…o use classNames, class overirde issue resolved, changes Thumbnail assignment instead of call, added comments
a07aa25 to
432ed0b
Compare
I have added a new prop called
thumbto the Slider component, which you can use like this.