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

add conditionals to hide arrow and dot buttons if only one slide #40

Merged
merged 4 commits into from
Dec 22, 2023
Merged
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
1 change: 1 addition & 0 deletions news/40.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add conditionals around arrow and dot buttons, and hide them, if there is only one slide @danalvrz
29 changes: 15 additions & 14 deletions src/components/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const SliderView = (props) => {
{data.slides?.length > 0 && (
<>
<div className="slider-wrapper">
{!data.hideArrows && (
{!data.hideArrows && data.slides?.length > 1 && (
<>
<PrevButton onClick={scrollPrev} disabled={prevBtnDisabled} />
<NextButton onClick={scrollNext} disabled={nextBtnDisabled} />
Expand Down Expand Up @@ -141,19 +141,20 @@ const SliderView = (props) => {
</div>
</div>
</div>

<div className="slider-dots">
{scrollSnaps.map((_, index) => (
<DotButton
key={index}
index={index}
onClick={() => scrollTo(index)}
className={'slider-dot'.concat(
index === selectedIndex ? ' slider-dot--selected' : '',
)}
/>
))}
</div>
{data.slides?.length > 1 && (
<div className="slider-dots">
{scrollSnaps.map((_, index) => (
<DotButton
key={index}
index={index}
onClick={() => scrollTo(index)}
className={'slider-dot'.concat(
index === selectedIndex ? ' slider-dot--selected' : '',
)}
/>
))}
</div>
)}
</>
)}
</div>
Expand Down