mirror of
https://git.rdcenter.ru/RDCenter/skb-kit.git
synced 2026-12-05 06:09:45 +00:00
Merge pull request #52 from ifraimka1/general-fixes
фиксы в фотогаллереи, слайдере, подгрузка кастомных страниц
This commit is contained in:
7 files changed
+229
-262
No files matched your search
Generated
+9
@@ -8089,6 +8089,15 @@
|
|||||||
"react": "^16.3.0 || ^17.0.0 || ^18.0.0"
|
"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": {
|
"node_modules/react-transition-group": {
|
||||||
"version": "4.4.5",
|
"version": "4.4.5",
|
||||||
"resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz",
|
"resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz",
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
font-size: 36px;
|
font-size: 36px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
line-height: 44px;
|
line-height: 44px;
|
||||||
margin-top: 0;
|
margin-top: 64px;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
|
|
||||||
@include mediaMax($tablet-max-width) {
|
@include mediaMax($tablet-max-width) {
|
||||||
|
|||||||
@@ -5,17 +5,21 @@ import "./PhotoGallery.style.scss";
|
|||||||
import HWaC1 from "@/shared/assets/images/hard_work_and_creativity/HWaC1.jpg";
|
import HWaC1 from "@/shared/assets/images/hard_work_and_creativity/HWaC1.jpg";
|
||||||
import HWaC2 from "@/shared/assets/images/hard_work_and_creativity/HWaC2.jpg";
|
import HWaC2 from "@/shared/assets/images/hard_work_and_creativity/HWaC2.jpg";
|
||||||
|
|
||||||
const PhotoGallery = () => {
|
interface PhotoGalleryProps {
|
||||||
const { data: mediaData, isLoading, isError } = useMedia();
|
images?: string[];
|
||||||
const [visibleCount] = useState(10);
|
}
|
||||||
|
|
||||||
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) {
|
if (isLoading) {
|
||||||
return <SkeletonGallery />;
|
return <SkeletonGallery />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isError || !filteredMedia || filteredMedia.length === 0) {
|
if (isError || !galleryImages || galleryImages.length === 0) {
|
||||||
return <center>Ошибка при загрузке медиа</center>;
|
return <center>Ошибка при загрузке медиа</center>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +47,7 @@ const PhotoGallery = () => {
|
|||||||
|
|
||||||
<h1 className="title">Фотогалерея</h1>
|
<h1 className="title">Фотогалерея</h1>
|
||||||
<div className="images">
|
<div className="images">
|
||||||
{filteredMedia.slice(0, visibleCount).map((media) => (
|
{galleryImages.slice(0, visibleCount).map((media) => (
|
||||||
<div key={media.id} className="image-container">
|
<div key={media.id} className="image-container">
|
||||||
<img
|
<img
|
||||||
src={media.src}
|
src={media.src}
|
||||||
@@ -54,7 +58,7 @@ const PhotoGallery = () => {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{visibleCount < filteredMedia.length && (
|
{visibleCount < galleryImages.length && (
|
||||||
<div className="btn" onClick={() => setVisibleCount(visibleCount + 10)}>
|
<div className="btn" onClick={() => setVisibleCount(visibleCount + 10)}>
|
||||||
Загрузить ещё
|
Загрузить ещё
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 10px 0;
|
padding: 10px 0;
|
||||||
user-select: none; // Запрещаем выделение всего содержимого слайдера
|
will-change: transform;
|
||||||
|
backface-visibility: hidden;
|
||||||
|
transform-style: preserve-3d;
|
||||||
|
|
||||||
&.has-pagination {
|
&.has-pagination {
|
||||||
.swiper {
|
.swiper {
|
||||||
@@ -11,121 +13,60 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.slider-item {
|
.swiper-slide {
|
||||||
|
padding-top: 10px;
|
||||||
|
padding-bottom: 10px;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
will-change: transform;
|
||||||
|
transform: translateZ(0);
|
||||||
|
backface-visibility: hidden;
|
||||||
|
perspective: 1000px;
|
||||||
|
|
||||||
.slide-image {
|
.slide-image {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: auto;
|
|
||||||
height: 350px;
|
height: 350px;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
object-position: center center;
|
object-position: center;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
user-select: none; // Дополнительная защита от выделения изображений
|
transform: translateZ(0);
|
||||||
|
backface-visibility: hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.swiper-wrapper:has(.swiper-slide.single) {
|
.swiper-wrapper:has(.swiper-slide.single) {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
||||||
.slider-item.single {
|
.swiper-slide.single {
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
.slide-image {
|
.slide-image {
|
||||||
width: auto;
|
width: auto;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
object-position: center center;
|
border-radius: 0;
|
||||||
pointer-events: none;
|
|
||||||
user-select: none; // Запрещаем выделение и для одиночных изображений
|
|
||||||
border-radius: 0px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* стрелки */
|
|
||||||
/* Кастомные стрелки */
|
|
||||||
.custom-navigation {
|
.custom-navigation {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
|
width: 100%;
|
||||||
transform: translateY(-50%);
|
transform: translateY(-50%);
|
||||||
background: rgba(0, 0, 0, 0.7);
|
z-index: 10;
|
||||||
color: white;
|
pointer-events: none;
|
||||||
border: none;
|
|
||||||
width: 40px;
|
|
||||||
height: 40px;
|
|
||||||
border-radius: 50%;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 18px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
z-index: 2;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
|
|
||||||
&:hover {
|
&>* {
|
||||||
background: rgba(0, 0, 0, 0.9);
|
pointer-events: all;
|
||||||
transform: translateY(-50%) scale(1.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
&[disabled] {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.alice-carousel__wrapper {
|
|
||||||
width: 185%;
|
|
||||||
height: auto;
|
|
||||||
left: -240px;
|
|
||||||
user-select: none;
|
|
||||||
}
|
|
||||||
.alice-carousel__prev-btn {
|
|
||||||
left: 10px;
|
|
||||||
|
|
||||||
&::before {
|
|
||||||
content: "←";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.alice-carousel__next-btn {
|
.custom-prev,
|
||||||
right: 10px;
|
.custom-next {
|
||||||
|
|
||||||
&::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;
|
width: 60px;
|
||||||
height: 60px;
|
height: 60px;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
@@ -133,116 +74,97 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
border: none;
|
border: none;
|
||||||
z-index: 10;
|
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);
|
||||||
&__prev-btn {
|
backface-visibility: hidden;
|
||||||
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 {
|
&:hover {
|
||||||
background: rgba(0, 0, 0, 0.6);
|
transform: scale(1.05);
|
||||||
}
|
box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Скрываем точки когда они отключены
|
&:active {
|
||||||
&.__disabled-dots .alice-carousel__dots {
|
transform: scale(0.95);
|
||||||
display: none;
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Скрываем кнопки когда они отключены
|
|
||||||
&.__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) {
|
@media (max-width: 768px) {
|
||||||
height: 250px;
|
width: 45px;
|
||||||
|
height: 45px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Responsive стили
|
.custom-prev {
|
||||||
@media (max-width: 768px) {
|
margin-left: -80px;
|
||||||
.slider {
|
|
||||||
.alice-carousel__stage-item {
|
@media (max-width: 768px) {
|
||||||
padding: 0 5px;
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
.alice-carousel__prev-btn,
|
@media (max-width: 768px) {
|
||||||
.alice-carousel__next-btn {
|
opacity: 1;
|
||||||
width: 35px;
|
transition: none;
|
||||||
height: 35px;
|
height: 48vh;
|
||||||
font-size: 16px;
|
min-height: 250px;
|
||||||
|
|
||||||
|
.slide-image {
|
||||||
|
height: 350px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.alice-carousel__prev-btn {
|
.swiper-slide-active {
|
||||||
left: 5px;
|
opacity: 1;
|
||||||
|
|
||||||
|
.slide-image {
|
||||||
|
transform: scale(1.02);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.alice-carousel__next-btn {
|
&.no-animation .swiper-slide {
|
||||||
right: 5px;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+105
-78
@@ -1,102 +1,129 @@
|
|||||||
import { useState } from "react";
|
import { useEffect, useState, useRef } from "react";
|
||||||
import AliceCarousel from "react-alice-carousel";
|
import { Swiper, SwiperSlide } from "swiper/react";
|
||||||
import "react-alice-carousel/lib/alice-carousel.css";
|
import { Navigation } from "swiper/modules";
|
||||||
import { useMedia } from "@/modules/media/hooks/useMedia";
|
import { useMedia } from "@/modules/media/hooks/useMedia";
|
||||||
import { MediaItem } from "@/modules/media/api/get";
|
|
||||||
import { SkeletonSlider } from "@/shared/Components/SkeletonSlider/SkeletonSlider";
|
import { SkeletonSlider } from "@/shared/Components/SkeletonSlider/SkeletonSlider";
|
||||||
import "./Slider.styles.scss";
|
import { MediaItem } from "@/modules/media/api/get";
|
||||||
import { SliderContext, SliderProps } from "@/widgets/Slider/context";
|
|
||||||
|
|
||||||
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,
|
autoPlay = false,
|
||||||
autoPlayTime = 3000,
|
autoPlayTime = 3000,
|
||||||
images,
|
images,
|
||||||
category = "gallery",
|
category,
|
||||||
customPerSlide = 6,
|
customPerSlide = 0,
|
||||||
}: SliderProps) {
|
variant = "default",
|
||||||
|
}: SliderProps) => {
|
||||||
const { data: mediaData, isLoading, isError } = useMedia();
|
const { data: mediaData, isLoading, isError } = useMedia();
|
||||||
const [slideNumber, setSlideNumber] = useState(0);
|
const [mediaList, setMediaList] = useState<MediaItem[]>([]);
|
||||||
|
const [itemsPerSlide, setItemsPerSlide] = useState(2);
|
||||||
|
const [enableButtons, setEnableButtons] = useState(false);
|
||||||
|
|
||||||
const filteredMedia: MediaItem[] = images
|
const swiperRef = useRef<any>(null);
|
||||||
? images.map((src, id) => ({ id, src, category: "", name: "" }))
|
|
||||||
: mediaData?.filter((m) => m.category === category) || [];
|
|
||||||
|
|
||||||
const getSlidesPerView = (width: number = window.innerWidth) => {
|
useEffect(() => {
|
||||||
if (customPerSlide > 0) return customPerSlide;
|
const mapped =
|
||||||
if (width < 768) return 1;
|
images?.map((src, id) => ({ id, src, category: "", name: "" })) ||
|
||||||
if (width < 1024) return 2;
|
mediaData?.filter((m) => m.category === category) ||
|
||||||
if (width < 1920) return 10;
|
[];
|
||||||
return 10;
|
setMediaList(mapped);
|
||||||
};
|
}, [images, mediaData, category]);
|
||||||
const currentSlidesPerView = getSlidesPerView();
|
|
||||||
|
|
||||||
const shouldShowNavigation = filteredMedia.length > currentSlidesPerView;
|
useEffect(() => {
|
||||||
const shouldShowDots = filteredMedia.length > currentSlidesPerView;
|
const updateLayout = () => {
|
||||||
|
const isMobile = window.innerWidth <= 768;
|
||||||
|
const slideCount = mediaList.length;
|
||||||
|
|
||||||
const responsive = {
|
setItemsPerSlide(
|
||||||
0: { items: 1 },
|
slideCount === 1
|
||||||
400: { items: 2 },
|
? 1
|
||||||
600: { items: 3 },
|
: variant === "news"
|
||||||
800: { items: 3 },
|
? isMobile
|
||||||
1000: { items: 4 },
|
? 1
|
||||||
1200: { items: 4 },
|
: 1.4
|
||||||
1400: { items: 5 },
|
: isMobile
|
||||||
1600: { items: 7 },
|
? 1
|
||||||
|
: customPerSlide || 2
|
||||||
|
);
|
||||||
|
setEnableButtons(isMobile ? slideCount > 1 : slideCount > (customPerSlide || 2));
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log("responsive object:", responsive);
|
updateLayout();
|
||||||
const items = filteredMedia.map((media) => (
|
window.addEventListener("resize", updateLayout);
|
||||||
<div key={media.id} className="slider-item">
|
return () => window.removeEventListener("resize", updateLayout);
|
||||||
<img
|
}, [mediaList, variant, customPerSlide]);
|
||||||
src={media.src}
|
|
||||||
alt={`slide-${media.id}`}
|
|
||||||
className="slide-image"
|
|
||||||
loading="lazy"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
));
|
|
||||||
|
|
||||||
const handleSlideChanged = (event: { item: number }) => {
|
|
||||||
setSlideNumber(event.item);
|
|
||||||
};
|
|
||||||
|
|
||||||
const goToSlide = (index: number) => {
|
|
||||||
setSlideNumber(index);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (isLoading) return <SkeletonSlider />;
|
if (isLoading) return <SkeletonSlider />;
|
||||||
if (isError) return <center>Ошибка при загрузке медиа</center>;
|
if (isError) return <center>Ошибка при загрузке медиа</center>;
|
||||||
if (filteredMedia.length === 0)
|
|
||||||
return <div>Нет изображений для отображения</div>;
|
const sliderClass =
|
||||||
|
variant === "news" && mediaList.length <= 2 ? "no-animation" : "";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SliderContext.Provider
|
<div className={`slider ${variant} ${sliderClass}`}>
|
||||||
value={{
|
{enableButtons && (
|
||||||
slideNumber,
|
<div className="custom-navigation">
|
||||||
mediaList: filteredMedia,
|
<button
|
||||||
goToSlide,
|
className="custom-prev"
|
||||||
slidesCount: filteredMedia.length,
|
onClick={() => swiperRef.current?.slidePrev()}
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<div className="slider">
|
<img src={arrow} alt="prev" />
|
||||||
<AliceCarousel
|
</button>
|
||||||
items={items}
|
<button
|
||||||
responsive={responsive}
|
className="custom-next"
|
||||||
controlsStrategy="alternate"
|
onClick={() => swiperRef.current?.slideNext()}
|
||||||
autoPlay={autoPlay && shouldShowNavigation}
|
>
|
||||||
autoPlayInterval={autoPlayTime}
|
<img src={arrow} alt="next" style={{ transform: "rotate(180deg)" }} />
|
||||||
infinite={shouldShowNavigation}
|
</button>
|
||||||
disableDotsControls={!shouldShowDots}
|
</div>
|
||||||
disableButtonsControls={!shouldShowNavigation}
|
)}
|
||||||
activeIndex={slideNumber}
|
|
||||||
onSlideChanged={handleSlideChanged}
|
<Swiper
|
||||||
mouseTracking={shouldShowNavigation}
|
modules={[Navigation]}
|
||||||
touchTracking={shouldShowNavigation}
|
spaceBetween={variant === "news" ? 20 : 30}
|
||||||
keyboardNavigation={shouldShowNavigation}
|
slidesPerView={itemsPerSlide}
|
||||||
|
centeredSlides={variant === "news" && mediaList.length > 1}
|
||||||
|
slidesPerGroup={1}
|
||||||
|
loop={enableButtons}
|
||||||
|
autoplay={
|
||||||
|
autoPlay
|
||||||
|
? { delay: autoPlayTime, disableOnInteraction: false }
|
||||||
|
: false
|
||||||
|
}
|
||||||
|
onSwiper={(swiper) => (swiperRef.current = swiper)}
|
||||||
|
>
|
||||||
|
{mediaList.map((media, index) => (
|
||||||
|
<SwiperSlide
|
||||||
|
key={media.id}
|
||||||
|
className={`swiper-slide ${
|
||||||
|
mediaList.length === 1 ? "single" : ""
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={media.src}
|
||||||
|
alt={`slide-${index}`}
|
||||||
|
className="slide-image"
|
||||||
|
loading="lazy"
|
||||||
/>
|
/>
|
||||||
|
</SwiperSlide>
|
||||||
|
))}
|
||||||
|
</Swiper>
|
||||||
</div>
|
</div>
|
||||||
</SliderContext.Provider>
|
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default Slider;
|
export default Slider;
|
||||||
@@ -23,7 +23,7 @@ export default function WpPost({
|
|||||||
|
|
||||||
const categories = post.categories ?? [];
|
const categories = post.categories ?? [];
|
||||||
const title = post.title;
|
const title = post.title;
|
||||||
const customComponent = getCustomProject(title);
|
const customComponent = getCustomProject(categories);
|
||||||
|
|
||||||
const isSpecialTitle = title === "Программно-аппаратный комплекс для мониторинга управления мусорных контейнеров";
|
const isSpecialTitle = title === "Программно-аппаратный комплекс для мониторинга управления мусорных контейнеров";
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,12 @@ const customProjects: Record<string, ReactNode> = {
|
|||||||
labboard: <LabBoard />,
|
labboard: <LabBoard />,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getCustomProject = (title: string): ReactNode | null => {
|
export const getCustomProject = (categories: string[]): ReactNode | null => {
|
||||||
// const normalizedKey = title.toLowerCase().replace(/\s+/g, "").replace(/[^a-z0-9]/g, "");
|
for (const category of categories) {
|
||||||
return customProjects[title] || null;
|
const key = category;
|
||||||
|
if (customProjects[key]) {
|
||||||
|
return customProjects[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user