Skip to content

Commit

Permalink
add conditionals to hide arrow and dot buttons if only one slide (#40)
Browse files Browse the repository at this point in the history
* add single-slide classname to View

* changelog entry

* add conditionals

* lint
  • Loading branch information
danalvrz authored Dec 22, 2023
1 parent e51a2fd commit d9aa3d3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
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

0 comments on commit d9aa3d3

Please sign in to comment.