Skip to content

Commit

Permalink
fix: slider styles + arrows in ct gallery (#763)
Browse files Browse the repository at this point in the history
* fix: slider styles + arrows in ct gallery

* chore: release.md info
  • Loading branch information
sabrina-bongiovanni authored Sep 12, 2024
1 parent b560bf8 commit fe1d50d
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 29 deletions.
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

### Migliorie

- ...
- Migliorato il layout della galleria immagini nei CT.

### Novità

Expand Down
64 changes: 36 additions & 28 deletions src/components/ItaliaTheme/View/Commons/Gallery.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
SingleSlideWrapper,
CarouselWrapper,
} from 'design-comuni-plone-theme/components/ItaliaTheme';
import { useSlider } from 'design-comuni-plone-theme/components/ItaliaTheme/Slider/slider';

import PropTypes from 'prop-types';
import { contentFolderHasItems } from 'design-comuni-plone-theme/helpers';
import { UniversalLink } from '@plone/volto/components';
Expand Down Expand Up @@ -50,6 +52,7 @@ const Gallery = ({
reactSlick,
}) => {
const Slider = reactSlick.default;
const { SliderNextArrow, SliderPrevArrow } = useSlider();
const Image = config.getComponent({ name: 'Image' }).component;
const getSettings = (nItems, slideToScroll) => {
return {
Expand All @@ -58,6 +61,8 @@ const Gallery = ({
speed: 500,
slidesToShow: nItems < 3 ? nItems : 3,
slidesToScroll: slideToScroll ?? 3,
nextArrow: <SliderNextArrow intl={intl} />,
prevArrow: <SliderPrevArrow intl={intl} />,
responsive: [
{
breakpoint: 1024,
Expand Down Expand Up @@ -154,37 +159,40 @@ const Gallery = ({
<Slider {...getSettings(images.length)}>
{images.map((item, i) => (
<SingleSlideWrapper key={item['@id']} index={i}>
<figure>
<UniversalLink
item={item}
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
setViewImageIndex(i);
}}
onKeyDown={(e) => {
if (e.keyCode === 13) {
<div className={'slide-wrapper'} role="presentation">
<figure className="img-wrapper">
<UniversalLink
item={item}
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
setViewImageIndex(i);
}
}}
aria-label={`${intl.formatMessage(
messages.viewPreview,
)} ${item.title}`}
>
<Image
item={item}
alt={item.title}
className="img-fluid"
loading="lazy"
sizes={`(max-width:320px) 300px, (max-width:425px) 400px, ${default_width_image}`}
/>
</UniversalLink>
<figcaption className="figure-caption mt-2">
{item.title}
</figcaption>
</figure>
}}
onKeyDown={(e) => {
if (e.keyCode === 13) {
e.preventDefault();
e.stopPropagation();
setViewImageIndex(i);
}
}}
aria-label={`${intl.formatMessage(
messages.viewPreview,
)} ${item.title}`}
className="img-wrapper"
>
<Image
item={item}
alt={item.title}
className="img-fluid"
loading="lazy"
sizes={`(max-width:320px) 300px, (max-width:425px) 400px, ${default_width_image}`}
/>
</UniversalLink>
<figcaption className="figure-caption mt-2">
{item.title}
</figcaption>
</figure>
</div>
</SingleSlideWrapper>
))}
</Slider>
Expand Down
27 changes: 27 additions & 0 deletions src/theme/ItaliaTheme/Views/_common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -367,3 +367,30 @@ dl.trasparenza-fields {
@include rem-size(font-size, 16px);
@include rem-size(line-height, 24px);
}

// CT gallery slider
.it-carousel-wrapper {
.slider-container {
.slick-list .slick-track {
.slick-slide {
position: relative;
margin: 0 auto;

a {
height: 150px;
&.img-wrapper {
position: relative;
overflow: hidden;
width: 100%;
margin: 0;

img {
min-height: 150px;
object-fit: cover;
}
}
}
}
}
}
}

0 comments on commit fe1d50d

Please sign in to comment.