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

image gallery improvements #2683

Merged
merged 6 commits into from
May 20, 2024
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
2 changes: 0 additions & 2 deletions src/shared/components/Modal/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ $modal-mobile-padding: 1.5rem;
.modal__content {
flex: 1;
padding: 0 $modal-padding;
overflow-y: auto;
andreymikhadyuk marked this conversation as resolved.
Show resolved Hide resolved

@include big-phone {
padding-left: $modal-mobile-padding;
Expand Down Expand Up @@ -190,7 +189,6 @@ $modal-mobile-padding: 1.5rem;
height: 100%;
margin: unset;
border-radius: unset;
overflow-y: scroll;
}
}
.modal--mobile-pop-up {
Expand Down
30 changes: 8 additions & 22 deletions src/shared/ui-kit/ImageGallery/ImageGallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ import { useMeasure } from "react-use";
import classNames from "classnames";
import { ButtonLink, Image } from "@/shared/components";
import { useModal } from "@/shared/hooks";
import { useIsTabletView } from "@/shared/hooks/viewport";
import { CommonLink } from "@/shared/models";
import { FilePrefix, ResizeType, getResizedFileUrl } from "@/shared/utils";
import {
ImageGalleryModal,
ImageGalleryMobileModal,
GalleryMainContent,
} from "./components";
import { ImageGalleryModal, GalleryMainContent } from "./components";
import styles from "./ImageGallery.module.scss";

interface ImageGalleryProps {
Expand All @@ -21,7 +16,6 @@ interface ImageGalleryProps {

const ImageGallery: FC<ImageGalleryProps> = (props) => {
const { gallery, videoSrc, useResizedFile = true } = props;
const isTabletView = useIsTabletView();
const [videoContainerRef, { width: videoContainerWidth }] = useMeasure();
const { isShowing, onOpen, onClose } = useModal(false);
const images = (gallery || []).map(({ value }) =>
Expand Down Expand Up @@ -97,21 +91,13 @@ const ImageGallery: FC<ImageGalleryProps> = (props) => {
See all gallery
</ButtonLink>
)}
{isTabletView ? (
<ImageGalleryMobileModal
images={images}
isShowing={isShowing}
onClose={onClose}
videoSrc={videoSrc}
/>
) : (
<ImageGalleryModal
isShowing={isShowing}
onClose={onClose}
images={images}
videoSrc={videoSrc}
/>
)}

<ImageGalleryModal
isShowing={isShowing}
onClose={onClose}
images={images}
videoSrc={videoSrc}
/>
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
width: 100%;
max-height: 43.125rem;
height: 100%;
margin-top: 1.625rem;
margin: auto;

@include big-phone {
margin-top: unset;
}

& .swiper-container {
padding-bottom: 2rem;
max-height: 35rem;
height: 100%;
max-width: 48.8125rem;
Expand All @@ -18,6 +21,11 @@

& .swiper-wrapper {
max-height: 35rem;
height: 90%;
}

& .swiper-pagination-bullet {
background-color: var(--primary-text);
}

& .swiper-pagination-bullet-active {
Expand Down Expand Up @@ -108,3 +116,16 @@
height: 100%;
width: 100%;
}

.image-gallery-modal {
.modal__content {
padding: 0;
.modal__header-wrapper {
.modal__header--default-padding {
margin-right: 0.5rem;
margin-top: 0.5rem;
padding-top: 0;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { FC, ReactNode, useCallback, useState } from "react";
import { Swiper, SwiperSlide } from "swiper/react";
import SwiperClass from "swiper/types/swiper-class";
import { ButtonIcon, Image, Modal } from "@/shared/components";
import { useIsTabletView } from "@/shared/hooks/viewport";
import LeftArrowIcon from "@/shared/icons/leftArrow.icon";
import RightArrowIcon from "@/shared/icons/rightArrow.icon";
import { VideoEmbed } from "@/shared/ui-kit/VideoEmbed";
Expand All @@ -21,6 +22,7 @@ interface ImageGalleryProps {
const ImageGalleryModal: FC<ImageGalleryProps> = (props) => {
const { images, isShowing, onClose, videoSrc, initialSlide = 0 } = props;
const [swiperRef, setSwiperRef] = useState<SwiperClass | null>(null);
const isTabletView = useIsTabletView();

const handleLeftClick = useCallback(() => {
if (swiperRef) {
Expand All @@ -43,14 +45,19 @@ const ImageGalleryModal: FC<ImageGalleryProps> = (props) => {
}, [swiperRef]);

return (
<Modal isShowing={isShowing} onClose={onClose}>
<Modal
isShowing={isShowing}
onClose={onClose}
mobileFullScreen={isTabletView}
className="image-gallery-modal"
>
<div className="container">
<Swiper
onSwiper={setSwiperRef}
loop={true}
pagination
initialSlide={initialSlide}
allowTouchMove={false}
allowTouchMove={isTabletView}
>
{videoSrc && (
<SwiperSlide key={videoSrc} className="slider-wrapper">
Expand All @@ -68,15 +75,16 @@ const ImageGalleryModal: FC<ImageGalleryProps> = (props) => {
}
>
<Image
hasZoom
hasZoom={!isTabletView}
className="slide-img"
imageContainerClassName="image-container"
src={imageURL}
alt={`Common gallery image #${index + 1}`}
/>
</SwiperSlide>
))}
</Swiper>
{images.length > 1 && (
{!isTabletView && images.length > 1 && (
<>
<ButtonIcon
className="arrow-wrapper-left"
Expand Down
Loading