summaryrefslogtreecommitdiff
path: root/src/components/product/ProductSlider.js
blob: 26584d8ad21391fb5a75cd13379fcf2669853084 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { Swiper, SwiperSlide } from "swiper/react";
import ProductCard from "../ProductCard";
import ImagePlaceholderIcon from "../../icons/image-placeholder.svg";
import "swiper/css";

export default function ProductSlider({ products }) {
  return (
    <>
      <Swiper freeMode={true} slidesPerView={2.15} spaceBetween={8}>
        {products?.products?.map((product, index) => (
          <SwiperSlide key={index}>
            <ProductCard data={product} />
          </SwiperSlide>
        ))}
      </Swiper>
      {products == null ? (
        <div className="grid grid-cols-2 gap-x-4">
          <div role="status" className="p-4 max-w-sm rounded border border-gray-300 shadow animate-pulse md:p-6">
            <div className="flex justify-center items-center mb-4 h-48 bg-gray-300 rounded">
            <ImagePlaceholderIcon className="w-12 h-12 text-gray-200" />
            </div>
            <div className="h-2 bg-gray-200 rounded-full w-10 mb-1"></div>
            <div className="h-2.5 bg-gray-200 rounded-full w-full mb-4"></div>
            <div className="h-2 bg-gray-200 rounded-full mb-2.5"></div>
            <div className="h-2 bg-gray-200 rounded-full mb-2.5"></div>
            <div className="h-2 bg-gray-200 rounded-full"></div>
            <span className="sr-only">Loading...</span>
          </div>
          <div role="status" className="p-4 max-w-sm rounded border border-gray-300 shadow animate-pulse md:p-6">
            <div className="flex justify-center items-center mb-4 h-48 bg-gray-300 rounded">
              <ImagePlaceholderIcon className="w-12 h-12 text-gray-200" />
            </div>
            <div className="h-2 bg-gray-200 rounded-full w-10 mb-1"></div>
            <div className="h-2.5 bg-gray-200 rounded-full w-full mb-4"></div>
            <div className="h-2 bg-gray-200 rounded-full mb-2.5"></div>
            <div className="h-2 bg-gray-200 rounded-full mb-2.5"></div>
            <div className="h-2 bg-gray-200 rounded-full"></div>
            <span className="sr-only">Loading...</span>
          </div>
        </div>
      ) : ''}
    </>
  )
}