стрелки в слайдере мобильная версия

This commit is contained in:
xomimishka committed 2025-05-26 00:09:29 +03:00
1 parent 5359359833
commit b4bebd0532
4 files changed
+234 -91

No files matched your search

+11 -1
View File
@@ -41,6 +41,7 @@
"react-router": "^7.1.1", "react-router": "^7.1.1",
"react-router-dom": "^6.28.1", "react-router-dom": "^6.28.1",
"react-router-hash-link": "^2.4.3", "react-router-hash-link": "^2.4.3",
"react-swipeable": "^7.0.2",
"sass": "^1.85.1", "sass": "^1.85.1",
"swiper": "^11.2.5", "swiper": "^11.2.5",
"wpapi": "^1.2.2", "wpapi": "^1.2.2",
@@ -68,7 +69,7 @@
"i": "^0.3.7", "i": "^0.3.7",
"npm": "^11.2.0", "npm": "^11.2.0",
"typescript": "^5.5.3", "typescript": "^5.5.3",
"vite": "^5.3.1" "vite": "^5.4.19"
} }
}, },
"node_modules/@ampproject/remapping": { "node_modules/@ampproject/remapping": {
@@ -8038,6 +8039,15 @@
"react-router-dom": ">=4" "react-router-dom": ">=4"
} }
}, },
"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",
+2 -1
View File
@@ -43,6 +43,7 @@
"react-router": "^7.1.1", "react-router": "^7.1.1",
"react-router-dom": "^6.28.1", "react-router-dom": "^6.28.1",
"react-router-hash-link": "^2.4.3", "react-router-hash-link": "^2.4.3",
"react-swipeable": "^7.0.2",
"sass": "^1.85.1", "sass": "^1.85.1",
"swiper": "^11.2.5", "swiper": "^11.2.5",
"wpapi": "^1.2.2", "wpapi": "^1.2.2",
@@ -70,6 +71,6 @@
"i": "^0.3.7", "i": "^0.3.7",
"npm": "^11.2.0", "npm": "^11.2.0",
"typescript": "^5.5.3", "typescript": "^5.5.3",
"vite": "^5.3.1" "vite": "^5.4.19"
} }
} }
@@ -3,6 +3,7 @@
overflow: hidden; overflow: hidden;
min-height: 100vh; min-height: 100vh;
padding: 0 10%; padding: 0 10%;
margin: 0; margin: 0;
margin-bottom: 64px; margin-bottom: 64px;
color: rgba(18, 18, 18, 1); color: rgba(18, 18, 18, 1);
@@ -71,15 +72,35 @@
display: none; display: none;
} }
} }
@media (max-width: 768px) {
padding: 0 5%;
margin-bottom: 32px;
}
} }
#padding { #padding {
padding: 0 10%; padding: 0 10%;
@media (max-width: 768px) {
padding: 0 5%;
}
}
#padding2 {
padding: 0 10%;
@media (max-width: 769px) {
padding: 0 2.5%;
}
} }
#page_container { #page_container {
padding: 0 10%; padding: 0 10%;
@media (max-width: 768px) {
padding: 0 5%;
}
h2 { h2 {
font-size: 36px; font-size: 36px;
} }
@@ -120,6 +141,7 @@
@media (max-width: 768px) { @media (max-width: 768px) {
flex-direction: column; flex-direction: column;
gap: 24px; gap: 24px;
margin-bottom: 32px;
} }
} }
@@ -168,6 +190,7 @@
@media (max-width: 768px) { @media (max-width: 768px) {
flex-direction: column; flex-direction: column;
gap: 24px; gap: 24px;
margin-bottom: 32px;
} }
} }
@@ -202,6 +225,7 @@
@media (max-width: 768px) { @media (max-width: 768px) {
flex-direction: column; flex-direction: column;
gap: 24px; gap: 24px;
margin-bottom: 32px;
} }
} }
@@ -278,14 +302,7 @@
.sliderNav { .sliderNav {
display: flex; display: flex;
gap: 16px; gap: 16px;
@media (max-width: 768px) {
order: 2;
justify-content: center;
width: 100%;
} }
}
.sliderButton { .sliderButton {
width: 40px; width: 40px;
@@ -304,57 +321,166 @@
} }
} }
// Карточка слайда .slideActive,
.sliderWrapper { .slideNext {
width: 100%;
display: flex;
justify-content: center;
margin-bottom: 64px;
@media (max-width: 768px) {
margin-bottom: 32px;
margin-top: 16px;
}
}
.slideContent {
width: 100%;
background: #f5f5f7; background: #f5f5f7;
border-radius: 16px; border-radius: 16px;
padding: 48px;
display: flex; display: flex;
height: 352px;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
transition: all 0.5s ease-in-out;
opacity: 1;
transform: scale(1);
} }
.slideActive {
flex: 2;
padding: 48px;
border: 2px solid #0867F4;
.slideImage { .activeImage {
width: 80%; width: 100%;
height: 300px;
object-fit: contain;
}
}
.slideNext {
flex: 1;
padding: 32px;
.nextImage {
width: 100%;
max-height: 200px;
height: auto; height: auto;
object-fit: contain; object-fit: contain;
} }
.swiperSlide {
flex-shrink: 0;
width: 100%;
transition: all 0.3s ease;
transform: scale(0.8);
opacity: 0.6;
cursor: pointer;
display: flex;
justify-content: center;
} }
.slideActive.fade-out,
.slideNext.fade-out,
.fadeOut {
opacity: 0;
transform: scale(0.98);
}
@media (max-width: 768px) {
.slideActive,
.slideNext {
width: 100%;
flex: none;
}
.slideNext {
display: none;
}
.sliderNav {
display: none;
}
.swiper-slide {
opacity: 1 !important;
transition: none !important;
height: 48vh !important;
.slide-image {
height: 350px !important;
}
}
.slideActive .activeImage {
height: 200px; // или auto, если хочешь, чтобы она заполняла контейнер
max-height: 60vh; // чтобы не вылезала за экран
width: 100%;
object-fit: contain;
}
.swiper-slide {
height: auto; // либо установи нужную высоту, например: 60vh
}
.slideActive { .slideActive {
padding: 16px; // уменьшить паддинги, чтобы картинка влезала лучше
}
}
.swiper-slide {
opacity: 0.5;
transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out;
height: 65vh;
.slide-image {
height: 500px;
}
}
.swiper-slide-active {
opacity: 1;
transform: scale(1); transform: scale(1);
}
.swiper-slide-prev,
.swiper-slide-next {
opacity: 0.7;
transform: scale(0.9);
@media (max-width: 768px) {
opacity: 1; opacity: 1;
border: 2px solid #0867F4; transform: none;
border-radius: 16px; }
z-index: 10; }
.sliderWrapper {
display: flex;
align-items: center;
gap: 16px;
width: 100%;
margin-bottom: 34px;
@media (max-width: 768px) {
.sliderNav {
display: none;
}
}
}
.sliderContainer {
display: flex;
gap: 32px;
width: 100%;
margin-bottom: 32px;
@media (max-width: 768px) {
flex: 1;
gap: 0;
.slideNext {
display: none;
}
}
}
.sliderButton2 {
width: 40px;
height: 40px;
border-radius: 50%;
background: #f5f5f7;
border: none;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
img {
width: 16px;
height: 16px;
}
@media (min-width: 769px) {
display: none;
}
} }
+52 -46
View File
@@ -8,12 +8,7 @@ import microcontroller_rear from "@/shared/assets/images/LabBoard/microcontrolle
import Group_one from "@/shared/assets/images/LabBoard/Group_one.svg"; import Group_one from "@/shared/assets/images/LabBoard/Group_one.svg";
import Group_two from "@/shared/assets/images/LabBoard/Group_two.svg"; import Group_two from "@/shared/assets/images/LabBoard/Group_two.svg";
import Vector from "@/shared/assets/images/LabBoard/Vector.svg"; import Vector from "@/shared/assets/images/LabBoard/Vector.svg";
import { useSwipeable } from 'react-swipeable';
import { Swiper, SwiperSlide } from "swiper/react";
import { Navigation, Pagination } from "swiper/modules";
import "swiper/css";
import "swiper/css/navigation";
import "swiper/css/pagination";
import ContactUs from "@/widgets/ContactUs"; import ContactUs from "@/widgets/ContactUs";
@@ -72,6 +67,24 @@ function LabBoard() {
{ image: Group_two, title: "Slide 2", description1: "Текст для слайда 2", description2: "222" } { image: Group_two, title: "Slide 2", description1: "Текст для слайда 2", description2: "222" }
]; ];
const [fade, setFade] = useState(false);
const nextSlide = () => {
setFade(true);
setTimeout(() => {
setCurrentSlide((prev) => (prev + 1) % slides.length);
setFade(false);
}, 200);
};
const prevSlide = () => {
setFade(true);
setTimeout(() => {
setCurrentSlide((prev) => (prev - 1 + slides.length) % slides.length);
setFade(false);
}, 200);
};
return ( return (
<div> <div>
<div id={styles.pageheader}> <div id={styles.pageheader}>
@@ -154,58 +167,52 @@ function LabBoard() {
<div className={styles.sliderHeaderContainer}> <div className={styles.sliderHeaderContainer}>
<h2 className={styles.title}>Подробнее о микроконтроллерах</h2> <h2 className={styles.title}>Подробнее о микроконтроллерах</h2>
<div className={styles.sliderNav}> <div className={styles.sliderNav}>
<button className={`${styles.sliderButton} ${styles.sliderPrevBtn}`}> <button onClick={prevSlide} className={styles.sliderButton}>
<img src={Vector} style={{ transform: 'scaleX(-1)' }} alt="Previous" /> <img src={Vector} style={{ transform: 'scaleX(-1)' }} alt="Previous" />
</button> </button>
<button className={`${styles.sliderButton} ${styles.sliderNextBtn}`}> <button onClick={nextSlide} className={styles.sliderButton}>
<img src={Vector} alt="Next" /> <img src={Vector} alt="Next" />
</button> </button>
</div> </div>
</div> </div>
</div>
<div className={styles.sliderWrapper}> <div id={styles.padding2} className={styles.sliderWrapper}>
<Swiper <button onClick={prevSlide} className={styles.sliderButton2}>
modules={[Navigation]} <img src={Vector} style={{ transform: 'scaleX(-1)' }} alt="Previous" />
navigation={{ </button>
nextEl: `.${styles.sliderNextBtn}`,
prevEl: `.${styles.sliderPrevBtn}`, <div
}}
spaceBetween={32}
slidesPerView={2}
centeredSlides={true}
loop={true}
onSlideChange={(swiper) => setCurrentSlide(swiper.realIndex)}
className={styles.sliderContainer} className={styles.sliderContainer}
allowTouchMove={false} {...useSwipeable({
breakpoints={{ onSwipedLeft: nextSlide,
0: { onSwipedRight: prevSlide,
slidesPerView: 1, preventScrollOnSwipe: true,
centeredSlides: false, trackMouse: true,
}, })}
768: {
slidesPerView: 2,
centeredSlides: true,
}
}}
> >
{slides.map((slide, index) => ( <div className={`${styles.slideActive} ${fade ? styles.fadeOut : ''}`}>
<SwiperSlide
key={index}
className={`${styles.swiperSlide} ${currentSlide === index ? styles.slideActive : ""}`}
>
<div className={styles.slideContent}>
<img <img
src={slide.image} src={slides[currentSlide].image}
alt={slide.title} alt={slides[currentSlide].title}
className={styles.slideImage} className={styles.activeImage}
/> />
</div> </div>
</SwiperSlide> <div className={`${styles.slideNext} ${fade ? styles.fadeOut : ''}`}>
))} <img
</Swiper> src={slides[(currentSlide + 1) % slides.length].image}
alt={slides[(currentSlide + 1) % slides.length].title}
className={styles.nextImage}
/>
</div> </div>
<div> </div>
<button onClick={nextSlide} className={styles.sliderButton2}>
<img src={Vector} alt="Next" />
</button>
</div>
<div id={styles.padding}>
<h4><div className={styles.slideDescription}> <h4><div className={styles.slideDescription}>
{slides[currentSlide]?.title} {slides[currentSlide]?.title}
</div></h4> </div></h4>
@@ -222,7 +229,6 @@ function LabBoard() {
</p> </p>
</div> </div>
</div> </div>
</div>
<div id={styles.padding}> <div id={styles.padding}>
<ContactUs /></div> <ContactUs /></div>