Guest User

Untitled

a guest
Sep 25th, 2020
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from "react";
  2. import s from "./imgs.module.css";
  3. import { imgOnShowSet } from "../../../../redux/oneGoods/action";
  4. import { connect } from "react-redux";
  5. import SwiperCore, { Pagination, Autoplay } from "swiper";
  6. import { Swiper, SwiperSlide } from "swiper/react";
  7. // import "swiper/swiper.scss";
  8. // import "swiper/components/pagination/pagination.scss";
  9. import { option } from "../../../../option";
  10.  
  11. SwiperCore.use([Pagination, Autoplay]);
  12. const Img = (props) => {
  13.   return (
  14.     <div className={s.imgsBox}>
  15.       <Swiper
  16.         slidesPerView={1}
  17.         autoHeight={true}
  18.         roundLengths={true}
  19.         autoplay={{ delay: 2000 }}
  20.         pagination={{ clickable: true }}
  21.       >
  22.         {props.data.img.map((item, index) => (
  23.           <SwiperSlide key={index}>
  24.             <picture style={{ width: "100%" }}>
  25.               <source
  26.                 style={{ width: "100%" }}
  27.                 type="image/webp"
  28.                 media="(max-width: 400px)"
  29.                 srcSet={`${option.STATIC}/webp/${props.data._id}/${item}-400.webp`}
  30.               />
  31.               <source
  32.                 style={{ width: "100%" }}
  33.                 type="image/webp"
  34.                 media="(max-width: 600px)"
  35.                 srcSet={`${option.STATIC}/webp/${props.data._id}/${item}-600.webp`}
  36.               />
  37.               <source
  38.                 style={{ width: "100%" }}
  39.                 type="image/webp"
  40.                 media="(max-width: 1024px)"
  41.                 srcSet={`${option.STATIC}/webp/${props.data._id}/${item}-1024.webp`}
  42.               />
  43.               <source
  44.                 style={{ width: "100%" }}
  45.                 type="image/jpeg"
  46.                 media="(max-width: 400px)"
  47.                 srcSet={`${option.STATIC}/jpeg/${props.data._id}/${item}-400.jpeg`}
  48.               />
  49.               <source
  50.                 style={{ width: "100%" }}
  51.                 type="image/jpeg"
  52.                 media="(max-width: 600px)"
  53.                 srcSet={`${option.STATIC}/jpeg/${props.data._id}/${item}-600.jpeg`}
  54.               />
  55.               <source
  56.                 style={{ width: "100%" }}
  57.                 type="image/jpeg"
  58.                 media="(max-width: 1024px)"
  59.                 srcSet={`${option.STATIC}/jpeg/${props.data._id}/${item}-1024.jpeg`}
  60.               />
  61.               <img
  62.                 style={{ width: "100%" }}
  63.                 src={`${option.STATIC}/jpeg/${props.data._id}/${item}-1024.jpeg`}
  64.                 alt=""
  65.               />
  66.             </picture>
  67.           </SwiperSlide>
  68.         ))}
  69.       </Swiper>
  70.     </div>
  71.   );
  72. };
  73. const mapStateToProps = (state) => {
  74.   return {
  75.     img: state.oneGoods.product.img,
  76.   };
  77. };
  78.  
  79. export const Imgs = connect(mapStateToProps, {
  80.   imgOnShowSet,
  81. })(Img);
  82.  
Advertisement
Add Comment
Please, Sign In to add comment