Skip to content

Added Carousel component. #587

Merged
tcbegley merged 15 commits intodbc-team:mainfrom
AnnMarieW:carousel
Jul 16, 2021
Merged

Added Carousel component. #587
tcbegley merged 15 commits intodbc-team:mainfrom
AnnMarieW:carousel

Conversation

@AnnMarieW
Copy link
Contributor

This PR adds a Carousel component -- as requested in #582

This is a work in progress and I hope this draft PR will make it easier to review different API options for the component.

Currently dcc.Carousel is a single component. It's possible to create separate components for the captions and headings, but so far, I find it more intuitive to format a slide with all the options in one dictionary.

When you have some time, it might be easier to run carousel.py, then we can discuss in more detail.

Copy link
Collaborator

@tcbegley tcbegley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Thanks so much @AnnMarieW!

I was wondering if we should add props like n_clicks_next and n_clicks_previous so that you can hook up advancing the slide to a callback? I suppose you can already connect to the active_index prop so maybe that's not necessary. What do you think? I'm already not so sure of the idea having written it out 😛

Anyway, other than the minor comments I'm very happy with the component itself. It would be great if we could also add some unit tests and some documentation. For documentation most of the sections borrow heavily from the examples in the official Bootstrap documentation. For the tests I think checking that the children are added to the layout with the right classes, and clicking next etc. calls setProps would be great.

Happy to give pointers on either of those if needed!

@AnnMarieW
Copy link
Contributor Author

Hi @tcbegley I agree with all comments on the code - I'll make your suggested changes.

I think it's not necessary to include the n_clicks_next and n_clicks_previous props since the active_index can be used to control the slides in a callback. There is an example of this in the carousel.py demo app.

What do you think about using the examples in the demo app for the documentation?

@tcbegley
Copy link
Collaborator

I think it's not necessary to include the n_clicks_next and n_clicks_previous props since the active_index can be used to control the slides in a callback. There is an example of this in the carousel.py demo app.

Ok perfect, I agree, let's not include them!

What do you think about using the examples in the demo app for the documentation?

Yeah they look good actually, maybe just cross-reference to Bootstrap docs to make sure we're not missing any functionality, but it looks pretty complete!

@AnnMarieW
Copy link
Contributor Author

AnnMarieW commented Jun 13, 2021

Yeah they look good actually, maybe just cross-reference to Bootstrap docs to make sure we're not missing any functionality, but it looks pretty complete!

One functionality that is in the Bootstrap docs that is not included is the cross-fade animation (rather than the slide animation) when changing the slides. There is no prop for that in reactstrap but it's possible to do by including `className="carousel-fade" in the Dash app. Should that just be added as an example?

@tcbegley
Copy link
Collaborator

Should that just be added as an example?

Sure why not! You could also submit a fix upstream in reactstrap if you fancy it! I did that a couple of times before when stuff wasn't supported.

I don't think the different animation styles are so important though if either of those options are a hassle.

@AnnMarieW
Copy link
Contributor Author

It would be easy to add as an example in the docs. It looks like it will be added to reactstrap with their changes for Bootstrap 5.

Copy link
Collaborator

@tcbegley tcbegley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really shaping up!

To make the linter pass you'll need to add docs/components_page/components/carousel/callback.py here

@AnnMarieW AnnMarieW changed the title Added Carousel component. Run carousel.py for a demo Jun 16, 2021
@AnnMarieW AnnMarieW marked this pull request as ready for review June 16, 2021 21:39
Copy link
Collaborator

@tcbegley tcbegley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! I have two minor queries, but otherwise I think this is basically good to go 🎉

@AnnMarieW
Copy link
Contributor Author

For now, I also removed the example of formatting the prev and next controls with CSS, since that's not part of the official Bootstrap docs either. (Maybe because people don't do that very often?)

If someone wants to change those, I think it would be easier to hide to Bootstrap prev/next controls, replace them with a dbc.Button and control the slideshow with a callback.

@tcbegley tcbegley added this to the 0.13.0 milestone Jul 6, 2021
@tcbegley tcbegley linked an issue Jul 6, 2021 that may be closed by this pull request
Copy link
Collaborator

@tcbegley tcbegley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @AnnMarieW! This is great 🚀

@tcbegley tcbegley merged commit 0e9ac02 into dbc-team:main Jul 16, 2021
This was referenced Jul 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants