single products swiper

This commit is contained in:
Moaz Dawalibi 2024-06-22 14:45:28 +03:00
parent 949f8de235
commit c51332ee03
3 changed files with 73 additions and 25 deletions

View File

@ -0,0 +1,42 @@
// import Swiper core and required modules
import { Navigation, A11y } from "swiper/modules";
import { Swiper, SwiperSlide } from "swiper/react";
// Import Swiper styles
import "swiper/css";
import "swiper/css/navigation";
import "swiper/css/pagination";
import "swiper/css/scrollbar";
import CustomImage from "../../ui/CustomImage";
const ProductSlider = (data:any) => {
const handelImage = (item: any) => {
// setMainImage(item);
};
return (
<div className="product_images_swiper">
<Swiper
modules={[Navigation, A11y]}
spaceBetween={10}
slidesPerView={4}
navigation
>
{data?.images?.map(({item,index}:any)=>{
return (
<SwiperSlide key={index}>
<span key={index} onClick={() => handelImage(item?.path)} >
<CustomImage
className="product_multi_image"
src={item?.path}
alt=""
/>
</span>
</SwiperSlide>
)
})}
</Swiper>
</div>
);
};
export default ProductSlider;

View File

@ -20,6 +20,7 @@ import { toast } from "react-toastify";
import { FaCartPlus } from "react-icons/fa"; import { FaCartPlus } from "react-icons/fa";
import { useCartState } from "../../state/CartState"; import { useCartState } from "../../state/CartState";
import useAuthState from "../../state/AuthState"; import useAuthState from "../../state/AuthState";
import ProductSlider from "../../Components/Products/ProductSlider";
const Page = () => { const Page = () => {
@ -98,7 +99,7 @@ const Page = () => {
</header> </header>
<main> <main>
<div className="Product_left"> <div className="Product_left">
<span> <span className="Product_left_container">
<div className="fav_icon"> <div className="fav_icon">
<IoHeartOutline <IoHeartOutline
onClick={() => handelChangeFavorite(product)} onClick={() => handelChangeFavorite(product)}
@ -110,22 +111,13 @@ const Page = () => {
</div> </div>
<CustomImage src={MainImage ?? product?.main_photo} alt="" /> <CustomImage src={MainImage ?? product?.main_photo} alt="" />
<div className="gallery_product"> <div className="gallery_product">
{product?.images?.map((item,index)=>{ <ProductSlider data={product}/>
return ( {/* <span>
<span key={index} onClick={() => handelImage(item?.path)} >
<CustomImage
src={item?.path}
alt=""
/>
</span>
)
})}
<span>
<img <img
onClick={() => handelImage('/Home/p1.png')} onClick={() => handelImage('/Home/p1.png')}
alt="" alt=""
/> />
</span> </span> */}
</div> </div>
</span> </span>

View File

@ -31,7 +31,8 @@
} }
} }
} }
> span { .Product_left_container {
width: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 20px; gap: 20px;
@ -46,19 +47,10 @@
&::-webkit-scrollbar { &::-webkit-scrollbar {
display: none; display: none;
} }
span {
padding: 10px 15px;
border: 2px solid rgba(128, 128, 128, 0.1);
width: 100%;
> img {
width: 100%;
cursor: pointer;
}
}
}
}
}
}
}
}
.Product_info { .Product_info {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -76,7 +68,7 @@
display: flex; display: flex;
align-items: flex-start; align-items: flex-start;
gap: 20px; gap: 20px;
width: 80%; width: 100%;
padding: 10px 15px 0px 15px; padding: 10px 15px 0px 15px;
&:nth-child(odd){ &:nth-child(odd){
background: var(--whiteOpacity) !important; background: var(--whiteOpacity) !important;
@ -95,6 +87,28 @@
} }
} }
} }
.product_images_swiper{
width: 100%;
.swiper-button-prev:after, .swiper-button-next:after{
color: var(--text);
font-size: 25px;
background: #fff;
padding: 4px;
border-radius: 4px;
}
.swiper-backface-hidden .swiper-slide{
padding-inline: 20px;
min-width: 50px !important;
}
> span{
width: 50px;
}
.product_multi_image{
width: 50px !important;
}
}
} }
.Product_Right{ .Product_Right{
width: 50%; width: 50%;