Skip to content

Commit

Permalink
feat: [Carousel] move the dots to the middle bottom of the slide
Browse files Browse the repository at this point in the history
BREAKING CHANGE: rename `.Carousel-indicators` to `.Carousel-dots`
  • Loading branch information
akai committed Jan 18, 2021
1 parent 424840d commit 1d71888
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/components/Carousel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ export const Carousel = React.forwardRef<CarouselHandle, CarouselProps>((props,
)}
</div>
{dots && (
<ol className="Carousel-indicators">
<ol className="Carousel-dots">
{React.Children.map(children, (_, i) => (
<li key={i}>
<button
Expand Down
24 changes: 15 additions & 9 deletions src/components/Carousel/style.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.Carousel {
position: relative;
overflow: hidden;

&--draggable {
Expand All @@ -22,21 +23,26 @@
&-inner {
display: flex;
}
&-indicators {
&-dots {
position: absolute;
z-index: 1;
bottom: @carousel-dots-bottom;
left: 50%;
transform: translateX(-50%);
display: flex;
justify-content: center;
list-style-type: none;
}
&-dot {
display: block;
width: 8px;
height: 8px;
margin: 0 3px;
padding: 0;
border: 0;
border-radius: 50%;
background: var(--gray-4);
transition: 0.3s;
width: @carousel-dot-width;
height: @carousel-dot-height;
margin: @carousel-dot-margin;
padding: @carousel-dot-padding;
border: @carousel-dot-border;
border-radius: @carousel-dot-border-radius;
background: @carousel-dot-bg;
transition: @carousel-dot-transition;
cursor: pointer;

&.active {
Expand Down
12 changes: 12 additions & 0 deletions src/styles/var.less
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,18 @@
@card-column-btn-bg: var(--white);
@card-column-btn-primary-color: var(--brand-1);

// Carousel
@carousel-dots-bottom: 8px;

@carousel-dot-width: 8px;
@carousel-dot-height: @carousel-dot-width;
@carousel-dot-margin: 0 4px;
@carousel-dot-padding: 0;
@carousel-dot-border: 0;
@carousel-dot-border-radius: 50%;
@carousel-dot-bg: var(--gray-4);
@carousel-dot-transition: 0.3s;

// Modals
@modal-width: 320px;
@modal-border-radius: 12px;
Expand Down
8 changes: 4 additions & 4 deletions storybook/stories/Carousel.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const ManyImages = (ars) => (
{imgs.map((img, i) => (
<div key={i}>
<p>{i}</p>
<img width="320" src={img} alt="" />
<img width="100%" src={img} alt="" />
</div>
))}
</Carousel>
Expand Down Expand Up @@ -52,10 +52,10 @@ function TestMethods() {
<div>
<Carousel ref={carouselRef}>
{imgs.map((img, i) => (
<div key={i} onClick={handleClick}>
<div key={i}>
<p>{i}</p>
<a href="javascript:;">
<img width="320" src={img} alt="" />
<a href={img} onClick={handleClick}>
<img width="100%" src={img} alt="" />
</a>
</div>
))}
Expand Down

0 comments on commit 1d71888

Please sign in to comment.