swiper slider added

master
mahdi andalib 3 years ago
parent a2c2404ba4
commit d92e0b3880
  1. 1
      package.json
  2. 117
      src/components/Digikala/Offer.js
  3. 15432
      yarn.lock

@ -24,6 +24,7 @@
"redux": "^4.1.2", "redux": "^4.1.2",
"sass": "^1.45.0", "sass": "^1.45.0",
"sweetalert2": "^11.3.4", "sweetalert2": "^11.3.4",
"swiper": "^8.0.6",
"tw-elements": "^1.0.0-alpha8", "tw-elements": "^1.0.0-alpha8",
"use-draggable-scroll": "^0.1.0", "use-draggable-scroll": "^0.1.0",
"web-vitals": "^2.1.2" "web-vitals": "^2.1.2"

@ -1,4 +1,10 @@
import React from "react"; import React from "react";
import { Swiper, SwiperSlide } from "swiper/react";
// Import Swiper styles
import "swiper/css";
import "swiper/css/navigation";
import "swiper/css/pagination";
import "./index"; import "./index";
import leftArrow from "./white-left-arrow.svg"; import leftArrow from "./white-left-arrow.svg";
@ -33,72 +39,55 @@ const Offer = ({ products }) => {
</button> </button>
</div> </div>
{/* left */} {/* left */}
{/* no-scrollbar */} <div className="w-10/12 flex flex-row items-center rounded-lg bg-white">
<div <Swiper
className="tabbar overflow-x-scroll scrolling-touch w-10/12 flex flex-row items-center rounded-lg bg-white" // spaceBetween={0}
onMouseDown={(e) => { slidesPerView={5}
const slider = window.document.querySelector(".tabbar"); navigation
window.isDown = true; pagination={{ clickable: true }}
window.startX = e.pageX - slider.offsetLeft; scrollbar={{ draggable: true }}
window.scrollLeft = slider.scrollLeft; onSlideChange={() => console.log("slide change")}
}} onSwiper={(swiper) => console.log(swiper)}
onMouseLeave={(e) => { >
window.isDown = false; {/* */}
}} {products.map((product, index) => (
onMouseUp={(e) => { <SwiperSlide>
window.isDown = false; <div className="flex flex-col p-2">
}} <img src={product.image} className="rounded" />
onMouseMove={(e) => { <div className="flex flex-row justify-between items-center mt-4">
const slider = window.document.querySelector(".tabbar"); <p className="text-xs text-white bg-red-600 px-2 py-0.5 rounded-lg mr-1">
if (!window.isDown) return; {product.discount}
e.preventDefault(); <span className="">%</span>
const x = e.pageX - slider.offsetLeft; </p>
const walk = (x - window.startX) * 1; <div className="flex flex-row items-center">
slider.scrollLeft = window.scrollLeft - walk; <p className="text-sm ml-1">{product.price}</p>
}} <div className="relative">
> <span className="text-xs">توما</span>
{products.map((product, index) => ( <span className="text-xs absolute left-0.5 -top-2">
<div ن
className="flex flex-col p-2" </span>
aria-current="page" </div>
onClick={(e) => { </div>
if (window.isDown) return e.preventDefault(); </div>
///do here <p
}} className="text-left text-xs line-through my-2 ml-3"
> style={{ color: "#c0c2c5" }}
<img src={product.image} className="rounded w-40" /> >
<div className="flex flex-row justify-between items-center mt-4"> {product.discountPrice}
{/* right */} </p>
<p className="text-xs text-white bg-red-600 px-2 py-0.5 rounded-lg mr-1"> <div className="bg-gray-200 h-1.5 mx-auto rounded mt-2 flex flex-row-reverse w-11/12">
{product.discount} <div
<span className="">%</span> className={`h-1.5 rounded duration-500`}
</p> style={{
{/* left */} width: product.rangeWidth,
<div className="flex flex-row items-center"> backgroundColor: "#ef3a4f",
<p className="text-sm ml-1">{product.price}</p> }}
<div className="relative"> ></div>
<span className="text-xs">توما</span>
<span className="text-xs absolute left-0.5 -top-2">ن</span>
</div> </div>
</div> </div>
</div> </SwiperSlide>
<p ))}
className="text-left text-xs line-through my-2 ml-3" </Swiper>
style={{ color: "#c0c2c5" }}
>
{product.discountPrice}
</p>
<div className="bg-gray-200 h-1.5 mx-auto rounded mt-2 flex flex-row-reverse w-10/12">
<div
className={`h-1.5 rounded duration-500`}
style={{
width: product.rangeWidth,
backgroundColor: "#ef3a4f",
}}
></div>
</div>
</div>
))}
</div> </div>
</div> </div>
</section> </section>

15432
yarn.lock

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save