HomeBanner.js
2.69 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
import React, { useState, useEffect } from "react";
import { Swiper, SwiperSlide } from "swiper/react";
import "swiper/css";
import "swiper/css/navigation";
import "swiper/css/pagination";
import { Navigation, Pagination, Autoplay } from "swiper/modules";
import SwiperBtn from "@/components/Layout/SwiperBtn";
const BannerData = [
{
desktopImage: "/image/banner/banner1.png",
mobileImage: "/image/banner/mb2.png",
title: "KITCHENS",
description:
"Transform your cooking space into a modern kitchen oasis. With sleek cabinetry and state-of-the-art appliances, you can create a functional yet stylish environment.",
},
{
desktopImage: "/image/banner/banner1.png",
mobileImage: "/image/banner/mb2.png",
title: "LIVING ROOMS",
description:
"Experience comfort and elegance in your living space. Designed with premium furniture and modern décor to elevate your lifestyle.",
},
{
desktopImage: "/image/banner/banner1.png",
mobileImage: "/image/banner/mb2.png",
title: "BEDROOMS",
description:
"Create your dream retreat with cozy and stylish bedroom designs. A perfect balance of comfort, elegance, and tranquility.",
},
];
const HomeBanner = () => {
const [isMobile, setIsMobile] = useState(false);
// Detect screen width
useEffect(() => {
const handleResize = () => setIsMobile(window.innerWidth <= 767);
handleResize();
window.addEventListener("resize", handleResize);
return () => window.removeEventListener("resize", handleResize);
}, []);
return (
<Swiper
navigation={{
nextEl: ".cust-swiper-button-next",
prevEl: ".cust-swiper-button-prev",
}}
pagination={{ clickable: true }}
autoplay={{ delay: 5000 }}
loop
modules={[Navigation, Pagination, Autoplay]}
className="homeBannerSwiper"
>
<div className="position-absolute swiperbtn1 d-lg-flex d-none justify-content-md-between px-5 align-items-center w-100">
<SwiperBtn />
</div>
{BannerData.map((item, index) => (
<SwiperSlide key={index}>
<div className="slide-container">
<img
src={isMobile ? item.mobileImage : item.desktopImage}
alt={item.title}
className="slide-bg"
/>
<div className="slide-overlay">
<div className="slide-content">
<h2>{item.title}</h2>
<div className="text-btn-row">
<p>{item.description}</p>
<button className="btn1">Explore More</button>
</div>
</div>
</div>
</div>
</SwiperSlide>
))}
</Swiper>
);
};
export default HomeBanner;