diff --git a/package-lock.json b/package-lock.json
index 6f3e62e..36775dc 100755
--- a/package-lock.json
+++ b/package-lock.json
@@ -8089,6 +8089,15 @@
"react": "^16.3.0 || ^17.0.0 || ^18.0.0"
}
},
+ "node_modules/react-swipeable": {
+ "version": "7.0.2",
+ "resolved": "https://registry.npmjs.org/react-swipeable/-/react-swipeable-7.0.2.tgz",
+ "integrity": "sha512-v1Qx1l+aC2fdxKa9aKJiaU/ZxmJ5o98RMoFwUqAAzVWUcxgfHFXDDruCKXhw6zIYXm6V64JiHgP9f6mlME5l8w==",
+ "license": "MIT",
+ "peerDependencies": {
+ "react": "^16.8.3 || ^17 || ^18 || ^19.0.0 || ^19.0.0-rc"
+ }
+ },
"node_modules/react-transition-group": {
"version": "4.4.5",
"resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz",
diff --git a/src/widgets/PhotoGallery/PhotoGallery.style.scss b/src/widgets/PhotoGallery/PhotoGallery.style.scss
index cfb48ea..d5026cd 100644
--- a/src/widgets/PhotoGallery/PhotoGallery.style.scss
+++ b/src/widgets/PhotoGallery/PhotoGallery.style.scss
@@ -12,7 +12,7 @@
font-size: 36px;
font-weight: 600;
line-height: 44px;
- margin-top: 0;
+ margin-top: 64px;
margin-bottom: 16px;
@include mediaMax($tablet-max-width) {
diff --git a/src/widgets/PhotoGallery/PhotoGallery.tsx b/src/widgets/PhotoGallery/PhotoGallery.tsx
index 465262b..2c5b9b1 100644
--- a/src/widgets/PhotoGallery/PhotoGallery.tsx
+++ b/src/widgets/PhotoGallery/PhotoGallery.tsx
@@ -5,17 +5,21 @@ import "./PhotoGallery.style.scss";
import HWaC1 from "@/shared/assets/images/hard_work_and_creativity/HWaC1.jpg";
import HWaC2 from "@/shared/assets/images/hard_work_and_creativity/HWaC2.jpg";
-const PhotoGallery = () => {
- const { data: mediaData, isLoading, isError } = useMedia();
- const [visibleCount] = useState(10);
+interface PhotoGalleryProps {
+ images?: string[];
+}
- const filteredMedia = mediaData?.filter((el) => el.category === "gallery") || [];
+const PhotoGallery = ({ images }: PhotoGalleryProps) => {
+ const { data: mediaData, isLoading, isError } = useMedia();
+ const [visibleCount, setVisibleCount] = useState(10);
+
+ const galleryImages = mediaData?.filter((el) => el.category === "photogallery");
if (isLoading) {
return ;
}
- if (isError || !filteredMedia || filteredMedia.length === 0) {
+ if (isError || !galleryImages || galleryImages.length === 0) {
return
- {filteredMedia.slice(0, visibleCount).map((media) => (
+ {galleryImages.slice(0, visibleCount).map((media) => (

{
))}
- {visibleCount < filteredMedia.length && (
+ {visibleCount < galleryImages.length && (
setVisibleCount(visibleCount + 10)}>
Загрузить ещё
diff --git a/src/widgets/Slider/Slider.styles.scss b/src/widgets/Slider/Slider.styles.scss
index 5bbe758..7509c41 100644
--- a/src/widgets/Slider/Slider.styles.scss
+++ b/src/widgets/Slider/Slider.styles.scss
@@ -3,7 +3,9 @@
margin: 0 auto;
position: relative;
padding: 10px 0;
- user-select: none; // Запрещаем выделение всего содержимого слайдера
+ will-change: transform;
+ backface-visibility: hidden;
+ transform-style: preserve-3d;
&.has-pagination {
.swiper {
@@ -11,238 +13,158 @@
}
}
- .slider-item {
+ .swiper-slide {
+ padding-top: 10px;
+ padding-bottom: 10px;
display: flex;
justify-content: center;
align-items: center;
+ will-change: transform;
+ transform: translateZ(0);
+ backface-visibility: hidden;
+ perspective: 1000px;
.slide-image {
width: 100%;
- height: auto;
height: 350px;
object-fit: cover;
- object-position: center center;
+ object-position: center;
border-radius: 8px;
pointer-events: none;
- user-select: none; // Дополнительная защита от выделения изображений
+ transform: translateZ(0);
+ backface-visibility: hidden;
}
}
.swiper-wrapper:has(.swiper-slide.single) {
justify-content: center;
- .slider-item.single {
- display: flex;
- justify-content: center;
- align-items: center;
-
+ .swiper-slide.single {
.slide-image {
width: auto;
height: 100%;
- object-position: center center;
- pointer-events: none;
- user-select: none; // Запрещаем выделение и для одиночных изображений
- border-radius: 0px;
+ border-radius: 0;
}
}
}
}
-/* стрелки */
-/* Кастомные стрелки */
.custom-navigation {
display: flex;
justify-content: space-between;
align-items: center;
position: absolute;
top: 50%;
+ width: 100%;
transform: translateY(-50%);
- background: rgba(0, 0, 0, 0.7);
- color: white;
- border: none;
- width: 40px;
- height: 40px;
+ z-index: 10;
+ pointer-events: none;
+
+ &>* {
+ pointer-events: all;
+ }
+}
+
+.custom-prev,
+.custom-next {
+ width: 60px;
+ height: 60px;
+ background-color: white;
border-radius: 50%;
- cursor: pointer;
- font-size: 18px;
display: flex;
- align-items: center;
justify-content: center;
- z-index: 2;
- transition: all 0.2s ease;
+ align-items: center;
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
+ cursor: pointer;
+ font-size: 24px;
+ border: none;
+ transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
+ box-shadow 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
+ transform: translateZ(0);
+ backface-visibility: hidden;
&:hover {
- background: rgba(0, 0, 0, 0.9);
- transform: translateY(-50%) scale(1.1);
+ transform: scale(1.05);
+ box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}
- &[disabled] {
- display: none;
+ &:active {
+ transform: scale(0.95);
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
-}
-.alice-carousel__wrapper {
- width: 185%;
- height: auto;
- left: -240px;
- user-select: none;
-}
-.alice-carousel__prev-btn {
- left: 10px;
-
- &::before {
- content: "←";
- }
-}
-
-.alice-carousel__next-btn {
- right: 10px;
-
- &::before {
- content: "→";
- }
-}
-
-// Стили для Alice Carousel (добавить в конец файла)
-.slider {
- // Ваши существующие стили остаются без изменений
-
- // Стили для Alice Carousel
- .alice-carousel {
- &__wrapper {
- position: relative;
- }
-
- &__stage {
- padding: 0;
- }
-
- &__stage-item {
- padding: 0 10px;
- }
-
- // Используем ваши оригинальные стили для кнопок навигации
- &__prev-btn,
- &__next-btn {
- position: absolute;
- top: 50%;
- transform: translateY(-50%);
- width: 60px;
- height: 60px;
- background-color: white;
- border-radius: 50%;
- display: flex;
- justify-content: center;
- align-items: center;
- box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
- cursor: pointer;
- font-size: 24px;
- border: none;
- z-index: 10;
- }
-
- &__prev-btn {
- left: -70px;
-
- &::before {
- content: "‹";
- }
-
- @media (max-width: 768px) {
- left: 0px;
- }
- }
-
- &__next-btn {
- right: -70px;
-
- &::before {
- content: "›";
- }
-
- @media (max-width: 768px) {
- right: 0px;
- }
- }
-
- // Стили для точек навигации
- &__dots {
- display: flex;
- justify-content: center;
- gap: 8px;
- margin-top: 15px;
-
- &-item {
- width: 10px;
- height: 10px;
- border-radius: 50%;
- background: rgba(0, 0, 0, 0.3);
- cursor: pointer;
- transition: all 0.2s ease;
- border: none;
-
- &.__active {
- background: #007bff;
- transform: scale(1.2);
- }
-
- &:hover {
- background: rgba(0, 0, 0, 0.6);
- }
- }
- }
-
- // Скрываем точки когда они отключены
- &.__disabled-dots .alice-carousel__dots {
- display: none;
- }
-
- // Скрываем кнопки когда они отключены
- &.__disabled-buttons {
- .alice-carousel__prev-btn,
- .alice-carousel__next-btn {
- display: none;
- }
- }
- }
-}
-
-.slider-item {
- display: flex;
- justify-content: center;
- align-items: center;
-}
-
-.slide-image {
- width: 100%;
- height: 300px;
- object-fit: cover;
- border-radius: 4px;
@media (max-width: 768px) {
- height: 250px;
+ width: 45px;
+ height: 45px;
}
}
-// Responsive стили
-@media (max-width: 768px) {
- .slider {
- .alice-carousel__stage-item {
- padding: 0 5px;
- }
+.custom-prev {
+ margin-left: -80px;
- .alice-carousel__prev-btn,
- .alice-carousel__next-btn {
- width: 35px;
- height: 35px;
- font-size: 16px;
- }
-
- .alice-carousel__prev-btn {
- left: 5px;
- }
-
- .alice-carousel__next-btn {
- right: 5px;
- }
+ @media (max-width: 768px) {
+ margin-left: 5px;
}
}
+
+.custom-next {
+ margin-right: -80px;
+
+ @media (max-width: 768px) {
+ margin-right: 5px;
+ }
+}
+
+.slider.news {
+ .swiper-slide {
+ opacity: 0.5;
+ transition: opacity 0.6s cubic-bezier(0.22, 0.61, 0.36, 1),
+ transform 0.6s cubic-bezier(0.22, 0.61, 0.36, 1);
+ height: 65vh;
+ min-height: 300px;
+ transform-origin: center center;
+
+ .slide-image {
+ height: 500px;
+ transition: transform 0.6s cubic-bezier(0.22, 0.61, 0.36, 1);
+ }
+
+ @media (max-width: 768px) {
+ opacity: 1;
+ transition: none;
+ height: 48vh;
+ min-height: 250px;
+
+ .slide-image {
+ height: 350px;
+ }
+ }
+ }
+
+ .swiper-slide-active {
+ opacity: 1;
+
+ .slide-image {
+ transform: scale(1.02);
+ }
+ }
+
+ &.no-animation .swiper-slide {
+ transition: none !important;
+
+ .slide-image {
+ transform: none !important;
+ }
+ }
+
+ .swiper-slide-prev,
+ .swiper-slide-next {
+ opacity: 0.7;
+ transform: scale(0.95);
+
+ @media (max-width: 768px) {
+ opacity: 1;
+ transform: none;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/widgets/Slider/Slider.tsx b/src/widgets/Slider/Slider.tsx
index 906ad9c..fe6804e 100644
--- a/src/widgets/Slider/Slider.tsx
+++ b/src/widgets/Slider/Slider.tsx
@@ -1,102 +1,129 @@
-import { useState } from "react";
-import AliceCarousel from "react-alice-carousel";
-import "react-alice-carousel/lib/alice-carousel.css";
+import { useEffect, useState, useRef } from "react";
+import { Swiper, SwiperSlide } from "swiper/react";
+import { Navigation } from "swiper/modules";
import { useMedia } from "@/modules/media/hooks/useMedia";
-import { MediaItem } from "@/modules/media/api/get";
import { SkeletonSlider } from "@/shared/Components/SkeletonSlider/SkeletonSlider";
-import "./Slider.styles.scss";
-import { SliderContext, SliderProps } from "@/widgets/Slider/context";
+import { MediaItem } from "@/modules/media/api/get";
-function Slider({
+import "swiper/css";
+import "swiper/css/navigation";
+import "./Slider.styles.scss";
+
+import arrow from "@/shared/assets/images/arrow.svg";
+
+interface SliderProps {
+ autoPlay?: boolean;
+ autoPlayTime?: number;
+ images?: string[];
+ category: string;
+ customPerSlide?: number;
+ variant?: "default" | "news";
+}
+
+const Slider = ({
autoPlay = false,
autoPlayTime = 3000,
images,
- category = "gallery",
- customPerSlide = 6,
-}: SliderProps) {
+ category,
+ customPerSlide = 0,
+ variant = "default",
+}: SliderProps) => {
const { data: mediaData, isLoading, isError } = useMedia();
- const [slideNumber, setSlideNumber] = useState(0);
+ const [mediaList, setMediaList] = useState
([]);
+ const [itemsPerSlide, setItemsPerSlide] = useState(2);
+ const [enableButtons, setEnableButtons] = useState(false);
- const filteredMedia: MediaItem[] = images
- ? images.map((src, id) => ({ id, src, category: "", name: "" }))
- : mediaData?.filter((m) => m.category === category) || [];
+ const swiperRef = useRef(null);
- const getSlidesPerView = (width: number = window.innerWidth) => {
- if (customPerSlide > 0) return customPerSlide;
- if (width < 768) return 1;
- if (width < 1024) return 2;
- if (width < 1920) return 10;
- return 10;
- };
- const currentSlidesPerView = getSlidesPerView();
+ useEffect(() => {
+ const mapped =
+ images?.map((src, id) => ({ id, src, category: "", name: "" })) ||
+ mediaData?.filter((m) => m.category === category) ||
+ [];
+ setMediaList(mapped);
+ }, [images, mediaData, category]);
- const shouldShowNavigation = filteredMedia.length > currentSlidesPerView;
- const shouldShowDots = filteredMedia.length > currentSlidesPerView;
+ useEffect(() => {
+ const updateLayout = () => {
+ const isMobile = window.innerWidth <= 768;
+ const slideCount = mediaList.length;
- const responsive = {
- 0: { items: 1 },
- 400: { items: 2 },
- 600: { items: 3 },
- 800: { items: 3 },
- 1000: { items: 4 },
- 1200: { items: 4 },
- 1400: { items: 5 },
- 1600: { items: 7 },
- };
+ setItemsPerSlide(
+ slideCount === 1
+ ? 1
+ : variant === "news"
+ ? isMobile
+ ? 1
+ : 1.4
+ : isMobile
+ ? 1
+ : customPerSlide || 2
+ );
+ setEnableButtons(isMobile ? slideCount > 1 : slideCount > (customPerSlide || 2));
+ };
- console.log("responsive object:", responsive);
- const items = filteredMedia.map((media) => (
-
-

-
- ));
-
- const handleSlideChanged = (event: { item: number }) => {
- setSlideNumber(event.item);
- };
-
- const goToSlide = (index: number) => {
- setSlideNumber(index);
- };
+ updateLayout();
+ window.addEventListener("resize", updateLayout);
+ return () => window.removeEventListener("resize", updateLayout);
+ }, [mediaList, variant, customPerSlide]);
if (isLoading) return ;
if (isError) return Ошибка при загрузке медиа;
- if (filteredMedia.length === 0)
- return Нет изображений для отображения
;
+
+ const sliderClass =
+ variant === "news" && mediaList.length <= 2 ? "no-animation" : "";
return (
-
-
-
- );
-}
+
+ {enableButtons && (
+
+
+
+
+ )}
-export default Slider;
+
1}
+ slidesPerGroup={1}
+ loop={enableButtons}
+ autoplay={
+ autoPlay
+ ? { delay: autoPlayTime, disableOnInteraction: false }
+ : false
+ }
+ onSwiper={(swiper) => (swiperRef.current = swiper)}
+ >
+ {mediaList.map((media, index) => (
+
+
+
+ ))}
+
+
+ );
+};
+
+export default Slider;
\ No newline at end of file
diff --git a/src/widgets/WpPost/WpPost.tsx b/src/widgets/WpPost/WpPost.tsx
index a0ba0ca..2c81bfb 100644
--- a/src/widgets/WpPost/WpPost.tsx
+++ b/src/widgets/WpPost/WpPost.tsx
@@ -23,7 +23,7 @@ export default function WpPost({
const categories = post.categories ?? [];
const title = post.title;
- const customComponent = getCustomProject(title);
+ const customComponent = getCustomProject(categories);
const isSpecialTitle = title === "Программно-аппаратный комплекс для мониторинга управления мусорных контейнеров";
diff --git a/src/widgets/WpPost/customProjects.tsx b/src/widgets/WpPost/customProjects.tsx
index 954330d..b3a5f73 100644
--- a/src/widgets/WpPost/customProjects.tsx
+++ b/src/widgets/WpPost/customProjects.tsx
@@ -6,7 +6,12 @@ const customProjects: Record = {
labboard: ,
};
-export const getCustomProject = (title: string): ReactNode | null => {
-// const normalizedKey = title.toLowerCase().replace(/\s+/g, "").replace(/[^a-z0-9]/g, "");
- return customProjects[title] || null;
+export const getCustomProject = (categories: string[]): ReactNode | null => {
+ for (const category of categories) {
+ const key = category;
+ if (customProjects[key]) {
+ return customProjects[key];
+ }
+ }
+ return null;
};