From ddd50090bdce687109c35c1d1dd62f1c8b2fd1f2 Mon Sep 17 00:00:00 2001 From: Giulia Ghisini Date: Mon, 5 Feb 2024 11:47:58 +0100 Subject: [PATCH] fix: avoid items repeat if nSlides is lower than results lenght --- src/components/ItaliaTheme/Blocks/Listing/SliderTemplate.jsx | 5 ++++- src/theme/ItaliaTheme/Blocks/_sliderTemplate.scss | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/ItaliaTheme/Blocks/Listing/SliderTemplate.jsx b/src/components/ItaliaTheme/Blocks/Listing/SliderTemplate.jsx index d9db1f7af..737377f8f 100644 --- a/src/components/ItaliaTheme/Blocks/Listing/SliderTemplate.jsx +++ b/src/components/ItaliaTheme/Blocks/Listing/SliderTemplate.jsx @@ -194,7 +194,10 @@ const SliderTemplate = ({ }) => { const intl = useIntl(); const [userAutoplay, setUserAutoplay] = useState(autoplay); - const nSlidesToShow = parseInt(slidesToShow); + const nSlidesToShow = + items.length < parseInt(slidesToShow) + ? items.length + : parseInt(slidesToShow); const Slider = reactSlick.default; const { slider, focusNext } = useSlider(userAutoplay); const toggleAutoplay = () => { diff --git a/src/theme/ItaliaTheme/Blocks/_sliderTemplate.scss b/src/theme/ItaliaTheme/Blocks/_sliderTemplate.scss index 5beabd097..17473f61e 100644 --- a/src/theme/ItaliaTheme/Blocks/_sliderTemplate.scss +++ b/src/theme/ItaliaTheme/Blocks/_sliderTemplate.scss @@ -168,6 +168,10 @@ > .card-wrapper { height: 100%; } + + > .card { + margin: 0.5rem 0; + } } } }