Banner.js
4.06 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import React from "react";
import { Swiper, SwiperSlide } from "swiper/react";
import { motion } from "framer-motion";
import { fadeIn, zoomIn, slideFromLeft, slideFromRight } from "../animationvariants.js";
import { Pagination, Navigation, Autoplay } from "swiper/modules";
// Import Swiper styles
import "swiper/css";
import "swiper/css/pagination";
import "swiper/css/navigation";
import Image from "next/image.js";
import { cleanImage } from "../../services/imageHandling.js";
const Banner = ({ homeBanner }) => {
return (
<>
<section className="home-banner">
<div>
<Swiper
slidesPerView={1}
// autoplay={{
// delay: 9000,
// disableOnInteraction: false
// }}
autoplay={false}
spaceBetween={10}
navigation={true}
pagination={{
clickable: true
}}
// breakpoints={{
// 640: {
// slidesPerView: 2,
// spaceBetween: 20
// },
// 768: {
// slidesPerView: 4,
// spaceBetween: 40
// },
// 1024: {
// slidesPerView: 5,
// spaceBetween: 50
// }
// }}
modules={[Pagination, Navigation, Autoplay]}
className="mySwiper01"
>
{
/*map through the array of images*/
homeBanner?.data &&
homeBanner?.data.map((data, index) => {
return (
<SwiperSlide>
<div className="slider-item slider-item-01">
<div className="home-banner-bg">
<span className="image-container hide-on-mobile">
{console.log("clean image", cleanImage(data?.attributes?.desktopBanner?.data?.attributes))}
<img layout="fill" className="image img-fluid" alt="" src={cleanImage(data?.attributes?.desktopBanner?.data?.attributes)} />
</span>
<span className="image-container hide-on-desktop">
<img layout="fill" className="image img-fluid" alt="" src={cleanImage(data?.attributes?.mobileBanner?.data?.attributes)} />
</span>
</div>
<div className="d-table">
<div className="d-table-cell">
<div className="container">
<motion.div variants={slideFromRight(0.4)} initial={"false"} whileInView={"show"} viewport={{ once: false, amount: 0.2 }}>
<div className="row">
<div className="col-md-6">
<div className="slider-text">
<div className="banner-title">
<div className="banner-txt">
<h1>{data?.attributes?.title}</h1>
<div className="title">{data?.attributes?.subTitle}</div>
<div className="disc">{data?.attributes?.discription}</div>
</div>
</div>
<div className="common-btn">
<a className="btn btn-primary" href={data?.attributes?.exploreNowButton}>
Explore Now
</a>
</div>
</div>
</div>
</div>
</motion.div>
</div>
</div>
</div>
</div>
</SwiperSlide>
);
})
}
</Swiper>
</div>
</section>
</>
);
};
export default Banner;