-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Added prevIconClass and nextIconClass props to Carousel with defaults… #793
Conversation
Huh. Why don't: react-bootstrap/src/Carousel.js Line 161 in d9b08d3
react-bootstrap/src/Carousel.js Line 169 in d9b08d3
use the I'd actually implement this as a replacement for the element inside the anchor, and default to the respective |
I would say as long as the glyphicons don't use a component, that class should be swappable. Maybe otherwise there could be a renderPrev: () => <span className="glyphicon glyphicon-chevron-left" />
renderNext: () => <span className="glyphicon glyphicon-chevron-right" /> However, many people using Bootstrap don't use glyphicons and this pull request seems to follow an existing pattern in code. |
@mfunkie presents the ideal solution. Being able to dump whatever you like inside of the anchor tag would give us the most flexibility. Since the glyphicon component wasn't being used in the Carousel, I was simply trying to stick with the established pattern. |
I mean set the default value to: The former is just a cleanup, and the latter seems to be a more correct way to model it than accepting a function or class name or whatever. |
I agree that allowing for the Glyphicon component and possibly swapping for something else would be ideal. For example allowing use of: https://github.com/andreypopp/react-fa. I don't know if the Carousel pre-dates the Glyphicon component or not, but definitely precedes my time with the library. A few more issues:
|
@taion Would it be a required prop if we have a default value? @mtscout6 The existing documentation for Carousel is a bit sparse, and thus overriding prev/next might seem out of place as far as I can see on the GitHub Pages site. Are there any plans to bring in usage of something like react-docgen and start documenting the propTypes in React Bootstrap? |
I'm not 100% sure on the |
@mfunkie It would still be required if that default prop was removed so yes I think it should still be required. |
Maybe my understanding of isRequired is flawed. As far as I know, isRequired's use case is only if there are no default props, otherwise it's not technically a required prop. Otherwise, all props would be 'isRequired', even if the component fails gracefully. |
I could be flawed as well, either should be fine I guess. Since there is a default than there will always be one, we can easily revisit the isRequired option if the default is ever removed. Which is partly why I don't think it hurts for it to be there. |
Per @taion 's suggestion ... Added two new props to the Carousel component: Added default props for the two new props above: |
Looks good now. Do we need tests for this? I think react-bootstrap/test/CarouselSpec.js Lines 109 to 110 in 12d6ddb
Will need to squash before merge. |
Tests would be appropriate to ensure those props are respected and not ignored. |
One last minor issue, can you amend your commit message to follow our guidelines as outlined in the Contributing Guide This will ensure that this change in documented in our changelog via our automated changelog tool. |
I was thinking the same, it allows you to glance at |
LGTM |
@mathieumg I wasn't thinking of auto generated docs, in which case you're right we shouldn't use @mcraiganthony Sorry to go back and forth on that. It's an issue that I myself have not investigated thoroughly enough, so I'll take the blame for how that went down. Can you go ahead and remove the |
I'll go ahead and remove those, sorry for all the confusion. |
Added prevIconClass and nextIconClass props to Carousel with defaults…
|
👍 |
Thanks @mtscout6 . Much appreciated. |
Allow specifying alternative icon classes in Carousel (refer to issue #502). I added two new props to the Carousel component that allow alternative icon classes to be passed to the previous and next buttons. If alternative icon classes are not passed, the Carousel defaults to using glyphicons. This gives developers the ability to use their own set of icons instead of being forced to use glyphicons.
Added two new props to the Carousel component:
prevIconClass: React.PropTypes.string
nextIconClass: React.PropTypes.string
Added default props for the two new props above:
prevIconClass: 'glyphicon glyphicon-chevron-left',
nextIconClass: 'glyphicon glyphicon-chevron-right'