Skip to content
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

Fix/carousel navigation styling #386

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions widget/src/components/messages/CarouselMessage.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.sc-message--carousel {
border-radius: .5rem;
border-radius: 0.5rem;
position: relative;
width: 100%;
overflow: hidden;
Expand All @@ -17,8 +17,10 @@
justify-content: center;

.sc-message--carousel-element {
padding: 1rem;
padding: 1rem 2rem;
width: 100%;
min-width: 307px;
min-height: 172px;

.sc-message--carousel-element-image {
background-position: center;
Expand All @@ -35,7 +37,6 @@
padding: 0.5rem 0;
margin-top: 8px;
}

.sc-message--carousel-element-description {
width: 100%;
}
Expand All @@ -51,15 +52,19 @@
color: white;
border: none;
cursor: pointer;
padding: 10px;
z-index: 2;
font-size: 0.75rem;

&.prev {
left: 10px;
left: 0px;
width: 1.5rem;
height: 2rem;
}

&.next {
right: 10px;
right: 0px;
width: 1.5rem;
height: 2rem;
}
}
}
26 changes: 17 additions & 9 deletions widget/src/components/messages/CarouselMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const CarouselMessage: React.FC<CarouselMessageProps> = ({
setActiveIndex((prevIndex) => (prevIndex + 1) % items.length);
};
const colors = allColors[messageCarousel.direction || "received"];
const shouldDisplayNavigationButtons = items.length > 1;

return (
<div
Expand All @@ -98,15 +99,22 @@ const CarouselMessage: React.FC<CarouselMessageProps> = ({
<CarouselItem key={idx} message={message} idx={idx} />
))}
</div>
<button
className="sc-message--carousel-control prev"
onClick={goToPrevious}
>
&#10094;
</button>
<button className="sc-message--carousel-control next" onClick={goToNext}>
&#10095;
</button>
{shouldDisplayNavigationButtons && (
<>
<button
className="sc-message--carousel-control prev"
onClick={goToPrevious}
>
&#10094;
</button>
<button
className="sc-message--carousel-control next"
onClick={goToNext}
>
&#10095;
</button>
</>
)}
</div>
);
};
Expand Down
Loading