Skip to content

Commit

Permalink
add conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
danalvrz committed Dec 20, 2023
1 parent ea0271f commit efce58c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion news/40.feature
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Add `single-slide` classname to improve styling @danalvrz
Add conditionals around arrow and dot buttons, and hide them, if there is only one slide @danalvrz
10 changes: 4 additions & 6 deletions src/components/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ const SliderView = (props) => {
return (
<>
<div
className={cx('block slider', className, {
'single-slide': data.slides?.length === 1,
})}
className={cx('block slider', className)}
style={{ '--slider-container-width': `${sliderContainerWidth}px` }}
>
{(data.slides?.length === 0 || !data.slides) && isEditMode && (
Expand All @@ -112,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 @@ -143,7 +141,7 @@ const SliderView = (props) => {
</div>
</div>
</div>

{data.slides?.length > 1 && (
<div className="slider-dots">
{scrollSnaps.map((_, index) => (
<DotButton
Expand All @@ -155,7 +153,7 @@ const SliderView = (props) => {
)}
/>
))}
</div>
</div>)}
</>
)}
</div>
Expand Down

0 comments on commit efce58c

Please sign in to comment.