-
-
Notifications
You must be signed in to change notification settings - Fork 79k
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
Refactor carousel #21298
Refactor carousel #21298
Conversation
- Un-nests .carousel-item - Appends .carousel-item- to .left, .right, .next, and .prev - Chain .carousel-item to .active where approproriate
- fix naming of left/right controls - drop the absolute positioning of things and rely on only 3d transforms - remove img styles and require classes to avoid inline-block line-height stuff
…rol width as margins to ensure content doesn't overlap
padding-left: 0; | ||
margin-left: -($carousel-indicators-width / 2); | ||
// Use the .carousel-control's width as margin so we don't overlay those | ||
margin-right: $carousel-control-width; |
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.
Properties should be ordered position, right, bottom, left, z-index, padding-left, margin-right, margin-left, text-align, list-style
Pushed a ton more updates to this since opening the PR. The only remaining thing this doesn't address yet is a flexbox variant. I'll tackle that tomorrow I think. Things that might benefit from flexbox:
Some of this likely can be done with utilities, too. |
Hello, I was briefly looking at the code change and just happened to find a small typo in the For prev/next controls, `.carousel-control.right` and `.carousel-control.left`
are now `.carousel-control-left` and `.carousel-control-left`,
meaning they no longer require a specific base class. Thanks for this great framework :) |
Punting flexbox variant to another PR. Opened #21305 to track. |
This PR refactors the carousel to un-nest CSS selectors, simplify overall styling, and improve documentation of key features. More specifically:
New visuals for a simpler design. I've removed the gradients on the controls, changed the indicators from circles to squares (with larger tap areas), and added new icons.
Un-nest CSS. Instead of
.carousel > .item
and the like, we have.carousel-*
prefixed on all classes (save for the.active
state). This includes the slides, controls, and indicators. Fixes Consider clarifying some of the carousel classes (right, left, icon-*) #18396.Simply CSS for sliding effects. We added transforms later in v3's lifecycle, so we had to support transitions for
position
andtransform
. No more; now we just have 3D transforms, so our compiled CSS is much simpler.More reliance on utilities. Image styles for within carousel items have been removed, so now you'll need to use utilities or custom styles (e.g.,
.d-block
and.img-fluid
). Similarly, I've included an example of responsive captions in our docs built with utilities.Improved documentation. The original example is now split across a handful of examples, each building on the previous (from slides only, to controls, to indicators, to captions). Rewrites some of the intro docs and also provides better guidance on responsive captions and more.
Tweak JS to better handle directional states. This pulls in the JS changes from Add prefix to carousel classes #18830 to accomplish that.
Fixes left carousel-control and right carousel-control elements are not visible in the carousel example #17878, correcting the Carousel example.
Update migration docs to mention changes.